Don't crash when trying to launch missing application
This is a cherry-pick of https://android-git.corp.google.com/g/28056
into donut-gms.
Fixes http://b/issue?id=2155988
"Clicking a shortcut for an uninstalled application in Quick Search Box crashes acore, requires reboot"
Change-Id: I4b1f19c15857b5905d98cb4da20c78dc4cfd6c2d
diff --git a/src/com/android/providers/applications/ApplicationLauncher.java b/src/com/android/providers/applications/ApplicationLauncher.java
index 8463fb6..830597f 100644
--- a/src/com/android/providers/applications/ApplicationLauncher.java
+++ b/src/com/android/providers/applications/ApplicationLauncher.java
@@ -17,6 +17,7 @@
package com.android.providers.applications;
import android.app.Activity;
+import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Intent;
import android.net.Uri;
@@ -45,7 +46,11 @@
launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
launchIntent.setComponent(componentName);
- startActivity(launchIntent);
+ try {
+ startActivity(launchIntent);
+ } catch (ActivityNotFoundException ex) {
+ Log.w(TAG, "Activity not found: " + componentName);
+ }
handled = true;
}
}