开发者

Open button (after application re-install by code) does not launch app

开发者 https://www.devze.com 2023-04-05 11:54 出处:网络
I re-install my .apk programmatically by code while it is running and when re-install finishes Open button does not launch the 开发者_C百科app.It just closes Open Finish window.Then I have to go to me

I re-install my .apk programmatically by code while it is running and when re-install finishes Open button does not launch the 开发者_C百科app.It just closes Open Finish window.Then I have to go to menu and launch it clicking there.

Does anyone know anything about this issue?

I guess this would be because the application signature changes or sth like that?


Your activity name may have changed, and now home screen shortcut probably points to non-existing activity. Delete the old home-screen shortcut, and place there new one.


  1. Make sure you have code below for your main activity in your Manifest:

      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
    
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    
  2. Also make sure to close your app when you are reinstalling. You can use this:

    android.os.Process.killProcess(android.os.Process.myPid());

    or

    System.exit(0);

  3. Finally Add the code below to your onCreate() in your Main Activity :

    if (!isTaskRoot()) {

                finish();
                return;
            }
    

Hope it works :)

0

精彩评论

暂无评论...
验证码 换一张
取 消