My MainActivity
supports Android N's new multi-window mode. However, I would like my AwesomeActivity
to NOT support multi-window.
I have tried the following:
AndroidManifest.xml
<activity
android:name=".activities.MainActivity"
android:label="@string/app_name"
android:windowSoftInputMode="stateHidden"/>
<activity android:name=".activities.AwesomeActivity"
android:resizeableActivity="false" />
MainActivity.java
Intent intent = new Intent(this, AwesomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
//removing CLEAR_TOP and SINGLE_TOP has no effect either
//Intent.FLAG_ACTIVITY_CLEAR_TASK in conjunction with Intent.FLAG_ACTIVITY_NEW_TASK does not have an effect either
I thought that by adding the Intent.FLAG_ACTIVITY_NEW_TASK
(with or without Intent.FLAG_ACTIVITY_CLEAR_TASK
), this would mean that AwesomeActivity
would be the root activity in its own task stack and therefore, I should not be able to get to multi-window mode at AwesomeActivity
.
However, this does not work, I can still switch to multi-window mode from AwesomeActivity
, which is not the desired behavior.
Although the combination of Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK
seems to work to launch AwesomeActivity this doesn't work in the sense that if you put the app in the background while in AwesomeActivity, then bring the AwesomeActivity back to the foreground, you will be unable to go back to MainActivity as it was wiped from the task stack. I believe in most cases, the user would want to be able to return to MainActivity
so this solution is not sufficient.