BroadcastReceiver ACTION_SETTINGS. Does not intercept

0

Good evening, everyone. I would like my application to be called when the user clicked "Settings" on his device.

So I tried to use a BroadcastReceiver to intercept android.provider.Settings.ACTION_SETTINGS and put my application as the default.

I'm sweating the shirt, I created an app with:

startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);

This app works correctly, it invokes the Android configurator. It turns out that I would like my broadcast to be recognized, and by calling this activity Android would display my application for the user to select her or the configurator.

I then broadcast:

<receiver android:name=".BlockConfig">
   <intent-filter >
                <action android:name="android.provider.Settings.ACTION_SETTINGS"/>
                <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>
</receiver>

But when I call Settings.ACTION_SETTINGS, it opens directly in the configurator.

Can someone give me a light where I'm going wrong? Thanks

    
asked by anonymous 14.09.2015 / 05:52

1 answer

0

I think you're experiencing the same problem / confusion expressed in this question , whose response is simple:

  

You can not "intercept" startActivity() calls using a BroadcastReceiver . BroadcastReceiver receives broadcasts, not startActivity() calls.

  

You can not "intercept" calls via startActivity() using a BroadcastReceiver . BroadcastReceiver receives transmissions, not calls via startActivity() .

That is, startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0); will launch an Activity and not a BroadcastReceiver

What you can try (not tested) is, in AndroidManifest.xml, add

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

to <intent-filter> of Activity whatever it is launched.

    
14.09.2015 / 15:06