diff --git a/samples/IntentPlayground/res/values/strings.xml b/samples/IntentPlayground/res/values/strings.xml index a6bdcc4cf..4a3683c4a 100644 --- a/samples/IntentPlayground/res/values/strings.xml +++ b/samples/IntentPlayground/res/values/strings.xml @@ -92,4 +92,5 @@ Select start mode Start activity Start activity for result + Start Intent testing failed diff --git a/samples/IntentPlayground/src/com/example/android/intentplayground/BaseActivity.java b/samples/IntentPlayground/src/com/example/android/intentplayground/BaseActivity.java index 02cad285d..227f517b5 100644 --- a/samples/IntentPlayground/src/com/example/android/intentplayground/BaseActivity.java +++ b/samples/IntentPlayground/src/com/example/android/intentplayground/BaseActivity.java @@ -27,6 +27,8 @@ import android.util.Log; import android.view.Menu; import android.view.MenuItem; +import android.widget.Toast; + import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; @@ -238,8 +240,14 @@ public abstract class BaseActivity extends AppCompatActivity implements } protected void runIntentTests() { - startActivity(getPackageManager() - .getLaunchIntentForPackage("com.example.android.intentplayground.test")); + final Intent intent = getPackageManager() + .getLaunchIntentForPackage("com.example.android.intentplayground.test"); + if (intent != null) { + startActivity(intent); + } else { + Toast.makeText(this, + R.string.launch_testing_activities_failed, Toast.LENGTH_LONG).show(); + } } protected Intent prepareLaunchForward() {