Hi guys, how can I re-start the app automatically once the app is updated, when it finishes updating the app shuts down, so how can i re-launch the app automatically,
I've tried running another service named RestartActivity and check for the StartingIntent, but it doesn't seem to work for me.
I've added this code to the manifest file:
I can see the service starting but only after I re-install the app through my usb cable, this is the logs i see
But i would like the app to be restarted right away after updating the app.
Below is the code for the RestartActivity service
Any advise on this?
Regards,
Walter
I've tried running another service named RestartActivity and check for the StartingIntent, but it doesn't seem to work for me.
I've added this code to the manifest file:
B4X:
AddReceiverText(restartactivity, <intent-filter>
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>)
I can see the service starting but only after I re-install the app through my usb cable, this is the logs i see
** Service (restartactivity) Create **
** Service (restartactivity) Start **
intent: (Intent) Intent { act=android.intent.action.PACKAGE_REPLACED dat=package:ifims.observer flg=0x4000010 cmp=ifims.observer/.restartactivity$restartactivity_BR bqHint=4 (has extras) }
starting intent: package:ifims.observer
extras: Bundle[{android.intent.extra.UID=10214, android.intent.extra.REPLACING=true, android.intent.extra.user_handle=0}]
restarting main Activity...
Activity (main) Pause, UserClosed = false **
But i would like the app to be restarted right away after updating the app.
Below is the code for the RestartActivity service
B4X:
Sub Service_Start (StartingIntent As Intent)
Log("intent: " & StartingIntent)
Log("starting intent: " & StartingIntent.GetData)
Log("extras: " & StartingIntent.ExtrasToString)
If StartingIntent.Action = "android.intent.action.PACKAGE_REPLACED" And IsPaused(Main) Then
Log("restarting main Activity...")
MyAppReload
Else
StartServiceAt("", DateTime.Now + 5 * 1000, True)
End If
End Sub
Sub Service_Destroy
End Sub
Sub MyAppReload
If IsPaused(Main) Then
Log("restarting Main Activity...")
StartActivity(Main)
StopService("")
End If
End Sub
Any advise on this?
Regards,
Walter