broadcastreceiver

Proximity alerts keep being added, how to remove them by using id's?

雨燕双飞 提交于 2019-12-11 14:07:05
问题 I set up my map and a proximity alert for each map marker, here I am passing the lat and long, and place name to the add proximity alert method: if(alerts==true) { addProximityAlert(l1, l2, place); } The add proximity alert method: //The following sets up proximity alerts, getting a unique id for each one private void addProximityAlert(Double latitude, Double longitude, String tit) { Intent intent = new Intent(PROX_ALERT_INTENT); intent.putExtra("name", tit); intent.putExtra("id", alertid);

Why is Network access in my geofence broadcast receiver unreliable?

不羁岁月 提交于 2019-12-11 13:44:37
问题 Use case: When geofence triggers we need to contact server ASAP. We have solved this with an implicit BroadcastReceiver calling a Service for several years, but problematic in new versions due to Doze and Oreo background restrictions. Attempted fixes: We moved geofence registering from implicit -> explicit broadcast receiver to get around the "background mode" restriction. We tried to do it as in Googles examples, i.e. the broadcast receiver calling enqueueWork() on a JobIntentService . The

Broadcast receiver not working when app is cleared from RAM

允我心安 提交于 2019-12-11 13:32:52
问题 I am new to android. I am making an alarm clock. Its working perfectly until the user clears the app from the RAM. On searching, I found that broadcast receivers don't work if the app is cleared from the RAM. So, what exactly should I do? Will sending the broadcast from a service help? Also if you have a link to a good tutorial to Services in android, pls do share. Also let me know if there is some other way to solve my problem. 回答1: In Xiaomi devices, you just have to add your app to

Android Date Changed Broadcast Receiver

混江龙づ霸主 提交于 2019-12-11 13:25:16
问题 I have a broadcast receiver that receives event when user manually changes Date . But I am unable to find what was the previous date he changed. Example- If date was 5-June-2014 and he changed it to 01-June-2014. I want to know the previous date that is 5-june-2014. Please help 回答1: You could register ACTION_TIME_TICK and record the current date every minute. 回答2: The intent to specify Date Changed is android.intent.action.DATE_CHANGED Set a listener to this intent by referring tutorial http:

Get location ( BroadcastReceiver,LocationListener) [closed]

社会主义新天地 提交于 2019-12-11 13:24:30
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I am beginner at android. I have a question. I want to when I receive SMS then get my location(latitude and longitude). How can I do. if you have sample code, it will be more helpful. Thanks for your help. 回答1:

MEDIA_BUTTON button event ACTION_DOWN and ACTION_UP received at the same time

▼魔方 西西 提交于 2019-12-11 13:23:32
问题 In my app I want to measure how long the media button press was. I registered a broadcastReceiver that listens to the media button press: (please excuse stupid mistakes as I am a beginner...) <receiver android:name="MyRec"> <intent-filter> <action android:name="android.intent.action.MEDIA_BUTTON"> <action android:name="android.intent.action.MEDIA_BUTTON"/> </action> </intent-filter> </receiver> The broadcastReceiver activates a method in an activity (not ideal, but this is just for testing

Android BroadCastReceiver and android.intent.action.PHONE_STATE Event

旧城冷巷雨未停 提交于 2019-12-11 13:17:10
问题 I am catching the android.intent.action.PHONE_STATE change event by using following code snippet with android BroadCastReceiver. I could recognize the event successfully and handle the incoming calls also can be done by following code. My requirement is identifying calls which are coming form a particular number, end that call through the code and invoke a web service for that incoming event. In here this code runs twice for call receiving and ending events. I want to stop calling this method

Should BroadcastReceiver be declared inside activities?

别来无恙 提交于 2019-12-11 12:49:16
问题 I'm wondering what's the better cleaner design approach to handle BroadcastReceiver creation between those two: Declaring directly a BroadcastReceiver in an Activity/Fragment and overriding onReceived method there. Creating another custom receiver class in a package "receiver", that extends the BroadcastReceiver class and override onReceive. Then, you instantiate that custom receiver class in your Activity/Fragment. 回答1: There are 2 types of Broadcast Receivers 1)Dynamic Broadcast Receiver

Is there a workaround for FLAG_RECEIVER_REGISTERED_ONLY, when using only a BroadcastReceiver?

廉价感情. 提交于 2019-12-11 12:38:03
问题 I want to be alerted, if a headset is plugged in. But the Intent "ACTION_HEADSET_PLUG" is used with the Flag "FLAG_RECEIVER_REGISTERED_ONLY". So I have to run a service or a activity all the time to get the intent? I just want to run a Broadcastreceiver and NO service or activity at all. Is there a workaround for this? Is this even possible? Or can I start a service once, registering and then stopping it? P.S.: I know when the headset is plugged off with the becoming noisy intent. Thank you

Why won't my BroadcastReceiver call other methods?

被刻印的时光 ゝ 提交于 2019-12-11 12:28:39
问题 I have a BroadcastReceiver that can successfully catch a broadcast, but if I try to call another method from it, it won't always work. Here's my setup: private class MyReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (working == true) { //toast to make sure we got here doWork(); } } } The toast within the if gets called, but doWork doesn't execute. Has anyone dealt with a similar issue? 回答1: The Broadcast receiver doesn't have the same