• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

How to add browsable intent-filters to a dynamic Broadcast Receiver?

Hello,

I'm actually searching for a way to add dynamically some browsable intent-filters to an activity using a Broadcast Receiver, I've made this in my activity :

Code:
private BroadcastReceiver receiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.e("Message", "uri "+ intent.getData().getPath());
    }
};
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    intentF = new IntentFilter();
    intentF.addAction("android.intent.action.VIEW");
    intentF.addCategory("android.intent.category.DEFAULT");
    intentF.addCategory("android.intent.category.BROWSABLE");
    intentF.addDataScheme("http");
    intentF.addDataScheme("https");
    intentF.addDataAuthority("*.google.fr", null);
    registerReceiver(receiver, intentF);
}

But when I go to https://google.fr on chrome browser app, I'm not redirected to my app...

What am I doing wrong ?

Thanks
 
Last edited:
Do you have working app where you enter address in the Chrome like "https://www.evitamins.com" and your application started and opens MainActivity?
When you open Chrome, your application is closed and destroy() method close all receivers that you opened in onCreate method.
So nobody listens URLs in Chrome address bar.
I tried to create application with your Manifest from there https://androidforums.com/threads/h...deeplink-intent-filters.1264632/#post-7746397
My Application does not start when I entered URL "https://www.evitamins.com" in Chrome.
I do follow :
1. open application
2. press home button (app in background memory closed but in memory)
3. open Chrome, enter URL
Nothing happens. Neither with Activity nor with Broadcast Receiver static(manifest) or dynamic (in MainActivity) or in Service (with STICKY flag)
So, could you please get link on demo project that shows your idea.
 
I do have a working app in background when I enter a URL in chrome and the app is not called
But it must also work if the app is closed...

Actually, I'm wandering why my app is not called when I enter a registered URL in my java code... you said that this is because all my receivers are destroyed right ? So how can I register my Broadcast receiver ?
 
I don't have working project so can't help you.
But if you want to get alive Broadcast Receiver out of the Manifest, you can register it in Service, which can work in background even app is closed.
 
  • Like
Reactions: Rob
Back
Top Bottom