Broadcastreceiver ACTION_SETTINGS. Does not intercept

Asked

Viewed 138 times

0

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

So I tried to use one Broadcastreceiver to intercept the android.provider.Settings.ACTION_SETTINGS and set my application as standard.

I’m sweating my 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 when calling this Activity the Android display my application for the user to select it or the configurator.

Then I 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? Thank you

1 answer

0

I believe you are facing the same problem/confusion expressed in this question, whose reply is simple:

You cannot "Intercept" startActivity() calls using a Broadcastreceiver. To Broadcastreceiver receives Broadcasts, not startActivity() calls.

You cannot "intercept" calls via startActivity() using a Broadcastreceiver. The Broadcastreceiver receives transmissions, no calls via startActivity().

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

What you can try (not tested) is, on Androidmanifest.xml, to add

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

at the <intent-filter> of Activity whatever is launched.

  • Hello Ramaral. I appreciate the reply, but it occurs initially my tests were invoking a Broadcast correctly sendBroadcast(new Intent("BROADCAST NAME")); The problem is not to invoke the broadcast, with both mine and Android natives (like the case of android.provider.Settings.ACTION_SETTINGS) The problem is that I can’t make Android identify that my application also has such a broadcast, and display pro user choose which application to open this call with (my or the default android configurator)

  • Have you tried to do what I suggested in the answer?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.