Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all intent filters for application (with root)

I am working on a system application and I need to know programmatically what intents an application is capable of handling. I have seen other questions related to this, but none of them seem to have an answer but also do not seem to be concerned with system privileges.

PackageManager only seems to provide methods to query activities for a given intent. I can not find a way to get intents for a given activity.

For example, if I have an activity which has intent filters defined as such:

<intent-filter>
    <action android:name="android.intent.action.BOOT_COMPLETED"/>
    <action android:name="android.intent.action.USER_PRESENT"/>
</intent-filter>

And I know the activities class name and package name, I would like to find out from the package manager (or any other source) what intents it can handle (in this case, BOOT_COMPLETED and USER_PRESENT).

like image 211
Andrew T. Avatar asked Jan 30 '14 20:01

Andrew T.


People also ask

Can an activity have multiple intent filters?

However, since a component can have multiple intent filters, an intent that does not pass through one of a component's filters might make it through on another. An <intent-filter> element in the manifest file lists actions as <action> subelements. For example: <intent-filter . . . >

What is intent filters explain intent filters with example?

An intent filter is an expression in an app's manifest file that specifies the type of intents that the component would like to receive. For instance, by declaring an intent filter for an activity, you make it possible for other apps to directly start your activity with a certain kind of intent.

Which components can you specify in an intent filter?

Android components register intent filters either statically in the AndroidManifest. xml or in case of a broadcast receiver also dynamically via code. An intent filter is defined by its category, action and data filters. It can also contain additional meta-data.

How do you make an explicit intent?

To create an Explicit Intent, we need to define the component name for an Intent object. Following is the simple code snippet of explicit intent in the android application. Intent di = new Intent(this, ActivityView. class);


1 Answers

Good question. I don't think it's possible to find out the intents that an app can handle. Some standard activity actions and broadcast actions are listed at http://developer.android.com/reference/android/content/Intent.html. If you are writing your own app that's having it's own intent filters, then i don't think other apps will know what intents your app can handle because there is no way to publish them or announce them to the world, i believe.

But what is possible is that you can make a call for a particular intent and if that returns null, then you know for sure that there are no apps on the device that can handle that particular intent.

HTH.

like image 168
VJ Vélan Solutions Avatar answered Oct 05 '22 06:10

VJ Vélan Solutions