Skip to content

Commit 67f0035

Browse files
(example app) handle reopening the foregrounded activity with a new intent
1 parent 7dd065d commit 67f0035

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

AdobeBranchExample/src/main/java/io/branch/adobe/demo/ProductActivity.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import android.content.Intent;
44
import android.os.Bundle;
5-
import android.os.Handler;
5+
import android.text.TextUtils;
66
import android.view.View;
77
import android.widget.AdapterView;
88
import android.widget.ListAdapter;
@@ -57,13 +57,14 @@ public void onClick(View view) {
5757
@Override
5858
protected void onStart() {
5959
super.onStart();
60-
initBranchSession();
60+
AdobeBranch.initSession(branchInitSessionCallback, getIntent().getData(), this);
6161
}
6262

6363
@Override
6464
public void onNewIntent(Intent intent) {
6565
super.onNewIntent(intent);
6666
this.setIntent(intent);
67+
AdobeBranch.initSession(branchInitSessionCallback, getIntent().getData(), this, 0);
6768
}
6869

6970
private void initList() {
@@ -88,16 +89,16 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
8889
}
8990
}
9091

91-
private void initBranchSession() {
92-
AdobeBranch.initSession(new Branch.BranchReferralInitListener() {
92+
private Branch.BranchReferralInitListener branchInitSessionCallback = new Branch.BranchReferralInitListener() {
9393
@Override
9494
public void onInitFinished(JSONObject referringParams, BranchError error) {
95+
PrefHelper.Debug("initBranchSession, referringParams = " + referringParams + ", error = " + error);
9596
if (referringParams == null) return;
9697
try {
9798
// You would think that there was an easier way to figure this out than looking at LinkProperties code
9899
if (referringParams.has("+clicked_branch_link") && referringParams.getBoolean("+clicked_branch_link")) {
99100
String idString = referringParams.optString(SwagActivity.SWAG_ID);
100-
if (idString != null) {
101+
if (!TextUtils.isEmpty(idString)) {
101102
int swagId = Integer.parseInt(idString);
102103

103104
// Launch the Swag Activity
@@ -111,8 +112,8 @@ public void onInitFinished(JSONObject referringParams, BranchError error) {
111112
// internal error; id is not a number.
112113
}
113114
}
114-
}, getIntent().getData(), this);
115-
}
115+
};
116+
116117

117118
private void shareProduct() {
118119
BranchUniversalObject buo = new BranchUniversalObject();

0 commit comments

Comments
 (0)