onCreate() called while Activity is stopped (but not destroyed). Only after installation

后端 未结 4 1181
醉话见心
醉话见心 2021-01-01 04:22

I\'m working on an app that targets Api 19, and that is basically a Processing sketch.

The problem I\'m facing is that the first time my app is run, right after inst

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-01 05:12

    Ok, this is how I solved it, in case anyone else bumps into this wall.

    This might affect especially people coming from the Processing Developing Environment, as it converts a "Processing sketch" into the only activity of the project.

    The original problem (Android managing apps in a different -wrong?- way when launching them from the Package Installer) is well explained here: https://code.google.com/p/android/issues/detail?id=26658

    Solutions posted there might solve most cases,but if -like me- your launcher activity is the one that carries out all the work, you will need to create a specific launcher activity that just starts the main one... and commits suicide when the Android bug happens.

    Add this bit to the onCreate() method of the launcher activity:

    if (!isTaskRoot()) {
     finish();
     return;
    } 
    

    I hope this helps.

提交回复
热议问题