10:56 AM
0

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.

RESOLVE
Add this code into oncreate() method
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();
            }
        }
More informations: http://stackoverflow.com/questions/16283079/re-launch-of-activity-on-home-button-but-only-the-first-time/16447508#16447508

0 comments:

Post a Comment