点击下一首的时候报java.lang.IllegalStateException 报的是int position = player.getCurrentPosition();这句话,网上说加上return就没了,的确加上之后是没报了,但是播放时间和进度条也不动了。求解,这是怎么回事。
if (player != null) {
int position = player.getCurrentPosition();
int total = player.getDuration();
Intent intent = new Intent("cn.com.karl.progress");
intent.putExtra("position", position);
intent.putExtra("total", total);
sendBroadcast(intent);
}
if (player != null) {
int position = player.getCurrentPosition();
int total = player.getDuration();
Intent intent = new Intent("cn.com.karl.progress");
intent.putExtra("position", position);
intent.putExtra("total", total);
sendBroadcast(intent);
}
解决方案 »
- Android应用App之间通信
- android解析json报空指针异常。
- 在activity里启动service之后怎么样才可以得到这个service的实例
- android程序中 手机图中的选中的一张图放到指定服务器中的一目录下,在线等
- calendar broadcast
- Android 执行Socket socket = new Socket(ip, port)就崩溃
- 安卓模拟器一直处在 LOGO界面
- 子fragment调用MainActivity中
- WXEntryActivity配置android:exported="true",有安全漏洞,怎么修复?
- 求解:Glide加载图片问题,只加载前5张?
- 谷歌map密钥申请
- android开发 如何把相册里图片剪裁成适合屏幕大小的图片
MediaPlay 有一套状态机,类中的很多接口都只能在某种状态下才能使用,否则则会抛出java.lang.IllegalStateException。楼主给的代码太少,看不出问题。自己查查是否是调用的时候状态不对导致。