-4

Consider 3 activities:
(A) Login Activity (main launcher)
(B) Main Activity
(C) Specific Activity

After users logged in (A) they will access (B), and from, and ONLY from (B), they can access (C).

Now everytime the app is opened, it will first launch (A) and then (B).

I want to make a push notification where when clicked, it can access (C) but must start (B) first.

I am using Xamarin.Android + Appcenter Push Notification

I can get notifications both when my app is in foreground and background.

My problem is when my app is in the background, clicking at the received notifications in the status bar causes it to relaunch the app, starting from (A).

I need help with skipping (A) since user is already logged in, opens (B) and THEN opens (C)

Any ideas? Hoping this is not too confusing for you guys.

I have also tried setting launchMode=singleInstance to (A) and (B) but it still relaunch the app

ShuFaz
  • 39
  • 1
  • 8

2 Answers2

1

You cannot change the launcher activity dynamically, but there are a few workarounds you can try:

Create a transparent activity and make it as the Launcher activity:

<activity
android:name=".ActivityLauncher"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" >
<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

And select the next activity in it's onCreate()

if ( logged() ) {
   intent = new Intent(this,ActivityB.class);
} else {
   intent = new Intent(this,ActivityA.class);
}
startActivity(intent);
finish();
Ayush Khare
  • 1,802
  • 1
  • 15
  • 26
  • 1
    Xamarin have little different syntax for few things & for initializing `Intent` as well. It would be better to mention note in your answer so that OP wont get confused. – R15 Nov 01 '18 at 05:57
  • Thanks for the answer. I'll give it a try – ShuFaz Nov 01 '18 at 11:20
-1

You can achieve this send a activity name or some value to select your activity. Depending on the value that u are sending you can launch the activity and also add the activity in backstack whenever u go back fron notified activity the page in backstack will appear.

I do always like this, hope this will work for you.

K K
  • 952
  • 9
  • 25