Android Alarm Manager with broadcast receiver registered in code rather than manifest

How about this? Intent startIntent = new Intent(“WhatEverYouWant”); PendingIntent startPIntent = PendingIntent.getBroadcast(context, 0, startIntent, 0); AlarmManager alarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarm.set(AlarmManager.RTC_WAKEUP, triggerTime, startPIntent); And then in your Manifest.xml file: <receiver android:name=”com.package.YourOnReceiver”> <intent-filter> <action android:name=”WhatEverYouWant” /> </intent-filter> </receiver> So as far as I know you still have to declare the receiver in the Manifest. I’m not … Read more

Volume change listener?

Check out registerMediaButtonEventReceiver(ComponentName broadcastReceiver); Define a BroadcastReceiver that handles ACTION_MEDIA_BUTTON. The recieved intent includes a single extra field, EXTRA_KEY_EVENT, containing the key event that caused the broadcast. You can use this key event to get which key was pressed. EDIT: This is just a sample code. syntax errors may be there. // in onCreate of … Read more

SharedPreferences in BroadcastReceiver seems to not update?

I had the same problem and after struggling for hours to solve it, I finally found the issue causing it. In your AndroidManifest you probably have something like that: <receiver android:name=”AlarmReceiver” android:process=”:remote” /> The last attribute (process:remote) cause the receiver to run on a different/new process when it is called. But SharedPreferences is NOT supported … Read more

BroadcastReceiver SMS_Received not working on new devices

Okay the problem was resolved. The issue did not reside with priorities, but with my phone being a Nexus 6P (a.k.a. API 23). Providing permissions in the manifest.xml alone wasn’t enough and I had to add code for runtime permission request. See Android documentation for runtime permissions Add this code to your MainActiviy: ActivityCompat.requestPermissions(this, new … Read more

BroadcastReceiver not receiving download complete action

Use full package name for you receiver like com.example.DownloadListenerService Add android:exported=”true” BroadcastReceiver can receive messages from sources outside its application. Change the name of the Action in the intent-filter to android.intent.action.DOWNLOAD_COMPLETE <receiver android:name=”com.example.DownloadListenerService” android:exported=”true” > <intent-filter> <action android:name=”android.intent.action.DOWNLOAD_COMPLETE” /> </intent-filter> </receiver> <uses-permission android:name=”android.permission.INTERNET” /> The receiver only will be triggered if was registered from your … Read more

DownloadManager.ACTION_DOWNLOAD_COMPLETE broadcast receiver receiving same download id more than once with different download statuses in Android

This is a reported bug see: http://code.google.com/p/android/issues/detail?id=18462 The way around I found is to verify if the download was a success, if not ditch the intent or re-queue the file if it was never downloaded… Lost a couple of hours figuring that one 🙁 ** Edit: adding code example ** /** * Check if download … Read more