Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add or remove intent filter programmatically in android?

Is it possible to remove intent filters from activity based on user preference? Say dial intent filter is added and then at later point of time user decides the application should not handle dial.

Edit: Removed add part in question description

like image 957
dhaval Avatar asked Feb 01 '11 12:02

dhaval


People also ask

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.

What is intent filter in XML?

description: Specifies the types of intents that an activity, service, or broadcast receiver can respond to. An intent filter declares the capabilities of its parent component — what an activity or service can do and what types of broadcasts a receiver can handle.

What is the difference between intent and intent filters?

An intent is an object that can hold the os or other app activity and its data in uri form.It is started using startActivity(intent-obj).. \n whereas IntentFilter can fetch activity information on os or other app activities.

Which component can you specify in an intent filter?

The intent filter specifies the types of intents that an activity, service, or broadcast receiver can respond.


2 Answers

No, it seems they are static.

An intent filter is an instance of the IntentFilter class. However, since the Android system must know about the capabilities of a component before it can launch that component, intent filters are generally not set up in Java code, but in the application's manifest file (AndroidManifest.xml) as elements.

Source: http://developer.android.com/guide/topics/intents/intents-filters.html#ifs

like image 163
Will Tate Avatar answered Sep 28 '22 20:09

Will Tate


I thought maybe you could enable/disable via the Package manager, but despite have a GET_INTENT_FILTERS flag in the PackageManager, it seems it's not supported.

The defect has been raised here, and discussion here.

like image 36
scottyab Avatar answered Sep 28 '22 19:09

scottyab