broadcastreceiver

Stop broadcast receiver from a button in acivity

旧巷老猫 提交于 2020-01-02 04:37:29
问题 I want to stop and start a broadcast receiver through a button click. two services associated with the broadcast receiver should also stop and start with button click how can i do it.. 回答1: this is the code............ b1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub PackageManager pm = Re_editActivity.this.getPackageManager(); ComponentName componentName = new ComponentName(currentActivity.this, name_of_your

handler.postDelayed vs. AlarmManager vs

ぐ巨炮叔叔 提交于 2020-01-01 19:27:09
问题 I have a minor problem in one of my apps. It uses a BroadCastReceiver to detect when a call finishes and then performs some minor housekeeping tasks. These have to be delayed for a few seconds, to allow the user to see some data and to ensure that the call log has been updated. I'm currently using handler.postDelayed() for this purpose: public class CallEndReceiver extends BroadcastReceiver { @Override public void onReceive(final Context context, final Intent intent) { if (DebugFlags.LOG

Android : Not able to sync data between applications above Oreo + devices

删除回忆录丶 提交于 2020-01-01 19:22:37
问题 I am stuck on sync real time data between 2 app only in Oreo+ devices, Like if different user login to the app then it should be immediately effect in other app and It should also change in other app.(e.g. Facebook and Facebook Messenger. If you logout from Facebook, it will automatically logout from FB Messenger or If you log into Facebook then it will automatically logged into FB Messenger and vice versa) I created broadcast receiver in both app and if login changes from one app then send

Calling the finish() method of an Activity from a BroadcastReceiver

隐身守侯 提交于 2020-01-01 17:06:45
问题 I have 2 Activities (Activity1, Activity2) and a BroadcastReceiver class Assume that we are now on Activity2, where I set up an AlarmManager to run at a specific time. Is there a way to call the finish() method of Activity2 within the onReceive() of the BroadcastReceiver? My goal is to return to Activity1 from Activity2 without starting a new Intent in onRecieve(). Note: The BroadcastReceiver class is not registered within the Activity of Activity2. It is registered in the AndroidManifest.xml

Android: ACTION_BATTERY_LOW not triggered in emulator. Receiver registered in code, not manifest

耗尽温柔 提交于 2020-01-01 10:46:13
问题 I have seen posts where it was mentioned registerReceiver has to be called (not defined in manifest) to receive ACTION_BATTERY_LOW intent. public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { //.... registerReceiver(new BatteryLevelReceiver(), new IntentFilter( Intent.ACTION_BATTERY_LOW)); } // ....... } BroadcastReceiver public class BatteryLevelReceiver extends BroadcastReceiver { private static final String TAG = BatteryLevelReceiver

Android Widget stops working randomly

随声附和 提交于 2020-01-01 10:06:52
问题 I have been working with this problem for three days now and I've looked at every single question on here for an answer. I have a widget with a button on it and all I would like it to do is start a service everytime it is clicked. The problem is that the button stops working randomly. I can't recreate it at all and I have no idea what causes it. My service calls stopSelf(); but I have had this problem with a broadcast receiver also so I believe the problem to be in the widget and not in the

android.net.wifi.WIFI_STATE_CHANGED not being broadcast

久未见 提交于 2020-01-01 09:53:10
问题 In my app, I need a service restarted if a network change is connected. Currently it only works one way (wifi to mobile data) but it doesn't work the other way (mobile data to wifi.) Why is this? Is it because I'm not getting android.net.wifi.WIFI_STATE_CHANGED in my broadcast receiver or maybe a misplaced permission? Thanks for any help. Code: Manifest entry for receiver: <receiver android:name="LiveForever" android:label="NetworkChangeReceiver" > <intent-filter> <action android:name=

android.net.wifi.WIFI_STATE_CHANGED not being broadcast

只愿长相守 提交于 2020-01-01 09:52:56
问题 In my app, I need a service restarted if a network change is connected. Currently it only works one way (wifi to mobile data) but it doesn't work the other way (mobile data to wifi.) Why is this? Is it because I'm not getting android.net.wifi.WIFI_STATE_CHANGED in my broadcast receiver or maybe a misplaced permission? Thanks for any help. Code: Manifest entry for receiver: <receiver android:name="LiveForever" android:label="NetworkChangeReceiver" > <intent-filter> <action android:name=

android.net.wifi.WIFI_STATE_CHANGED not being broadcast

蓝咒 提交于 2020-01-01 09:52:48
问题 In my app, I need a service restarted if a network change is connected. Currently it only works one way (wifi to mobile data) but it doesn't work the other way (mobile data to wifi.) Why is this? Is it because I'm not getting android.net.wifi.WIFI_STATE_CHANGED in my broadcast receiver or maybe a misplaced permission? Thanks for any help. Code: Manifest entry for receiver: <receiver android:name="LiveForever" android:label="NetworkChangeReceiver" > <intent-filter> <action android:name=

Is this possible to check if a broadcast was sent in sticky mode? Can it be aborted/removed?

試著忘記壹切 提交于 2020-01-01 08:21:32
问题 Is this possible to check if a broadcast was sent in sticky mode? Can we completely abort/remove a sticky broadcast? If yes, then can it be done for both normal and ordered broadcasts? 回答1: In onReceive() you can use the following calls: isInitialStickyBroadcast() - This will tell you if the broadcast you are currently processing was sent as "sticky" and was the current one when the BroadcastReceiver was registered. isOrderedBroadcast() - This will tell you if the broadcast you are currently