2

I have got a small problem in an Android app I am working on. My app has such logic:

MainActivity(Root) -> OneActivity -> TwoActivity -> MainActivity ->  ThreeActivity

When I press Back button I need move to TwoActivity

It is important that TwoActivity create DeepLink URL and MainActivity generate Intent of ThreeActivity. My MainActivity has android:launchMode="singleTop" and I cant finish() it. Min API is 16.

Can I solve it with Back Stack and Task?

UPDATE:

In my TwoActivity:

Intent intent = new Intent();
intent.setData(new Uri.Builder()
.scheme(SCHEMA)
.appendEncodedPath(packageName)
.appendEncodedPath(PATH_APP)
.appendEncodedPath(packageName)
.appendEncodedPath(deeplink)
.build());
startActivity(intent);

In my AndroidManifest.xml:

<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.VIEW" />

<data
    android:host="${applicationId}"
    android:scheme="android-app" />
</intent-filter>

So intent in TwoActivity != intent MainMenu.

Jack
  • 77
  • 1
  • 7
  • this link may help you. https://stackoverflow.com/questions/23826483/go-back-to-specific-activity-from-stack – androholic Apr 02 '18 at 20:40

1 Answers1

0

well, when you start an activity it will be added on the backstack by default, and by extension when you call onBackPressed afterwards it remove the last activity from that backstack.

So if you want to start an activity without adding it to the backstack you do it like this:

startActivity(new Intent(this, TargetActivity.class).setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY));
Alaa AbuZarifa
  • 1,171
  • 20
  • 39
  • thank you for answer, but after process DeepLink Android generate Intent for MainActivity - no Flags, no Extras – Jack Apr 03 '18 at 07:29