aboutsummaryrefslogtreecommitdiff
path: root/src/com/android/tv/LauncherActivity.java
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2018-08-06 16:51:26 -0700
committerXin Li <delphij@google.com>2018-08-06 16:51:26 -0700
commitaca265722281fe082995a71fd35401f766afac3e (patch)
tree28eac0d8752df3b094f50103a9ebb6d6340f4cc8 /src/com/android/tv/LauncherActivity.java
parent5fdc24aa6cc0acfd6a2d5939862e6edbe14f1ef6 (diff)
parentc56e1892201e0b31f3043e37a32d779b4055cb34 (diff)
downloadTV-oreo-mr1-1.2-iot-release.tar.gz
Bug: 112104996 Change-Id: Iec32f622f0bb1bc1583aefcbf6d115ad05baa693
Diffstat (limited to 'src/com/android/tv/LauncherActivity.java')
-rw-r--r--src/com/android/tv/LauncherActivity.java38
1 files changed, 9 insertions, 29 deletions
diff --git a/src/com/android/tv/LauncherActivity.java b/src/com/android/tv/LauncherActivity.java
index e03952da..679d612d 100644
--- a/src/com/android/tv/LauncherActivity.java
+++ b/src/com/android/tv/LauncherActivity.java
@@ -26,8 +26,8 @@ import android.util.Log;
/**
* An activity to launch a new activity.
*
- * <p>In the case when {@link MainActivity} starts a new activity using
- * {@link Activity#startActivity} or {@link Activity#startActivityForResult}, Live TV app is
+ * <p>In the case when {@link MainActivity} starts a new activity using {@link
+ * Activity#startActivity} or {@link Activity#startActivityForResult}, Live TV app is
* terminated if the new activity crashes. That's because the {@link android.app.ActivityManager}
* terminates the activity which is just below the crashed activity in the activity stack. To avoid
* this, we need to locate an additional activity between these activities in the activity stack.
@@ -35,8 +35,7 @@ import android.util.Log;
public class LauncherActivity extends Activity {
private static final String TAG = "LauncherActivity";
- public static final String ERROR_MESSAGE
- = "com.android.tv.LauncherActivity.ErrorMessage";
+ public static final String ERROR_MESSAGE = "com.android.tv.LauncherActivity.ErrorMessage";
private static final int REQUEST_CODE_DEFAULT = 0;
private static final int REQUEST_START_ACTIVITY = 100;
@@ -45,34 +44,16 @@ public class LauncherActivity extends Activity {
private static final String EXTRA_REQUEST_RESULT =
"com.android.tv.LauncherActivity.REQUEST_RESULT";
- /**
- * Starts an activity by calling {@link Activity#startActivity}.
- */
+ /** Starts an activity by calling {@link Activity#startActivity}. */
public static void startActivitySafe(Activity baseActivity, Intent intentToLaunch) {
// To avoid the app termination when the new activity crashes, LauncherActivity should be
// started by calling startActivityForResult().
- baseActivity.startActivityForResult(createIntent(baseActivity, intentToLaunch, false),
- REQUEST_CODE_DEFAULT);
+ baseActivity.startActivityForResult(
+ createIntent(baseActivity, intentToLaunch, false), REQUEST_CODE_DEFAULT);
}
- /**
- * Starts an activity by calling {@link Activity#startActivityForResult}.
- *
- * <p>Note: {@code requestCode} should not be 0. The value is reserved for internal use.
- */
- public static void startActivityForResultSafe(Activity baseActivity, Intent intentToLaunch,
- int requestCode) {
- if (requestCode == REQUEST_CODE_DEFAULT) {
- throw new IllegalArgumentException("requestCode should not be 0.");
- }
- // To avoid the app termination when the new activity crashes, LauncherActivity should be
- // started by calling startActivityForResult().
- baseActivity.startActivityForResult(createIntent(baseActivity, intentToLaunch, true),
- requestCode);
- }
-
- private static Intent createIntent(Context context, Intent intentToLaunch,
- boolean requestResult) {
+ private static Intent createIntent(
+ Context context, Intent intentToLaunch, boolean requestResult) {
Intent intent = new Intent(context, LauncherActivity.class);
intent.putExtra(EXTRA_INTENT, intentToLaunch);
if (requestResult) {
@@ -98,8 +79,7 @@ public class LauncherActivity extends Activity {
}
} catch (ActivityNotFoundException e) {
Log.w(TAG, "Activity not found for " + intent);
- intent.putExtra(ERROR_MESSAGE,
- getResources().getString(R.string.msg_missing_app));
+ intent.putExtra(ERROR_MESSAGE, getResources().getString(R.string.msg_missing_app));
setResult(Activity.RESULT_CANCELED, intent);
finish();
}