FATAL EXCEPTION: Timer-0 java.lang.IllegalArgumentException

本文记录了一次在Android设备上进行视频播放时遇到的错误,该错误与SurfaceView和MediaPlayer有关,具体表现为IllegalArgumentException异常。文章探讨了两种可能的原因:一是由于Android版本升级导致的问题;二是关于如何正确使用Timer及避免在UI线程中执行长时间任务的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

描述:

01-21 07:00:40.523: E/AndroidRuntime(717):        FATAL EXCEPTION: Timer-0

01-21 07:00:40.523: E/AndroidRuntime(717):        java.lang.IllegalArgumentException

01-21 07:00:40.523: E/AndroidRuntime(717):       at android.view.Surface.unlockCanvasAndPost(Native Method)

01-21 07:00:40.523: E/AndroidRuntime(717):       at android.view.SurfaceView$3.unlockCanvasAndPost(SurfaceView.java:793)

01-21 07:00:40.523: E/AndroidRuntime(717):       at com.testSurfaceView.TestSurfaceView.SimpleDraw(TestSurfaceView.java:217)

01-21 07:00:40.523: E/AndroidRuntime(717):       at com.testSurfaceView.TestSurfaceView$MyTimerTask.run(TestSurfaceView.java:163)

01-21 07:00:40.523: E/AndroidRuntime(717):       at java.util.Timer$TimerImpl.run(Timer.java:284)

 

搜索到的解释:

 (1) 版本问题

Iam getting this error at the time of video playback and the platform
is Moto Droid with Froyo. Have to tell you, this has started ever
since my Droid got upgraded to 2.2.

 

 

(2) timer和AndroidUI的操作问题

KK wrote:

> hi,

> Seems the logcat

>> 11-26 13:32:06.727: ERROR/AndroidRuntime(10779): FATAL EXCEPTION: Timer-0

> 11-26 13:32:06.727: ERROR/AndroidRuntime(10779):> java.lang.IllegalStateException

> 11-26 13:32:06.727: ERROR/AndroidRuntime(10779):     at> android.media.MediaPlayer.getCurrentPosition(Native Method)

> 11-26 13:32:06.727: ERROR/AndroidRuntime(10779):     at> com.infineon.musicplayer4mNet.MusicPlayerActivity$2.run(MusicPlayerActivity.java:174)

> 11-26 13:32:06.727: ERROR/AndroidRuntime(10779):     at> java.util.Timer$TimerImpl.run(Timer.java:284)

 

>>Try to cancel() the timer before releazing media player. Also try to avoid Timer/TimerTask, use Handler insteadpskink.

 

已经解决了问题的同学请留个言,分享一下!

03-16 12:33:00.942 18324 18324 E AndroidRuntime: FATAL EXCEPTION: main 03-16 12:33:00.942 18324 18324 E AndroidRuntime: Process: com.android.bluetooth, PID: 18324 03-16 12:33:00.942 18324 18324 E AndroidRuntime: java.lang.IllegalArgumentException: Receiver not registered: com.oplus.bluetooth.feature.dcs.OplusBluetoothRecorderFactory$1@f666353 03-16 12:33:00.942 18324 18324 E AndroidRuntime: at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:1777) 03-16 12:33:00.942 18324 18324 E AndroidRuntime: at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1922) 03-16 12:33:00.942 18324 18324 E AndroidRuntime: at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:832) 03-16 12:33:00.942 18324 18324 E AndroidRuntime: at com.oplus.bluetooth.feature.dcs.03-16 12:33:00.942 18324 18324 E AndroidRuntime: FATAL EXCEPTION: main 03-16 12:33:00.942 18324 18324 E AndroidRuntime: Process: com.android.bluetooth, PID: 18324 03-16 12:33:00.942 18324 18324 E AndroidRuntime: java.lang.IllegalArgumentException: Receiver not registered: com.oplus.bluetooth.feature.dcs.OplusBluetoothRecorderFactory$1@f666353 03-16 12:33:00.942 18324 18324 E AndroidRuntime: at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:1777) 03-16 12:33:00.942 18324 18324 E AndroidRuntime: at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1922) 03-16 12:33:00.942 18324 18324 E AndroidRuntime: at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:832) 03-16 12:33:00.942 18324 18324 E AndroidRuntime: at com.oplus.bluetooth.feature.dcs.OplusBluetoothRecorderFactory.cleanUp(OplusBluetoothRecorderFactory.java:312).cleanUp(OplusBluetoothRecorderFactory.java:312) 帮我看看报错是什么,是什么类型的报错,怎么导致的
03-21
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值