java.lang.RuntimeException: Unable to create service

D

Deleted member 103

Guest
Hi,

I got from a user from google play this error message:
The error message is produced by this app.
What may have triggered it?
With the devices I tested it had no problem.

Ciao,
Filippo
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is the relevant part:

It fails to load the media file. You can use Try / Catch to catch this error.
 
Upvote 0
D

Deleted member 103

Guest
Hi Erel,
Thanks for the reply.

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?
 
Upvote 0
D

Deleted member 103

Guest
Here is a part of the service:
B4X:
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

Can I improve something here?
 
Upvote 0

Amalkotey

Active Member
Licensed User
Longtime User
Hi Filippo,

meine Create Sub sieht immer so aus:

B4X:
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
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…