Fixes issue #2

by removing singleinstance from MainActivity in the manifest and handling the launch in AppShortcutLauncherActivity
This commit is contained in:
Adrian Campos 2017-03-22 14:25:51 -07:00 committed by Karim Abou Zeid
commit d17f0407dd
2 changed files with 6 additions and 3 deletions

View file

@ -20,8 +20,7 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Phonograph.Light" android:theme="@style/Theme.Phonograph.Light"
tools:ignore="UnusedAttribute"> tools:ignore="UnusedAttribute">
<activity android:name=".ui.activities.MainActivity" <activity android:name=".ui.activities.MainActivity">
android:launchMode="singleInstance">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.MUSIC_PLAYER" /> <action android:name="android.intent.action.MUSIC_PLAYER" />
@ -176,7 +175,8 @@
android:label="@string/report_an_issue" /> android:label="@string/report_an_issue" />
<activity <activity
android:name=".appshortcuts.AppShortcutLauncherActivity" android:name=".appshortcuts.AppShortcutLauncherActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"/> android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:launchMode="singleInstance"/>
</application> </application>
</manifest> </manifest>

View file

@ -84,6 +84,9 @@ public class AppShortcutLauncherActivity extends Activity {
//Put the bundle in the intent //Put the bundle in the intent
intent.putExtras(bundle); intent.putExtras(bundle);
//If MainActivity's already running, don't launch another instance. Instead, bring it to the top and deliver the intent to onNewIntent()
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
//Finally, start MainActivity with those extras //Finally, start MainActivity with those extras
startActivity(intent); startActivity(intent);
} }