2

I am currently doing a custom scheme intent-filter to open my own app from the browser.

Is it possible to instead opening an activity to launch a broadcast receiver.

My current code for the activity broadcast receiver is like this:

  <action android:name="android.intent.action.VIEW" >
            </action>

            <category android:name="android.intent.category.DEFAULT" >
            </category>
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="shortener.com"
                android:scheme="shortener" >
            </data>
        </intent-filter>

Here is my receiver code. Doesn't trigger. tried a View action and a custom action

 <receiver android:name="MyReceiver" >
            <intent-filter>
                <action android:name="com.dg.action.CONFIGURE" >
                </action>
                <category android:name="android.intent.category.DEFAULT" >
                </category>
                <data
                    android:host="shortener.com"
                    android:scheme="shortener" >
                </data>
            </intent-filter>
        </receiver>
DArkO
  • 14,990
  • 10
  • 56
  • 82
  • http://stackoverflow.com/questions/2958701/launch-custom-android-application-from-android-browser/2958870#2958870 try this – Prakash May 25 '15 at 17:02

1 Answers1

10

I know this is old, but since there's no clear and accepted answer on it, what the hey. As the official documentation puts it:

...the Intent broadcast mechanism .. is completely separate from Intents that are used to start Activities with Context.startActivity(). There is no way for a BroadcastReceiver to see or capture Intents used with startActivity(); likewise, when you broadcast an Intent, you will never find or start an Activity. These two operations are semantically very different: starting an Activity with an Intent is a foreground operation that modifies what the user is currently interacting with; broadcasting an Intent is a background operation that the user is not normally aware of.

Source: Android Developer Documentation, BroadcastReceiver

Hope that makes it clear.

themightyjon
  • 972
  • 8
  • 10
  • 1
    Yes this makes sense. I thought that when you want to do an action, lets say ACTION_VIEW as it was in my case that every component that listens to that action is registered and shows up as someone that can carry it out and not just activities OR broadcastReceivers OR Services exclusively. but when you consider it it is actually triggered from startActivity(intent) as you say. – DArkO Oct 08 '13 at 19:09
  • Further links to help with this clarification: [Standard Activity Actions](https://developer.android.com/reference/android/content/Intent.html#standard-activity-actions) vs [Standard Broadcast Actions](https://developer.android.com/reference/android/content/Intent.html#standard-broadcast-actions) – MechEthan Sep 05 '19 at 16:44