Merge "Catch exception to prevent crash." into tm-qpr-dev am: a7fafd6976

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/20544536

Change-Id: I56c0ee67cd286dea30b2ecac4bda93486145231f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-11-29 23:04:05 +00:00
committed by Automerger Merge Worker

View File

@@ -28,6 +28,7 @@ import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_SU
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
@@ -315,10 +316,16 @@ public class ItemClickHandler {
*/
public static void onClickSearchAction(Launcher launcher, SearchActionItemInfo itemInfo) {
if (itemInfo.getIntent() != null) {
if (itemInfo.hasFlags(SearchActionItemInfo.FLAG_SHOULD_START_FOR_RESULT)) {
launcher.startActivityForResult(itemInfo.getIntent(), 0);
} else {
launcher.startActivity(itemInfo.getIntent());
try {
if (itemInfo.hasFlags(SearchActionItemInfo.FLAG_SHOULD_START_FOR_RESULT)) {
launcher.startActivityForResult(itemInfo.getIntent(), 0);
} else {
launcher.startActivity(itemInfo.getIntent());
}
} catch (ActivityNotFoundException e) {
Toast.makeText(launcher,
launcher.getResources().getText(R.string.shortcut_not_available),
Toast.LENGTH_SHORT).show();
}
} else if (itemInfo.getPendingIntent() != null) {
try {