android-broadcast

Unable to receive SMS receive broadcast on Galaxy SIII running 4.1.1

早过忘川 提交于 2019-12-04 22:27:59
I have this problem only on Samsung Galaxy SIII running Android 4.1.1. There is no problem on Samsung Galaxy Ace and Samsung Galaxy Y. The broadcast SMS received is not firing up, when SMS is received. No other SMS app is installed on the phone. I am using the following code to receive the SMS broadcast smsReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "Inside onReceive of smsReceiver"); Bundle bundle = intent.getExtras(); Object[] messages = (Object[]) bundle.get("pdus"); SmsMessage[] sms = new SmsMessage[messages.length]; //

Android , broadcasting parcelable data

感情迁移 提交于 2019-12-04 19:08:04
问题 I've implemented a class that extends NotificationListenerService which works fine for picking up on notifications posted. I'm then wanting to take the statusBarNotification object received and broadcast it. I'd doing the following: @Override public void onNotificationPosted(StatusBarNotification statusBarNotification) { Intent intent = new Intent(); intent.putExtra("STATUS_BAR_NOTIFICATION",statusBarNotification); intent.setAction("com.example.NotificationPosted"); sendBroadcast(intent); }

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"

Call broadcast receiver at time of uninstalling application in android [duplicate]

≯℡__Kan透↙ 提交于 2019-12-04 05:29:52
This question already has an answer here: Receiving package install and uninstall events 4 answers I want to clean up the junk created by my application at time on UnInstalling the Application. Using ManiFest File:- Added in Manifest File: <receiver android:name="com.netdoers.com.ui.CleanReceiver" > <intent-filter> <action android:name="android.intent.action.PACKAGE_REMOVED" > </action> <data android:scheme="package"/> </intent-filter> </receiver> Created Receiver to catch the BroadCast Event public class CleanReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent

Long running service consumes a lot of battery

老子叫甜甜 提交于 2019-12-04 03:47:48
I developed an app and some people complains that it takes too much battery, it is the second most consuming process after the screen. However, in some devices it does not consumes that much battery. All the work my app do is in a service. The service is sticky and is running all the time (the android system may kill it when has low resources or pause it when device go to sleep), it has listener to the accelerometer as long as the screen is on, it is not foreground service and does not hold wakelock. Can someone tell me why it takes a lot of battery? And why is this happening only on some of

Notification action button does not fire pending intent

邮差的信 提交于 2019-12-04 03:41:58
问题 I try to send intent to BroadcastReceiver from notification action button my problem is that when I click the button the intent in not fired or not getting to the BroadcastReceiver. Here is my code: The notification: Intent accept = new Intent(this, ChallengesActionReceiver.class); accept.setAction("com.soinfit.utilities.CHALLENGE_CLICK"); accept.putExtra("reqId", extras.getString("reqId")); accept.putExtra("answer", "1"); PendingIntent acceptIntent = PendingIntent.getActivity(this, 1, accept

Listen to location access disable/enable in settings

谁说我不能喝 提交于 2019-12-04 03:13:08
In Android OS, in " Settings " --> " Location services ", there is a toggle button named " Access to my location " which can be used to disable & enable location info access from apps. Currently, I am developing a location service application. I am wondering, how can I listen to this setting in my Android project? Is there any broadcast receiver I can use to know right away when user disable or enable " Access to my location " ? If there isn't any broadcast receiver for it, how can I listen to this change in my Android project? This works for me: Add receiver to the Manifest file: <receiver

Can you use pending intents with localbroadcasts?

南笙酒味 提交于 2019-12-03 23:24:40
I am interested in using pending intents with local broadcasts. To make myself clear, I am using the following for registering receivers and sending broadcast: android.support.v4.content.LocalBroadcastManager . I have a local broadcast receiver in a service which works. I am trying to send local broadcasts from a custom notification layout which includes click-able items. The local broadcast receiver - just receives simple action intents. I was trying something like this to no avail: Intent backintent = new Intent("GOTO_START_BROADCAST"); PendingIntent backIntent = PendingIntent.getBroadcast

Android - How to trigger a Broadcast Receiver to call its onReceive() method?

做~自己de王妃 提交于 2019-12-03 22:55:49
I have scheduled alarm for my application. I have implemented broadcast receiver to be triggered once the alarm time reaches. How to manually call broadcast receiver to execute the code inside of onReceive method without replicating the code twice. I thought of having the code in utility singleton call and call that method by having util class instance from anywhere. But is that any other way to call that onReceive method directly or else broadcast intent problematically. android:exported="false" //Additional parameter of receiver when defining in manifest file. Another question is what is

Android get current song playing and song changed events, like Musixmatch

耗尽温柔 提交于 2019-12-03 17:33:32
What i want to achieve is very similar to what Musixmatch is doing. I need to be informed when the music starts playing and when the song is changed. All this in the service because my app may be closed (even musicmatch does this). In the above case even if Musixmatch app is not running i get a notification when ever i change the song on spotify or any player. Can anyone pls tell me how to achieve this. I don't need the code help, just what to know how to achieve it. I'm really confused how Musixmatch is doing it. Here is a solution to find if music player is playing. AudioManager manager =