Merge "Fix NPE when run the testing in IntentPlayground" into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-04-24 02:34:41 +00:00
committed by Android (Google) Code Review
2 changed files with 11 additions and 2 deletions

View File

@@ -92,4 +92,5 @@
<string name="start_mode">Select start mode</string>
<string name="start_normal">Start activity</string>
<string name="start_for_result">Start activity for result</string>
<string name="launch_testing_activities_failed">Start Intent testing failed</string>
</resources>

View File

@@ -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() {