Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(841)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/util/IntentUtils.java

Issue 988963004: Add IntentUtils to share common intent-related code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/util/IntentUtils.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/util/IntentUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/util/IntentUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..3785f8b5db4df603915f845876e564e5af388041
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/util/IntentUtils.java
@@ -0,0 +1,34 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.util;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ResolveInfo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Utilities dealing with extracting information from intents.
+ */
+public class IntentUtils {
+
+ /**
+ * Retrieves a list of components that would handle the given intent.
+ * @param context The application context.
+ * @param intent The intent which we are interested in.
+ * @return The list of component names.
+ */
+ public static List<ComponentName> getIntentHandlers(Context context, Intent intent) {
+ List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent, 0);
+ List<ComponentName> nameList = new ArrayList<ComponentName>();
+ for (ResolveInfo r : list) {
+ nameList.add(new ComponentName(r.activityInfo.packageName, r.activityInfo.name));
+ }
+ return nameList;
+ }
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698