android-broadcastreceiver

Manifest-declared BroadcastReceiver not picking up explicit broadcast when app is not running

蓝咒 提交于 2019-12-22 10:56:36
问题 I am trying to get two apps to communicate via broadcasts. The first app sends a broadcast using code like the following: Intent outIntent = new Intent("org.example.WHATEVER"); PackageManager pm = this.getPackageManager(); List<ResolveInfo> receivers = pm.queryBroadcastReceivers(outIntent, 0); if (receivers != null) for (ResolveInfo receiver : receivers) { Log.d("Sender", String.format("Polling %s", receiver.activityInfo.packageName)); outIntent = new Intent("org.example.WHATEVER"); outIntent

Is it possible to call onReceive method from a dialog?

霸气de小男生 提交于 2019-12-22 10:06:27
问题 I have a custom dialog with editText and save button . When button clicked, I want it call MyReceiver . But the log and Toast in MyReceiver never get displayed. Reminder final AlertDialog.Builder builder = new AlertDialog.Builder(this); LayoutInflater inflater = LayoutInflater.from(this); View promptView = getLayoutInflater().inflate(R.layout.dialog_with_edittext, null); Button save = (Button) promptView.findViewById(R.id.okBtn); final EditText task = (EditText) promptView.findViewById(R.id

Crash while self updating APK (component class does not exist)

你。 提交于 2019-12-21 03:37:29
问题 I am working on a system application which updates itslef by downloading an apk and installing it by using PackageManager's installPackage() method. I am getting the following exception: Fatal Exception: java.lang.IllegalArgumentException: Component class com.myapp.package.receivers.SomeOldReceiver does not exist in com.myapp.package at android.os.Parcel.readException(Parcel.java:1544) at android.os.Parcel.readException(Parcel.java:1493) at android.content.pm.IPackageManager$Stub$Proxy

Android - Trouble with service sending multiple local notifications

喜欢而已 提交于 2019-12-20 04:08:15
问题 I've inherited a code base for an Android app and I'm facing a particularly though problem with local notifications. The idea is to send a notification for each event which is scheduled in the future, considering also the reminder preference on how many minutes before the event the user wants to be notified. Everything works just fine, except that after the notification is thrown for the first time, if the user opens the app before the event starts, the notification gets thrown another time.

Handle programmatically unregister BroadcastReceiver on process death

拜拜、爱过 提交于 2019-12-18 09:24:52
问题 In my app I register BroadcastReceiver programmatically like that and unregister it in appropriate time with respect to my app's business logic. receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) {...} I want to make sure that when my app's process unexpectedly die (get killed) no memory leak is caused by the receiver and if it does what are my options? (Already check the official doc, this great article and this SO thread ) 回答1: I want to

Register broadcast receiver dynamically does not work - BluetoothDevice.ACTION_FOUND

拜拜、爱过 提交于 2019-12-17 18:24:07
问题 Using Log class to track Runtime show that onReceive() methode does not called,why ? Register broadcast receiver dynamically private void discoverDevices () { Log.e("MOHAB","BEFORE ON RECEIVE"); mReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { Log.e("MOHAB","ON RECEIVE"); String action = intent.getAction(); // When discovery finds a device if (BluetoothDevice.ACTION_FOUND.equals(action)) { // Get the BluetoothDevice object from the Intent

android - “Exported receiver does not require permission” on receivers meant to receive from system services

最后都变了- 提交于 2019-12-17 15:34:56
问题 I have some receivers declared in my AndroidManifest : <!-- no warning --> <receiver android:name=".receivers.TriggerMonitoringBootReceiver" android:enabled="false"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> <!-- no warning --> <receiver android:name=".receivers.ScanResultsReceiver" android:enabled="false"> <intent-filter> <action android:name="android.net.wifi.SCAN_RESULTS" /> </intent-filter> </receiver> <!-- warning :

Broadcast Receiver Not Working After Device Reboot in Android

假装没事ソ 提交于 2019-12-17 07:03:11
问题 I have already checked all the related questions and have not found any solution for this problem. So this is an absolutely new problem for me. What I Have I have an Android app which registers a few broadcast receivers in its manifest. This is what my manifest looks like. <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.app.myapp"> <uses-permission android:name="android

Broadcast Receiver Not Working After Device Reboot in Android

柔情痞子 提交于 2019-12-17 07:03:06
问题 I have already checked all the related questions and have not found any solution for this problem. So this is an absolutely new problem for me. What I Have I have an Android app which registers a few broadcast receivers in its manifest. This is what my manifest looks like. <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.app.myapp"> <uses-permission android:name="android

How to check if Receiver is registered in Android?

旧巷老猫 提交于 2019-12-17 04:44:16
问题 I need to check if my registered receiver is still registered if not how do i check it any methods? 回答1: I am not sure the API provides directly an API, if you consider this thread: I was wondering the same thing. In my case I have a BroadcastReceiver implementation that calls Context#unregisterReceiver(BroadcastReceiver) passing itself as the argument after handling the Intent that it receives. There is a small chance that the receiver's onReceive(Context, Intent) method is called more than