broadcastreceiver

Listen to location access disable/enable in settings

两盒软妹~` 提交于 2019-12-09 17:12:13
问题 In Android OS, in " Settings " --> " Location services ", there is a toggle button named " Access to my location " which can be used to disable & enable location info access from apps. Currently, I am developing a location service application. I am wondering, how can I listen to this setting in my Android project? Is there any broadcast receiver I can use to know right away when user disable or enable " Access to my location " ? If there isn't any broadcast receiver for it, how can I listen

Android - sendOrderedBroadcast help

一曲冷凌霜 提交于 2019-12-09 11:42:42
问题 I am trying to use a sendOrderedBroadcast in my Android app. I want to be able to send the Intent from one of my applications to another and I then want to get data back from the Application that recieves the Intent, in this case a boolean true or false. Here is the current code: Intent i = new Intent(); i.setAction(GlobalData.PROPOSE_IN_DOMAIN_ROAM_INTENT); i.putExtra("com.testnetworks.QCLEVEL", aProposedTheoreticalQoSLevel); sendOrderedBroadcast(i, null, null, null, Activity.RESULT_OK, null

When To Unregister Broadcast Receiver registered in onCreate?

試著忘記壹切 提交于 2019-12-09 09:25:42
问题 In Android, I've registered a BroadcastReceiver in my onCreate(). Where should I unregister so that I won't have leaked receivers? 回答1: http://developer.android.com/reference/android/content/BroadcastReceiver.html "You can either dynamically register an instance of this class with Context.registerReceiver() or statically publish an implementation through the tag in your AndroidManifest.xml. Note: If registering a receiver in your Activity.onResume() implementation, you should unregister it in

How to release the microphone resource when another Android app needs it?

一个人想着一个人 提交于 2019-12-09 09:20:37
问题 I have implemented an Android background service (based in Pocket Sphinx) that continuously listens, detects and spots certain keywords when the phone's screen is on, and then reacts accordingly (for a domotic project). However, my app should always have a lower priority and I want it to release the microphone's resources when any other app needs to use it. Is there any system intent or system broadcast that I can receive when an app -wants- to use the microphone (so that my service can

Android: detect when GPS is turned on/off (or when no app is using it anymore)

我是研究僧i 提交于 2019-12-09 08:05:48
问题 I'm on Android 2.3.7 and I'm trying to write a BroadcastReceiver that will get called when the user turns GPS on/off (ie: by tapping on the "use GPS satellites" in the options. What I've done so far is this: 1) Created the following broadcastReceiver: public class GPSStatusBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context arg0, Intent arg1) { Toast.makeText(arg0, "Broadcast received!", Toast.LENGTH_SHORT).show(); } } 2)Added this to the android manifest,

Hide sms notifications with a broadcastreceiver in KitKat

做~自己de王妃 提交于 2019-12-09 07:20:16
问题 I'm trying to intercept the received SMSs by using a broadcast receiver. Here is the code: <receiver android:name=".receivers.SmsReceiver" android:enabled="true" android:exported="true" android:priority="999"> <intent-filter> <action android:name="android.provider.Telephony.SMS_RECEIVED" /> </intent-filter> </receiver> and: public class SmsReceiver extends BroadcastReceiver { private static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED"; @Override public void onReceive

Android IntentService won't start on boot

◇◆丶佛笑我妖孽 提交于 2019-12-09 07:20:11
问题 I have an IntentService which starts on boot and stays running in the background. There is no launcher Activity, the IntentService is called by a broadcast receiver. It works on 2.3.4 and 4.0.4 devices but not on 4.2.2. Maybe my broadcast receiver isn't being triggered on the device? Manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="br.com.xxx" android:versionCode="1" android:versionName="1.0"> <uses-sdk android

How to send broadcast with permission from command line

偶尔善良 提交于 2019-12-09 07:01:32
问题 I have a broadcast receiver in a app which uses my permission com.myexample.permission.MY_PERMISSION . I am able to send the broadcast using sendBroadcast(intent, "com.myexample.permission.MY_PERMISSION") from activities. To send a broadcast for action as com.com.myexample.MY_ACTION and extra data with key as MY_EXTRA below command can be used: $adb shell am broadcast -a com.com.myexample.MY_ACTION --ez MY_EXTRA true But how to send broadcast with permission com.myexample.permission.MY

SMS_RECEIVED onReceive android 2.3.5 not triggering

99封情书 提交于 2019-12-09 06:57:26
I've been puzzling over this one recently, prior to 2.3.5 this seems to work fine (on my colleagues devices). However on mine it now never triggers. I've stripped the code right back and made a very simple test application to see what's going on. Basically the onReceive code doesn't ever appear to trigger, even though adb/logcat does seem to show the register of the BroadcastReveiver does take place. Here's the simple code I've gone for: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.broadcasttech.testsmsreceive" android

Monitoring the Hotspot state in Android

不打扰是莪最后的温柔 提交于 2019-12-09 04:18:20
问题 I'm new to android. I want to receive information via broadcastreceiver ( onReceive ) to know that if user enable/disable "Portable Wi-Fi Hotspot" (Settings->Wireless &Networks->Tethering & portable hotspot) . Check this link And I found that there is " android.net.wifi.WIFI_AP_STATE_CHANGED " but it was set to hidden. Any how I can use that ??? Thanks in advance 回答1: to receive enable/disable "Portable Wi-Fi Hotspot" events you will need to register an Receiver for WIFI_AP_STATE_CHANGED as :