I just noticed this with a WatchDog app (app A) I'm working on. It uses intents to communicate with another app (app B) that should constantly run. When you close out app B normally or even force stop the app, app A is able to start app B via intent. But, if app B crashes (in this case with some intentional code to see what happens), the user is given the option to restart app B. At that moment and time (when a user is given the option to restart the app) any attempts to wake up app B via app A's intents fail. It's like B is in limbo and does not process the intents. And it is not like the intents are queued and once app A runs (user restarts the app) it processes the missed intents; no, the intents are just gone. So, it seems that while an app is stuck in "restart mode" where a user is given the option to restart an app, all intents disappear into a black hole and the app is completely unresponsive.
Disclaimer: I'm not an expert, so I may just not have the chops to pull off what FB does (both apps mentioned are FB).how to do this?
This apparently happens. I have heard about some software companies, such as TeamViewer, to get some extra privileges but this was by making deals directly with manufacturers such as Samsung, Huawei etc..I'm really starting to think that some vendors, especially the big vendors, pay Google (and Apple - I'm looking at you Dropbox) for some nice back door API access that gives them a leg up over us smaller developers. Of course, I may just suck at this.
Yes, and this behavior could be a problem with high priority apps. Depending on user to restart is a disaster: imagine a messenger which receives important information about a company and the employee must to take some action for each event. This must to be some way to garante that a high priority app is running on Android and SO MUST to restart each if it stops...
Does anybody knows how to do it (by the way, I noticed that some famous apps like WhatsApp and FB Messenger have a behavior as always running... even after a crash, some minutes later there are notifications arriving again, even without any user action... how to do this?)
There is a way to disable the restart message. See https://www.b4x.com/android/forum/threads/auto-restart-an-android-application-after-a-crash.103858/I notice that, after an error, if the user doesn't restart the app, even ServiceStartAt doesn't work...
The last sentence applies. Plus, a shout out/apology to the really smart people working at other companies (that I disparaged here).Disclaimer: I'm not an expert, so I may just not have the chops to pull off what FB does (both apps mentioned are FB).
I'm really starting to think that some vendors, especially the big vendors, pay Google (and Apple - I'm looking at you Dropbox) for some nice back door API access that gives them a leg up over us smaller developers. Of course, I may just suck at this.
Hello,There is a way to disable the restart message. See https://www.b4x.com/android/forum/threads/auto-restart-an-android-application-after-a-crash.103858/
The last sentence applies. Plus, a shout out/apology to the really smart people working at other companies (that I disparaged here).
Hello,
In this thread he says that doesn't know what happens if a service crashes, what is exactly my problem because our app stops when it is in background... I'll test but not sure that will work...
Thanks !
Hello @Jmu5667 ... follows my service_createHow are you setting up the background service, can you show me the code in the service_create and service_start please
Sub Service_Create
'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.
Permissions = Non_Authorized_Runtime_Permissions
Kvs.Initialize(File.DirInternal,"riolivre")
NativeMe.InitializeContext
SdkVersion = Phone1.SdkVersion
'Kvs.DeleteAll
'File.Delete(File.DirInternal,"nexphone.db")
'Values from 0 to 30... from 0 to 1, reduce, above 1, aplify
If Not(Kvs.ContainsKey("miclevelradio")) Then
Kvs.Put("miclevelradio",10)
Kvs.put("speakerlevelradio",10)
Kvs.Put("miclevelphone",12)
Kvs.Put("speakerlevelphone",10)
End If
If File.Exists(File.DirInternal,"voice_note_start.wav") = False Then
File.Copy(File.DirAssets,"voice_note_start.wav",File.DirInternal,"voice_note_start.wav")
File.Copy(File.DirAssets,"voice_note_stop.wav",File.DirInternal,"voice_note_stop.wav")
File.Copy(File.DirAssets,"voice_note_error.wav",File.DirInternal,"voice_note_error.wav")
End If
If Not(File.Exists(File.DirInternal,"placedetails.db")) Then
File.Copy(File.DirAssets,"placedetails.db",File.DirInternal,"placedetails.db")
End If
If Not(File.Exists(File.DirInternal,"profile.png")) Then
File.Copy(File.DirAssets,"actionbar_button_person_dark.png",File.DirInternal,"profile.png")
End If
If Not(File.Exists(File.DirInternal,"genericnotify.png")) Then
File.Copy(File.DirAssets,"actionbar_button_person_dark.png",File.DirInternal,"genericnotify.png")
End If
If Not(Kvs.ContainsKey("country")) Then
Kvs.Put("country","br")
End If
If Not(Kvs.ContainsKey("radiocallstarted")) Then
Kvs.Put("radiocallstarted",False)
End If
Kvs.Put("chamadaemcurso",False)
If Not(Kvs.ContainsKey("radioactive")) Then
Kvs.Put("radioactive",False)
End If
'Nb.Initialize
Sql1.Initialize(File.DirInternal,"nexphone.db",True)
Dim Query As String
'Query = "drop table radiohistory"
'Sql1.ExecNonQuery(Query)
'Query = "drop table busca"
'Sql1.ExecNonQuery(Query)
'Query = "drop table contacts"
'Sql1.ExecNonQuery(Query)
'Query = "drop table indications"
'Sql1.ExecNonQuery(Query)
Dim DbUpdate As Boolean = False
If Kvs.ContainsKey("database-done") = False Then
DbUpdate = True
Else
If Kvs.Get("database-done") <> "43.1.0" Then DbUpdate = True
End If
If DbUpdate = True Then
Kvs.Put("database-done","43.1.0")
Query = "create table if not exists radiohistory (id integer PRIMARY KEY,iduser integer,login text,nome text,company text,mobile text,googleid text,start real,answer real,end real,status text)"
Sql1.ExecNonQuery(Query)
Query = "create table if not exists busca (id integer PRIMARY KEY,login text,nome text,company text,mobile text,datahora real,googleid text)"
Sql1.ExecNonQuery(Query)
Query = "create table if not exists contacts (id integer PRIMARY KEY,login text,nome text,company text,mobile text,datahora real,googleid text) "
Sql1.ExecNonQuery(Query)
Query = "create table if not exists indications (googleid text PRIMARY KEY,photoreference text,company text,nome text,telefone text,celular text,datahora real,enviada integer default 0) "
Sql1.ExecNonQuery(Query)
Query = "create table if not exists addedplaces (googleid text PRIMARY KEY,latitude text,longitude text,accuracy text,name text,phone_number text,address text,types text,website text,language text,datahora real)"
Sql1.ExecNonQuery(Query)
Query = "create table if not exists chats (id text primary key,title text,description text,logofile text,created real,id_creator integer,is_active int," _
& "is_pro int,daysofweek text,starthour int,startminute int,endhour int,endminute int,chat_active real)"
Sql1.ExecNonQuery(Query)
Query = "create table if not exists messages (id text primary key,chatid text,source int,target int,msgcreated real, msgsent real, msgreceived real,msgread real,media_url text " _
& ",media_mime_type,media_size int,media_name text,media_caption text,media_duration int,latitude real,longitude real,thumb_image text,msgdata text)"
Sql1.ExecNonQuery(Query)
Query = "create table if not exists messagestemp (id text primary key,chatid text,source int,target int,msgcreated real, msgsent real, msgreceived real,msgread real,media_url text " _
& ",media_mime_type,media_size int,media_name text,media_caption text,media_duration int,latitude real,longitude real,thumb_image text,msgdata text)"
Sql1.ExecNonQuery(Query)
'#### TODO - CREATE UNIQUE STATEMENT
Query = "create table if not exists chat_users (iduser int,idchat text,starttime real,endtime real,isadmin int,primary key (iduser,idchat) )"
Sql1.ExecNonQuery(Query)
Try
Query = "alter table chat_users add nome text"
Sql1.ExecNonQuery(Query)
Query = "alter table chat_users add login text"
Sql1.ExecNonQuery(Query)
Query = "alter table chat_users add company text"
Sql1.ExecNonQuery(Query)
Catch
Log(LastException)
End Try
Try
Query = "create index idx_msgcreated on messages (msgcreated)"
Sql1.ExecNonQuery(Query)
Query = "create index idx_chatid on messages (chatid)"
Sql1.ExecNonQuery(Query)
Catch
Log(LastException)
End Try
'### TODO - END UNIQUE STATEMENT
Query = "create table if not exists msgqueue (id int,iduser int,msgdata text,datetime real)"
Sql1.ExecNonQuery(Query)
'Query = "delete from upmediaqueue"
'Sql1.ExecNonQuery(Query)
Query = "create table if not exists upmediaqueue (id int,iduser int,msgdata text,datetime real)"
Sql1.ExecNonQuery(Query)
Query = "create table if not exists compressmediaqueue (id int,mediatype text,chatid text,messageid text,msgstring text,situation text,datetime real)"
Sql1.ExecNonQuery(Query)
Query = "create table if not exists chatselected (id int primary key)"
Sql1.ExecNonQuery(Query)
Query = "alter table chatselected add idchat text"
Try
Sql1.ExecNonQuery(Query)
Catch
Log(LastException)
End Try
Query = "create table if not exists downqueue (id int,msgdata text,datetime real)"
Sql1.ExecNonQuery(Query)
Query = "alter table contacts add lastuse real default 0"
Try
Sql1.ExecNonQuery(Query)
Catch
Log(LastException)
End Try
Query = "create table if not exists messagestatus (messageid text,chatid text,userid int,msgdelivered real,msgread real,primary key (messageid,userid))"
Sql1.ExecNonQuery(Query)
Query = "create table if not exists downmediaqueue (id int primary key,chatid text,medialink text,mediafile text,mimetype text)"
Sql1.ExecNonQuery(Query)
Query = "create table if not exists userselected (id int primary key,login text,nome text,company text)"
Sql1.ExecNonQuery(Query)
Query = "create table if not exists messageselected (id text primary key,chatid text,media_mime_type text)"
Sql1.ExecNonQuery(Query)
End If
Dim ExtenFolder As String = rp.GetSafeDirDefaultExternal("shared")
File.copy(File.DirAssets,"radioshort.wav", ExtenFolder ,"radioshort.wav")
File.copy(File.DirAssets,"radiolong.wav",ExtenFolder ,"radiolong.wav")
File.copy(File.DirAssets,"radiook.wav",ExtenFolder ,"radiook.wav")
File.copy(File.DirAssets,"radiorefuse.wav",ExtenFolder ,"radiorefuse.wav")
File.copy(File.DirAssets,"radiostart.wav",ExtenFolder ,"radiostart.wav")
File.copy(File.DirAssets,"msgting.mpeg",ExtenFolder ,"msgting.mpeg")
File.Copy(File.DirAssets,"missed_radio.png",ExtenFolder,"missed_radio.png")
File.Copy(File.DirAssets,"largecall.png",ExtenFolder,"largecall.png")
File.Copy(File.DirAssets,"oncall.png",ExtenFolder,"oncall.png")
Initialize_Voip
End Sub
Sub Service_Start (StartingIntent As Intent)
If Kvs.ContainsKey("username") Then
Dim Username As String = Kvs.Get("username")
Dim Password As String = Kvs.Get("password")
'Phone.register ("falegratis.com.br", Username, Password, 600)
CallSubDelayed2(FirebaseMessaging, "SubscribeIndividual",Username)
End If
End Sub
No. The problem isn't related to foreground service state... the service is automatically called by firebase push service. If it's started as a foreground service a icon will be showed on notifications bar and the battery consumption will be high, what's not good.Do you want to keep this running all the time ?
I am using FCM Pushnotifications. My Service is NOT started in Foreground when a Message arrives! I don´t have any problem here.the service is automatically called by firebase push service. If it's started as a foreground service a icon will be showed on notifications bar and the battery consumption will be high, what's not good.
I am using FCM Pushnotifications. My Service is NOT started in Foreground when a Message arrives! I don´t have any problem here.
Even after weeks a push-message will start the FirebaseMessaging service. But, again, it will not be started a a Foreground service. And i don´think that the Notification will eat much battery...........
Sure, if you start it as a foreground service there will be an Icon in the notificationbar.
The battery assumptiion does not come from the notification. More it is your service which consumes battery.
Hello,Hi, do you have a log of the actual error ?
Why would you have 20 different Services using FCM?Hello,
the error occurs due asynchronous requests thru internet... It's not possible to fix because it's not possible to preview every event. To illustrate, this program has about 45 activities, 20 services using FCM, SIP, 2 or 3 native libs calling 60 API methods communicating with a remote server. This means that some error will occur sometimes... I need to hide the error message and restart silently ... (of course that every recurrent error I will fix, but it's not possible to track and fix all the errors)
Hello @walterf25 ,Why would you have 20 different Services using FCM?
I think that's the problem, why not just use one, You can subscribe to different topics using only one Service.
Walter
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?