Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After Installation of apk "Open" and "Done" button shows, onclick of Open button it's not adding categor as launcher

Android issue: This issue is coming only 1st time after installation and clicking on open button, after launching application with launcher icon then issue will never come.

  • Steps to reproduce the problem.

    1. Install Any .apk file
    2. After installation you will get two buttons "Open" and "Done".
    3. Onclick of Open button it's opening/starting application.
    4. now Navigate in you application and go to any other screen, like on 2nd screen, 3rd screen.
    5. Now, Press Home and put application in background (means put in pause sate).
    6. Now go to list of application Click on Launcher Icon of same application.
  • What happened.

    1. It is Launching Same application from start point at first screen.
    2. It must resume the running application on 3rd screen.
    3. Now press back and come out from 1st screen of 2nd time started application.
    4. It is showing 1st time run application's 3rd screen.

I have explain you general behavior after installation and start app with open button. In my application it create inconsistent state of 2 times started application.

  • What you think the correct behavior should be.

    1. Application must resume.
    2. application must not come in inconsistent state.

I have some logs..

  • Clicking on "Open" button logs :

10-04 21:45:28.703: INFO/ActivityManager(243): Starting activity: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.test/.TestnewversionActivity } from pid 15146.

"See no category added in intent above"

  • Clicking on "Launcher" Icon’s logs :

10-04 21:46:46.109: INFO/ActivityManager(243): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.test/.TestnewversionActivity } from pid 428

"See category added in intent above".

If some one tell me how to Resolve this or tell how to add category as android.intent.category.LAUNCHER on "Open" button click then problem will resolve.

I have tried to add category in intent on app start, oncreate and many places. intent.addCategory("android.intent.category.LAUNCHER"); Also tried to work with IntentFilter, PackageManager.

This issue is in every Android phone.

I have taken Logs on HTC-SENSE Android version 2.3.3

like image 719
user1722363 Avatar asked Oct 05 '12 08:10

user1722363


1 Answers

please add code to onCreate

if (isTaskRoot()) {
    final Intent intent = getIntent();
    final String intentAction = intent.getAction();
    if (!intent.hasCategory(Intent.CATEGORY_LAUNCHER) &&
            intentAction != null && intentAction.equals(Intent.ACTION_MAIN)) {
        finish();
        System.exit(0);
    }
}
like image 54
user1925808 Avatar answered Oct 13 '22 03:10

user1925808