-2

After exiting from my app if i open it again random activities open instead of Launcher Activity. The problem continues even after putting in manifest. I have set the category as DEFAULT as shown in the code below. In the main activity i have put the code (given below) to exit the app on back press.

 //Android Manifest -- i have set all activities as DEFAULT except LAUNCHER activity.
<intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.DEFAULT" />
 </intent-filter>



@Override// In Main Activity I have put this code to exit app when back is pressed
public void onBackPressed() {

                    Intent intent = new Intent(Intent.ACTION_MAIN);
                    intent.addCategory(Intent.CATEGORY_HOME);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                    finish();
    }
admin 7798
  • 697
  • 1
  • 7
  • 15

1 Answers1

2

Have you tried setting the category to LAUNCHER like this

`<intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />

`