I have an application with a broadcast receiver, and I'm trying to figure out how to receive the broadcast of when an app from the Market is purchased and/or installed. Is this possible?
I've tried setting a receiver for android.Intent.ACTION_PACKAGE_ADDED and com.android.vending.billing.PURCHASE_STATE etc.
There isn't a way of receiving a broadcast intent on purchase/install of the application. From what I recall reading about this in the past, is that it's a security concern.
From the API, it even states that a new application won't receive the ACTION_PACKAGE_ADDED broadcast intent. PURCHASE_STATE is also irrelevant since the app isn't installed yet at purchase time.
Related
I know broadcast receiver wont work when app is killed in oreo, but i want to get sms data when app is killed. How do i do that? Is there any way to achieve this?
Oreo has been a sort of headache.
On Oreo, you can receive broadcast receiver for sms even if application isn't on memory as you mentioned it by 'killed'.
As you said, from android oreo, the broadcast receiver can't receive implicit intent even if it is defined on android manifest.
But sms receive is a whitelisted so you can receive it even if you application isn't on memory.
Please check below link.
https://developer.android.com/guide/components/broadcast-exceptions
I want to know all broadcast message that occur at Android system or third-party application.
Broadcast messages that occur at Android system are so easy to know because make broadcast receiver, add intent-filter(all broadcast action) and receive :).
But messages that occur at third-party application are difficult to know because i don't know there broadcast message action :(
How to receive broadcast intent at third-party application?
There is no way to indiscriminately register for any broadcast event, but you can list all historical broadcasts and registered broadcast receivers with the following terminal command:
dumpsys activity broadcasts
Essentially, you would receive only those broadcasts for which you have registered. It is not feasible/possible to receive all the broadcasts. In fact, if it is somehow possible, it would be a HUGE security breach !!!
I understoo from docs that
As of Android 3.1 the Android system will by default exclude all
BroadcastReceiver from receiving Intents if the corresponding
application has never been started by the user or if the user
explicitly stopped the application via the Android menu (in Manage
Application).
Thus, I wonder how could I send send Broadcast to Receiver if my app have not been started yet.
Thus, I wonder how could I send send Broadcast to Receiver if my app have not been started yet.
I am going to take you literally, meaning that you want to send a broadcast Intent to some BroadcastReceiver that you wrote.
If the sender and the BroadcastReceiver are in the same app, there is no problem: if the sender is capable of running, it is capable of sending the broadcast. That's because the user will have had to do something to run the sender, such as starting an activity.
If the sender and the BroadcastReceiver are in different apps, my understanding is that the sender can include FLAG_INCLUDE_STOPPED_PACKAGES on the Intent and that will make sure that the BroadcastReceiver in the other app can receive the broadcast.
I'm currently working on a project where I analyze the SMS_RECEIVED-Flow.
According to the article [1] I simulated the SMS_RECEIVED-Broadcast with an explicit call to the service: com.android.mms.transaction.SmsReceiverService.
The problem is, that the Android-Emulator and my Nexus do forward
the generated BroadcastReceiver to the default SMS-App only and I do not know why.
I tried to catch the Broadcast with an statically registered receiver in another App and with an dynamically registered receiver (all receiver registered with the highest priority and the correct intent-filter). Both methods work fine with a normal SMS, but not with my simulated one.
So the question is, does anybody know how the SMS-Receive mechanism work and why my program won't receive any broadcasts.
[1] http://blog.dev001.net/post/14085892020/android-generate-incoming-sms-from-within-your-app
SmsRecieverService is part of default messaging app, so if you explicitly call this service, the broadcast will reach only that app. Since the SMS_RECIEVED broadcast is a protected broadcast , your app cannot broadcast it.
One way is to change the name of the broadcast in both simulator and your app.
I have a question about BroadcastReceiver in Android, say, about system broadcast receiver BOOT_COMPLETED. If I have written a listener to Broadcast after system is booted and installed it. How the android system would know that it has to notify my application, since my application is not running but just installed? Is it that, all BroadcastReceiver derived classes are always in the memory (or system loads them in the memory after bootup) and whenever any broadcast happens, all relevant application can receive it.
Thanks
Braj
When the broadcast BOOT_COMPLETED is sent, the Android system checks the manifests of loaded apps to see if anything is meant to handle that message. The same is true for implicit intents, and all broadcasts.
Manifests are public facing and allows the system to know what your app can and will do.