Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I define a dynamic intent-filter in my Android application? [duplicate]

I can define intent-filter(s) in AndroidManifest.xml; works great. Is there an API to register them dynamically? My application allows users to configure "accounts" to various servers; I'd like to start capturing actions going to those servers, but since they are dynamic I won't know them at compile time.

This is what I was asking: Android: Dynamically asscociating data type with an activity

like image 477
Valdis R Avatar asked May 11 '11 19:05

Valdis R


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.

Which components can you specify in an intent filter?

The intent filter specifies the types of intents that an activity, service, or broadcast receiver can respond. Intent filters are declared in the Android manifest file.

What is intent filter and how we can define it?

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.


1 Answers

This might be useful to you. I use this so my receiver can get a call when the screen off intent happens. this particular intent doesn't seem to work if you try to declare it in the manifest.

    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
    BroadcastReceiver mReceiver = new ScreenReceiver();
    registerReceiver(mReceiver, filter);
like image 200
FoamyGuy Avatar answered Sep 30 '22 03:09

FoamyGuy