android-broadcastreceiver

Local broadcast from Service not received by Activity

僤鯓⒐⒋嵵緔 提交于 2019-12-05 02:39:11
I have an Activity in which I am registering a BroadcastReceiver locally as follows: public class SomeActivity extends Activity{ public static final String PERFORM_SOME_ACTION = "PERFORM_SOME_ACTION"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.some_activity_layout); ..... ..... IntentFilter filter = new IntentFilter(); filter.addAction(PERFORM_SOME_ACTION); receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // perform some action ... } }; registerReceiver(receiver

Register Broadcast Receiver from another Broadcast Receiver in android

拈花ヽ惹草 提交于 2019-12-04 23:40:41
问题 Currently I have Broadcast Receiver for listening call states events. I have registered Broadcast Receiver in AndroidManifest.xml as shown below. <receiver android:name=".api.PhoneCallReceiver"> <intent-filter> <action android:name="android.intent.action.PHONE_STATE" /> </intent-filter> </receiver> When Application launches this broadcast receiver is registered for listening call states events and according to CALL_STATE i am managing my application. It is working fine until phone restarts.

How to receive USB connection status broadcast?

若如初见. 提交于 2019-12-04 10:28:49
I am trying to detect USB connection in my app, that is, whether or not USB is connected to device. It's being tested on Marshmallow 6.0.1 (sdk23) But I'm unable to receive the broadcast actions ACTION_USB_DEVICE_ATTACHED or ACTION_USB_DEVICE_DETACHED.. I tried using both the dynamic way and the AndroidManifest.xml way, neither worked.. Here's my code: AndroidManifest.xml : <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.gokulnc.blah_blah" android:installLocation="auto" android:versionCode="15" android:versionName="1.5.1"

setRepeating of AlarmManager not respond within the time indicated

你离开我真会死。 提交于 2019-12-04 06:30:05
问题 AlarmManager should be repeated every 1 minute, but repeated every 1, 2, 3 or 4 minutes. Since the application I throw AlarmManager public class PacienteApp extends Application { @Override public void onCreate() { AlarmManager gps = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(this, GpsReceiver.class); PendingIntent pending = PendingIntent.getBroadcast(this, 0, i, 0); gps.setRepeating(AlarmManager.RTC, System.currentTimeMillis(), 1000 * 60, pending); } }

Android - get a reference to a BroadcastReceiver defined in Manifest

亡梦爱人 提交于 2019-12-04 04:11:34
问题 Is there any way how to get a reference for a BroadcastReceiver defined in Manifest.xml from code? In my case, we are using a BroadcastReceiver that needs to be included in the Manifest.xml. However it has functionality I would like to reuse from within our code. So instead of creating another similar BroadcastReceiver and instantiating it from the code I would like to obtain a reference to the existing one. Additional information: My goal is to subscribe to an event on my BroadcastReceiver

Mobilock app starts before BOOT_COMPLETED broadcast… How is it possible?

扶醉桌前 提交于 2019-12-04 02:03:29
问题 There is a kiosk app called Mobilock. This app starts way faster (Almost 5 seconds before) than my own app which starts with BOOT_COMPLETED broadcast. My own app has the highest priority which is max value of integer. So this is not about the priority. These guys have found a way to start their application 5 second sooner than BOOT_COMPLETED broadcast. Has anyone got an idea about what they are doing? 回答1: Listen also to android.intent.action.QUICKBOOT_POWERON and android.intent.action.LOCKED

Register Broadcast Receiver from another Broadcast Receiver in android

 ̄綄美尐妖づ 提交于 2019-12-03 15:47:07
Currently I have Broadcast Receiver for listening call states events. I have registered Broadcast Receiver in AndroidManifest.xml as shown below. <receiver android:name=".api.PhoneCallReceiver"> <intent-filter> <action android:name="android.intent.action.PHONE_STATE" /> </intent-filter> </receiver> When Application launches this broadcast receiver is registered for listening call states events and according to CALL_STATE i am managing my application. It is working fine until phone restarts. After phone restart this broadcast receiver stops working. I know I have to register receiver for

Receive Parse notification using custom broadcastreceiver

房东的猫 提交于 2019-12-03 13:49:17
问题 Am using parse notification in my app. Am receiving notification alert using GcmBroadcastReceiver. But am seeing lot of notification receiving to my app. I thought to update notification in status bar so i used custom receiver. When receiving notification through GcmBroadcastReceiver, my custom broadcastreceiver called. So in my status bar having both gcm and custom notifications. I want custom notification only. How to solve this problem? Manifest code: <receiver android:name="com.parse

WakefulBroadcastReceiver is deprecated

时间秒杀一切 提交于 2019-12-03 11:22:14
问题 For creating a receiver I'm extended WakefulBroadcastReceiver in my old project. But now it's deprecated . Instead of WakefulBroadcastReceiver which Receiver I should use now and how to convert below code with new method? Here is my code: public class TaskFinishReceiver extends WakefulBroadcastReceiver { private PowerManager mPowerManager; private PowerManager.WakeLock mWakeLock; @Override public void onReceive(Context context, Intent intent) { mPowerManager = (PowerManager) context

Receive Parse notification using custom broadcastreceiver

老子叫甜甜 提交于 2019-12-03 04:47:18
Am using parse notification in my app. Am receiving notification alert using GcmBroadcastReceiver. But am seeing lot of notification receiving to my app. I thought to update notification in status bar so i used custom receiver. When receiving notification through GcmBroadcastReceiver, my custom broadcastreceiver called. So in my status bar having both gcm and custom notifications. I want custom notification only. How to solve this problem? Manifest code: <receiver android:name="com.parse.ParseBroadcastReceiver" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" />