Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding static intent-filter definitions after installation

I have a feeling this just isn't possible, but thought I'd get some confirmation...

I'd like to have an app which reacts to certain HTTP URLs, and I know I can pre-define a few entries in the manifest something like this:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="http" android:host="example.com" />
</intent-filter>

However, I would like the user to add (or potentially remove) hosts, e.g. add "http://example.net" or deactivate the pre-defined "http://example.com/" entry.

Of course, I can capture such Intents by registering a dynamic broadcast receiver in a foreground Activity.

But is it possible to register new intent filters with the system after installation, so that my app doesn't need to be in the foreground to capture intents which match the newly-added hostnames?

like image 715
Christopher Orr Avatar asked Nov 14 '22 10:11

Christopher Orr


1 Answers

Good question.

Not sure if it's possible but I would:

a) Test what happens when you register the receiver with the registerReceiver() method inside Context. Perhaps it gets persisted somehow.

b) Set the dynamic broadcast receiver inside a never ending Service. (Yep, it's ugly, I know)

like image 160
Macarse Avatar answered Nov 16 '22 03:11

Macarse