android-broadcast

Show push notifications when application open/closed in different way

烈酒焚心 提交于 2019-12-01 05:42:07
问题 In my app I've a several Activities that inherit from one BaseActivity. My application receive push notification with GCMBaseIntentService I need to implement the next logic: When push received if the application is open show dialog, if closed show notification. My code: public class GCMIntentService extends GCMBaseIntentService { ----------------------- other code ---------------------------------------- @Override protected void onMessage(Context context, Intent intent) { Log.d(TAG,

Widget issue: BroadcastQueue: Background execution not allowed: receiving Intent

喜你入骨 提交于 2019-12-01 04:14:36
问题 My app widget stops working after upgrading to targetSDk to 28. It is flawlessly working on old targetsdk devices. I am getting the following error: W/BroadcastQueue: Background execution not allowed: receiving Intent { act=ch.corten.aha.worldclock.WIDGET_DATA_CHANGED flg=0x10 } to ch.corten.aha.worldclock/.WorldClockWidgetProvider W/BroadcastQueue: Background execution not allowed: receiving Intent { act=ch.corten.aha.worldclock.WIDGET_DATA_CHANGED flg=0x10 } to ch.corten.aha.worldclock/

Android keep BroadcastReceiver in background

南楼画角 提交于 2019-11-30 22:00:17
I created a BroadcastReceiver and it runs only when my app shown in recent apps menu. If I remove my app from the recent apps the BroadcastReceiver will stop working. How can I keep the BroadcastReceiver in background? I register the BroadcastReceiver from my main activity (in OnCreate()). IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); registerReceiver(receiver, intentFilter); BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { } }; This is not how you should register a receiver. You receiver

Oreo: Broadcast receiver Not working

允我心安 提交于 2019-11-30 17:54:37
问题 I was trying to get notification trigger on my application whenever the user makes a new call. I'm registering receiver in my activity and destroying it in onDestroy() method. Following is the code snippets for registering registerReceiver(inComingCall = new IncomingCall(),new IntentFilter("android.intent.action.PHONE_STATE")); The issue I'm facing is I'm not getting any trigger in override onReceive() method for the Broadcast receiver. Kindly let me know whether any new implementations or

Dynamic Registration vs Static Registration of BroadcastReceiver

妖精的绣舞 提交于 2019-11-30 17:30:28
All of us known we register BroadcastReceiver in two types 1)Static Registration 2)Dynamic Registration But my doubt is when we need to use Static and when we need to use Dynamic ? Jitesh Upadhyay As we know there are two ways to register a BroadcastReceiver ; one is static and the other dynamic . Static: Use tag in your Manifest file. (AndroidManifest.xml) Not all events can be registered statically. Some events require permissions. Dynamic: Use Context.registerReceiver() to dynamically register an instance. Note: Unregister when pausing. When we are doing dynamic registration (i.e. at run

Android keep BroadcastReceiver in background

夙愿已清 提交于 2019-11-30 17:18:44
问题 I created a BroadcastReceiver and it runs only when my app shown in recent apps menu. If I remove my app from the recent apps the BroadcastReceiver will stop working. How can I keep the BroadcastReceiver in background? I register the BroadcastReceiver from my main activity (in OnCreate()). IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); registerReceiver(receiver, intentFilter); BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive

Access to application class in Broadcast Receiver

我是研究僧i 提交于 2019-11-30 13:18:26
I want to check internet connection in Broadcast Receiver; And set result (A boolean flag) to a global variable, to use it on whole application, in if conditions; That if internet is disconnected, set a status imageview in main activity, to red image, and if connected, set it to green. I followed this topic. But there is no getApplication() in Broadcast Receiver; And iI should use getApplicationContext() instead. On another side, this topic: when writing code in a broadcast receiver, which is not a context but is given a context in its onReceive method, you can only call getApplicationContext(

Volume change Listener: Is registerMediaButtonEventReceiver preferable to onKeyDown?

蹲街弑〆低调 提交于 2019-11-30 09:30:24
Looking for a "most comprehensive & compatible (i.e. all Android versions...)" way to listen to volume changes, I found 2 different approaches to handle this: registerMediaButtonEventReceiver onKeyDown + SettingsContentObserver Which method is preferable? And why? UPDATE 1: Thanks to the comment below, I discovered that onKeyDown() actually takes over the volume key, which may not be a complete solution as one of the posts mentioned that volume could be changed via interfaces other than the hardware buttons (not to mention that Google seems to be gradually taking away those "take over"

android.intent.action.BOOT_COMPLETED Intent is not received at “Restart” or “Reboot”

三世轮回 提交于 2019-11-30 08:55:56
Android android.intent.action.BOOT_COMPLETED Intent is not received if I use the "Restart" or "Reboot" , but works if I turn off and on the device. Is there Any way to make this work? Add <action android:name="android.intent.action.QUICKBOOT_POWERON" /> also Kindly add the below Permission: <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> and add the Receiver Class entry in manifest.zml: <receiver android:name="com.example.receivers.BootReceiver" > Now Receiver Class: import android.content.BroadcastReceiver; import android.content.Context; import android.content

Dynamic Registration vs Static Registration of BroadcastReceiver

给你一囗甜甜゛ 提交于 2019-11-30 01:23:13
问题 All of us known we register BroadcastReceiver in two types 1)Static Registration 2)Dynamic Registration But my doubt is when we need to use Static and when we need to use Dynamic ? 回答1: As we know there are two ways to register a BroadcastReceiver ; one is static and the other dynamic . Static: Use tag in your Manifest file. (AndroidManifest.xml) Not all events can be registered statically. Some events require permissions. Dynamic: Use Context.registerReceiver() to dynamically register an