javaandroidapplication-restart

Can we program the app to restart on its own?


My app doesn't function as intended after fresh installation on the device. The user has to manually close the app and start it again for proper functionality. A quick fix is needed, something as simple as the app restarting on its own after first launch (this only has to happen 1 time).

05/22 19:44:57: Launching app
$ adb install-multiple -r -t C:\Users\Gregory\AndroidStudioProjects\GAaudioTransform\app\build\intermediates\split-apk\debug\slices\slice_6.apk C:\Users\Gregory\AndroidStudioProjects\GAaudioTransform\app\build\intermediates\split-apk\debug\slices\slice_4.apk C:\Users\Gregory\AndroidStudioProjects\GAaudioTransform\app\build\intermediates\split-apk\debug\dep\dependencies.apk C:\Users\Gregory\AndroidStudioProjects\GAaudioTransform\app\build\intermediates\resources\instant-run\debug\resources-debug.apk C:\Users\Gregory\AndroidStudioProjects\GAaudioTransform\app\build\intermediates\split-apk\debug\slices\slice_9.apk C:\Users\Gregory\AndroidStudioProjects\GAaudioTransform\app\build\intermediates\split-apk\debug\slices\slice_8.apk C:\Users\Gregory\AndroidStudioProjects\GAaudioTransform\app\build\intermediates\split-apk\debug\slices\slice_2.apk C:\Users\Gregory\AndroidStudioProjects\GAaudioTransform\app\build\intermediates\split-apk\debug\slices\slice_3.apk C:\Users\Gregory\AndroidStudioProjects\GAaudioTransform\app\build\intermediates\split-apk\debug\slices\slice_5.apk C:\Users\Gregory\AndroidStudioProjects\GAaudioTransform\app\build\intermediates\split-apk\debug\slices\slice_1.apk C:\Users\Gregory\AndroidStudioProjects\GAaudioTransform\app\build\intermediates\split-apk\debug\slices\slice_7.apk C:\Users\Gregory\AndroidStudioProjects\GAaudioTransform\app\build\intermediates\split-apk\debug\slices\slice_0.apk C:\Users\Gregory\AndroidStudioProjects\GAaudioTransform\app\build\intermediates\instant-run-apk\debug\app-debug.apk 
Split APKs installed in 5 s 337 ms
$ adb shell am start -n "tk.gandriks.gaaudiotransform/tk.gandriks.gaaudiotransform.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Client not ready yet..Waiting for process to come online
Connected to process 11440 on device samsung-sm_g930f-ce05160561e0761105
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
E/Zygote: isWhitelistProcess - Process is Whitelisted
E/libpersona: scanKnoxPersonas
Couldn't open the File - /data/system/users/0/personalist.xml - No such file or directory
W/SELinux: SELinux selinux_android_compute_policy_index : Policy Index[2],  Con:u:r:zygote:s0 RAM:SEPF_SM-G930F_8.0.0_0018, [-1 -1 -1 -1 0 1]
I/SELinux: SELinux: seapp_context_lookup: seinfo=untrusted, level=s0:c512,c768, pkgname=tk.gandriks.gaaudiotransform 
I/zygote64: Late-enabling -Xcheck:jni
D/TimaKeyStoreProvider: TimaKeyStore is not enabled: cannot add TimaSignature Service and generateKeyPair Service
D/ActivityThread: Added TimaKeyStore provider
I/zygote64: no shared libraies, dex_files: 1
I/InstantRun: starting instant run server: is main process
D/OpenGLRenderer: HWUI GL Pipeline
D/ViewRootImpl@d597feb[MainActivity]: setView = DecorView@ed74148[MainActivity] TM=true MM=false
D/ViewRootImpl@d597feb[MainActivity]: dispatchAttachedToWindow
V/Surface: sf_framedrop debug : 0x4f4c, game : false, logging : 0
D/ViewRootImpl@d597feb[MainActivity]: Relayout returned: old=[0,0][0,0] new=[0,0][1440,2560] result=0x7 surface={valid=true 484328804352} changed=true
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 2
D/libGLESv1: STS_GLApi : DTS, ODTC are not allowed for Package : tk.gandriks.gaaudiotransform
D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000,  [1440x2560]-format:1
D/OpenGLRenderer: eglCreateWindowSurface = 0x70c9e2df00
D/ViewRootImpl@d597feb[MainActivity]: MSG_RESIZED_REPORT: frame=Rect(0, 0 - 1440, 2560) ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1
D/ViewRootImpl@d597feb[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1
V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@56c3619 nm : tk.gandriks.gaaudiotransform ic=null
I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@7e4d6de nm : tk.gandriks.gaaudiotransform ic=null
D/ViewRootImpl@c82cf8d[Toast]: setView = android.widget.LinearLayout{2fd8542 V.E...... ......I. 0,0-0,0} TM=true MM=false
V/Toast: Text: Qerm in android.widget.Toast$TN@7980953
D/ViewRootImpl@c82cf8d[Toast]: dispatchAttachedToWindow
V/Surface: sf_framedrop debug : 0x4f4c, game : false, logging : 0
D/ViewRootImpl@c82cf8d[Toast]: Relayout returned: old=[0,0][0,0] new=[373,2128][1066,2304] result=0x7 surface={valid=true 484137521152} changed=true
D/ViewRootImpl@c82cf8d[Toast]: MSG_RESIZED_REPORT: frame=Rect(373, 2128 - 1066, 2304) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
D/ViewRootImpl@c82cf8d[Toast]: dispatchDetachedFromWindow
D/InputEventReceiver: channel 'd449b05 Toast (client)' ~ Disposing input event receiver.
channel 'd449b05 Toast (client)' ~NativeInputEventReceiver.
V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@7c57290 nm : tk.gandriks.gaaudiotransform ic=null
I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
D/OpenGLRenderer: eglDestroySurface = 0x70c9e2df00
D/ViewRootImpl@d597feb[MainActivity]: Relayout returned: old=[0,0][1440,2560] new=[0,0][1440,2560] result=0x5 surface={valid=false 0} changed=true
D/ViewRootImpl@d597feb[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0

The error in this log is the line:

E/Zygote: isWhitelistProcess - Process is Whitelisted
E/libpersona: scanKnoxPersonas
Couldn't open the File - /data/system/users/0/personalist.xml - No such file or directory

Solution

  • Even though there might be some answers to this question, from my(and probably most of the users) point of view this would be a terrible experience. Fix the original problem, any workaround that you do that results in app restarting itself will probably end in user uninstalling your app. Keep your app stable and users happy!