I got from a user from google play this error message:
java.lang.RuntimeException: Unable to create service fg.ItalyStopWatch.smtimer: java.lang.RuntimeException: java.io.IOException: Prepare failed.: status=0x1
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2031)
at android.app.ActivityThread.access$2500(ActivityThread.java:124)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1022)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3806)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: java.io.IOException: Prepare failed.: status=0x1
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:195)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at fg.ItalyStopWatch.smtimer.onCreate(smtimer.java:42)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2021)
... 10 more
Caused by: java.io.IOException: Prepare failed.: status=0x1
at android.media.MediaPlayer.prepare(Native Method)
at anywheresoftware.b4a.objects.MediaPlayerWrapper.Load(MediaPlayerWrapper.java:86)
at fg.ItalyStopWatch.smtimer._service_create(smtimer.java:231)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
... 13 more
Caused by: java.io.IOException: Prepare failed.: status=0x1
at android.media.MediaPlayer.prepare(Native Method)
at anywheresoftware.b4a.objects.MediaPlayerWrapper.Lo ad(MediaPlayerWrapper.java:86)
at fg.ItalyStopWatch.smtimer._service_create(smtimer. java:231)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
OK, I can use Try / Catch to catch this error, but the question is why the error is thrown?
Do I have every time before I want to use the media player, check that the media player has been initialized?
It fails because the native media player service failed to load the media file. It is impossible to say why it failed and whether it will succeed loading a different file.
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private n As Notification
Private phone1 As Phone
Public mPlayer As MediaPlayer
Public plyVolume As Float
Public oldVolume As Int
Private beep As MediaPlayer
End Sub
Sub Service_Create
n.Initialize
n.Icon = "icon_36_36"
n.SetInfo(Main.AppName,"",Main)
n.Sound = False
n.Vibrate = False
'Initiallisiere beeper
beep.Initialize
beep.Load(File.DirAssets,"beep.mp3")
'Mediaplayer initiallisieren
mPlayer.Initialize2("mPlayer")
oldVolume=phone1.GetVolume(phone1.VOLUME_MUSIC)
End Sub
Sub Service_Create
Try
cToast.Initialize
Global.InitializeLanguage
If AppNotification.IsInitialized = False Then
AppNotification.Initialize
AppNotification.Icon = "icon"
AppNotification.SetInfo2("ScreenOn-Widget (App)", Global.Trans.GetText("999"), "True", Main)
AppNotification.Sound = False
AppNotification.Vibrate = False
End If
Catch
Exceptions.RuntimeException("nService.Service_Create")
End Try
End Sub