aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorherriojr <jherriott@cyngn.com>2015-09-29 13:38:20 -0700
committerherriojr <jherriott@cyngn.com>2015-09-30 12:06:01 -0700
commitd28d1480987de805421689831593619e653e659e (patch)
tree640b66cd1eb662c6f50c1f535601b84a705236ca
parent085427a361a042c88d29a41bb59e718ab98b057d (diff)
downloadandroid_packages_apps_CMFileManager-d28d1480987de805421689831593619e653e659e.tar.gz
android_packages_apps_CMFileManager-d28d1480987de805421689831593619e653e659e.tar.bz2
android_packages_apps_CMFileManager-d28d1480987de805421689831593619e653e659e.zip
Check If System Wants Intent
After much thought about this last night, I came to the conclusion that because applications can in fact do this, we need to be able to support it in a backwards compatible fashion. In doing so, there are a few cases which won't work with suggestions, however, the changes here are less severe than what they were before. Now just an extra check happens to see if the system wants to handle the intent if nothing was found to handle it. What this means is any application acting as its own resolver will not automatically have the system handle it in this case and we no longer can support suggestion outlined here: http://developer.android.com/training/basics/intents/sending.html#StartActivity The suggestion is wrong anyways as an activity isn't guaranteed to continue to exist after the query when the start is called. Maybe I'll try and push a documentation change upstream to AOSP for this. Change-Id: I8510660420ee52c09d03c719850fa14d6b1c4441 Issue-Id: CYNGNOS-1152
-rwxr-xr-xsrc/com/cyanogenmod/filemanager/ui/policy/IntentsActionPolicy.java35
1 files changed, 30 insertions, 5 deletions
diff --git a/src/com/cyanogenmod/filemanager/ui/policy/IntentsActionPolicy.java b/src/com/cyanogenmod/filemanager/ui/policy/IntentsActionPolicy.java
index 043a3621..64fb4086 100755
--- a/src/com/cyanogenmod/filemanager/ui/policy/IntentsActionPolicy.java
+++ b/src/com/cyanogenmod/filemanager/ui/policy/IntentsActionPolicy.java
@@ -16,6 +16,7 @@
package com.cyanogenmod.filemanager.ui.policy;
+import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface.OnCancelListener;
@@ -336,6 +337,22 @@ public final class IntentsActionPolicy extends ActionsPolicy {
}
});
+ if (info.size() == 0) {
+ // This basically checks the system to see if it possibly wants to handle it
+ ResolveInfo ri = packageManager.resolveActivity(intent, 0);
+ if (ri != null) {
+ try {
+ ctx.startActivity(getIntentFromResolveInfo(ri, intent));
+ if (onDismissListener != null) {
+ onDismissListener.onDismiss(null);
+ }
+ return;
+ } catch (ActivityNotFoundException e) {
+ // fall through, we may still want to handle it with an internal activity
+ }
+ }
+ }
+
// Add the internal editors
int count = 0;
if (internals != null) {
@@ -406,16 +423,24 @@ public final class IntentsActionPolicy extends ActionsPolicy {
//---
// If we have a preferred application, then use it
if (!choose && (mPreferredInfo != null && mPreferredInfo.match != 0)) {
- ctx.startActivity(getIntentFromResolveInfo(mPreferredInfo, intent));
- if (onDismissListener != null) {
- onDismissListener.onDismiss(null);
+ try {
+ ctx.startActivity(getIntentFromResolveInfo(mPreferredInfo, intent));
+ if (onDismissListener != null) {
+ onDismissListener.onDismiss(null);
+ }
+ return;
+ } catch (ActivityNotFoundException e) {
+ // fall through, the preferred may have been uninstalled.
}
- return;
}
// If there are only one activity (app or internal editor), then use it
if (!choose && info.size() == 1) {
ResolveInfo ri = info.get(0);
- ctx.startActivity(getIntentFromResolveInfo(ri, intent));
+ try {
+ ctx.startActivity(getIntentFromResolveInfo(ri, intent));
+ } catch (ActivityNotFoundException e) {
+ DialogHelper.showToast(ctx, R.string.msgs_not_registered_app, Toast.LENGTH_SHORT);
+ }
if (onDismissListener != null) {
onDismissListener.onDismiss(null);
}