Skip to content

Commit

Permalink
Merge pull request #157 from apptentive/branch_5.1.2
Browse files Browse the repository at this point in the history
Release 5.1.2
  • Loading branch information
weeeBox authored May 22, 2018
2 parents 119329f + eb4e37f commit ee182af
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 2018-05-22 - v5.1.2

#### Bugs Fixed

* Properly handle different app support library versions.

# 2018-05-09 - v5.1.1

#### Bugs Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use your app, to talk to them at the right time, and in the right way.

##### [Release Notes](https://learn.apptentive.com/knowledge-base/android-sdk-release-notes/)

##### Binary releases are hosted for Maven [here](http://search.maven.org/#artifactdetails|com.apptentive|apptentive-android|5.1.1|aar)
##### Binary releases are hosted for Maven [here](http://search.maven.org/#artifactdetails|com.apptentive|apptentive-android|5.1.2|aar)

#### Reporting Bugs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.IntentCompat;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar;
Expand Down Expand Up @@ -358,22 +359,28 @@ private void addFragmentToAdapter(ApptentiveBaseFragment f, String title) {
* activity, instead of desktop.
* */
private void startLauncherActivityIfRoot() {
if (isTaskRoot()) {
PackageManager packageManager = getPackageManager();
Intent intent = packageManager.getLaunchIntentForPackage(getPackageName());
try {
if (isTaskRoot()) {
PackageManager packageManager = getPackageManager();
Intent intent = packageManager.getLaunchIntentForPackage(getPackageName());
/*
Make this work with Instant Apps. It is possible and even likely to create an Instant App
that doesn't have the Main Activity included in its APK. In such cases, this Intent is null,
and we can't do anything apart from exiting our Activity.
*/
if (intent != null) {
ComponentName componentName = intent.getComponent();
/** Backwards compatible method that will clear all activities in the stack. */
Intent mainIntent = Intent.makeRestartActivityTask(componentName);
startActivity(mainIntent);
} else {
ApptentiveLog.w("Unable to start app's main activity: launch intent is missing");
if (intent != null) {
ComponentName componentName = intent.getComponent();
/* Backwards compatible method that will clear all activities in the stack. */
Intent mainIntent = Util.makeRestartActivityTask(componentName);
if (mainIntent != null) {
startActivity(mainIntent);
}
} else {
ApptentiveLog.w("Unable to start app's main activity: launch intent is missing");
}
}
} catch (Exception e) {
ApptentiveLog.e(e, "Exception while starting app's main activity");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public class Constants {

public static final int API_VERSION = 9;
private static final String APPTENTIVE_SDK_VERSION = "5.1.1";
private static final String APPTENTIVE_SDK_VERSION = "5.1.2";

public static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = 45000;
public static final int DEFAULT_READ_TIMEOUT_MILLIS = 45000;
Expand Down
21 changes: 21 additions & 0 deletions apptentive/src/main/java/com/apptentive/android/sdk/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.IntentCompat;
import android.text.TextUtils;
import android.util.Patterns;
import android.util.TypedValue;
Expand Down Expand Up @@ -1192,4 +1193,24 @@ public static String currentDateAsFilename(String prefix, String suffix) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd_hh-mm-ss", Locale.US);
return prefix + df.format(new Date()) + suffix;
}

public static @Nullable Intent makeRestartActivityTask(ComponentName cn) {
try {
return makeRestartActivityTaskGuarded(cn);
}
catch (Exception e) {
ApptentiveLog.e(e, "Exception in makeRestartActivityTask");
}

return null;
}

private static Intent makeRestartActivityTaskGuarded(ComponentName cn) {
try {
return Intent.makeRestartActivityTask(cn);
} catch (NoSuchMethodError e) {
//noinspection deprecation
return IntentCompat.makeRestartActivityTask(cn);
}
}
}

0 comments on commit ee182af

Please sign in to comment.