broadcastreceiver

Missing a call to unregister HapticFeedbackBroadcastReceiver receiver that I never registered

谁都会走 提交于 2019-11-30 15:12:42
问题 I get the following error "Are you missing a call to unregister receiver" when I hit the back button to exit my application. How do I identify which Receiver is causing the leak and eliminate the error? I am using the code "DownLoader" from Google to download an expansion file. 10-27 22:13:32.818: E/ActivityThread(30744): Activity com.ssowens.groovebasstrial.BassActivity has leaked IntentReceiver com.immersion.android.haptics.HapticFeedbackManager$HapticFeedbackBroadcastReceiver@41d166d0 that

Creating a Notification at a particular time through Alarm Manager

牧云@^-^@ 提交于 2019-11-30 14:15:59
问题 I am trying to create a notification at a particular time. Im creating a broadcast receiver and calling it through the AlarmManager. Problem is that the broadcast is not received and that I am not getting any notifications. Registering the Broadcast Receiver in the Manifest, <receiver android:name="com.example.android.receivers"> <intent-filter> <action android:name="com.example.android.receivers.AlarmReceiver" /> </intent-filter> </receiver> This is the Broadcast Receiver, public class

BroadcastReceiver Life Cycle — Static Variables

∥☆過路亽.° 提交于 2019-11-30 13:53:56
I have a BroadcastReceiver class. I have some static variables declared whose value is updated in side the onReceive() method. As per my knowledge static variable will keep it's value across the onReceive calls. Is there any possibility when I will loose those values(Like my class will be unloaded resetting the static variables)? These are basically some temporary variables I need to be available for multiple onReceive calls. From the documentation for BroadcastReceiver Lifecycle ... A BroadcastReceiver object is only valid for the duration of the call to onReceive(Context, Intent). Once your

What is the use of android:exported=“true” in BroadcastReceiver

跟風遠走 提交于 2019-11-30 13:41:15
问题 Hi I see that some broadcast receiver use this tag android:exported="true" in Android Manifest.xml to register. <receiver android:exported="true" android:name="com.flyingsoftgames.googleplayquery.QueryReceiver"> <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER" /> </intent-filter> </receiver> What exactly the use of android:exported="true" to register broadcast receiver in Android ? Thanks in advance. 回答1: From the Developer Guide: android:exported Whether or not the

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(

PACKAGE_ADDED BroadcastReceiver doesn't work

廉价感情. 提交于 2019-11-30 12:51:36
问题 I have a broadcast receiver registered in Manifest: <application ...> <receiver android:name="com.some.pkg.NewAppReceiver" > <intent-filter> <action android:name="android.intent.action.PACKAGE_ADDED" /> </intent-filter> </receiver> </appcication> And the receiver: public class NewAppReceiver extends BroadcastReceiver { private static final String TAG = "NewAppReceiver"; @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "Intent: " + intent.getAction()); } } And

Android detect Bluetooth disconnect immediately Max 2 seconds

冷暖自知 提交于 2019-11-30 11:31:00
I'm looking for a way to detect the disconnection of a Bluetooth device immediately after it has happened (2 second max), typically in a "device too far" scenario or Device battery is dead. Currently I can detect it with a BroadcastReceiver by getting a BluetoothDevice.ACTION_ACL_DISCONNECTED , but it takes about 16 to 20 seconds to fire. Is there any way to get notified in 2 seconds Max. I used BroadcatReceiver but it is not fast enough to get alert in 2 seconds Max, so is there any other kind of approach available to get notification quickly that bluetooth is disconnected. I use this

Toast message from Broadcast Receiver

旧巷老猫 提交于 2019-11-30 11:17:23
I have a broadcast receiver and I am trying to show a toast message from it, is this possible ? This code doesn't show the toast but it print the log message in the logcat. Is there some idiotic thing I am doing or what is my problem ? @Override public void onReceive(Context context, Intent intent) { Log.v("log", "this is shown"); Toast.makeText(context, "this is not shown" , Toast.LENGTH_LONG); } Call the show() method for the Toast . you forgot to call show() on the Toast .. although i would not recommend creating toasts from BroadcastReceivers.. you might consider using Notifications Use

Receiver stopped receiving in Oreo

让人想犯罪 __ 提交于 2019-11-30 10:26:07
I understand services and such are being clamped down on, so my receiver has stopped working in Android Oreo. I have this code starting the service - Intent intent = new Intent(this, MyService.class); intent.putExtra("Time", locationUpdatesTime); intent.putExtra("Dist", locationUpdatesDistance); startService(intent); I have this in my service - Intent intent = new Intent(); intent.setAction("com.androidandyuk.laptimerbuddy"); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent.putExtra("Lat", thisLat); intent.putExtra("Lon", thisLon); sendBroadcast(intent); But my receiver is never

Calling AlarmManager in Service

可紊 提交于 2019-11-30 09:57:25
问题 Context: I am attempting to implement one service call a second service (a subclass of the first) via an AlarmManager. To do this, I needed to create a Broadcast Receiver as an inner class, as recommended here (Service and a BroadCastReceiver). However, it appears that the first service is never successfully calling the second service, or the second service is not receiving the call. I have looked around SO and found that someone else had a similar problem that was never resolved: