This question already has answers here:
SMS Broadcastreceiver not called when GO SMS Pro installed
(2 answers)
Closed 9 years ago.
I have implemented an SMS receiver which intercepts incoming SMS messages without any issues. However, when I install GO SMS Pro and set "Disable other message notification", then my app does not receive any broadcast message even though I have set the priority on intent filter very high. Is there a way to overcome so that my app always receive a SMS broadcast irrespective of what user does on Go SMS Pro's app, especially since my app does not show any UI pop-up notification? As soon as I uninstall GO SMS Pro, my app starts getting incoming SMS broadcasts and works fine.
Here is the log when an incoming SMS is received and GO SMS Pro is installed. There is some magic done by GO SMS Pro which I don't understand. Can someone explain what is done here and how can I make sure my app does get ordered broadcast notification every time.
add following code in your manifest in broadcast receiver declaration
<receiver
android:name="com.application.reciever.SMSReceiver"
class="com.application.reciever.SMSReceiver" android:exported="true">
<intent-filter android:priority="999" >
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
"The value must be an integer, such as "100". Higher numbers have a higher priority."
Hope it will help you.
GO SMS have set their on absolute maximum of 2147483647 (2^31-1). So if you set it same priority then in that case Android OS will pass broadcast to older app i.e (first installed app) would get the notification.If Go SMS Pro is installed prior to your app you should warn your users about the situation. They could configure Go SMS Pro differently or uninstall it and then re install it again so your app can work too.
<receiver android:name=".SMSReceiver" >
<intent-filter android:priority="2147483647">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
Then in SMSReceiver onReceive() you need to add abortBroadcast() to abort any further Broadcasts
public void onReceive(Context context, Intent intent) {
abortBroadcast();
}
Related
How chat apps (e. g. Messenger) listen to incoming messages even if their activity haven't been started yet since in android 3.1 and later this is not possible:
Manifest:
<service android:name=".ManagerService" android:enabled="true" />
<receiver
android:name=".BootFinishedReceiver"
android:directBootAware="true"
android:enabled="true"
android:exported="false"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
Receiver:
public class BootFinishedReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Intent serviceIntent = new Intent(context, ManagerService.class);
context.startService(serviceIntent);
}
}
There have to be some way around as chat apps are still working this way.
Thanks for any informations or ideas
Your question is quite open-ended and broad. But to the link that you have pointed about the broadcast receiver when the app is not running.
There is a comment on the same answer that says:
Applications are in a stopped state when they are first installed but are not yet launched and when they are manually stopped by the user (in Manage Applications). That means, the user should launch the app at least once after installation to activate the application, then the app can receive all implicit broadcast from OS as normal.
The app is stopped when it is just installed. As soon as you launch the app for the first time, The application can listen to broadcast receivers and can run background services even when the app is closed.
The chat applications basically implement socket.io that keeps up the communication on both ends. Furthermore, you may implement FCM to get notifications and messages even when the app is killed.
I hope you, understand the concept :).
I am trying to receive SMS from my android app. I have following receiver specified in my manifest.
<receiver android:exported="true" android:name="com.lahiruchandima.myapp.SMSReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
SMSReceiver successfully receives SMS if my app is installed and opened once (app does not need to be running at the moment the SMS is received to the device). But, if i do not open my app at least once after a fresh install, it doesn't receive any SMS.
Does anybody know a way to make it possible to receive SMS without opening the app at least once?
Does anybody know a way to make it possible to receive SMS without opening the app at least once?
It can't be done, on newer Android versions at least. Ever since Android 3.1, apps are installed in a stopped state, and require that the user open it at least once before components like your BroadcastReceiver can function. This is for security reasons, to prevent, or at least hamper, malicious program behavior.
i want to receive sms in my app, but if there is any other app is receiving sms as well , sms will go to that app and i cant do anything with it .
i want to receive sms first in my app
enter code here<receiver android:name="pk.wisesolutions.smsmanager.activity.IncomingMessage" >
<intent-filter android:priority="999" >
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
SMS functionality has changed as of KitKat (version 4.4, API Level 19).
i want to receive sms in my app
This is still possible, if your app has the RECEIVE_SMS permission, and has an appropriately configured BroadcastReceiver.
if there is any other app is receiving sms as well , sms will go to that app and i cant do anything with it .
The concept of a default SMS app was introduced with KitKat. The app chosen as the default SMS app listens for the SMS_DELIVER action broadcast, and is responsible for handling the appropriate notifications and Provider writes. Only the default app has control over messages being written to the Provider.
The SMS_RECEIVED action is still broadcast, but it cannot be aborted. This means that your app can still listen for and retrieve incoming SMS messages, but it cannot stop other apps from doing so as well, and vice versa. Though the maximum practical priority you can set for your Receiver is 999, it is rather irrelevant, in this case, because abortBroadcast() will not work, and any app listening for the SMS_RECEIVED broadcast will still get it. If your app is not receiving and handling this broadcast, there are other things going on.
I have written an app which receives incoming SMSes, saves it and displays it to the users. Suddenly my app stopped receiving SMS due to Samsung's ChatOn app update.
Here is the my Manifest.xml:
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<receiver android:name="com.myapp.sms.service.SMSReceiver"
android:permission="android.permission.BROADCAST_SMS" android:exported="true">
<intent-filter android:priority="999">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
I had this issue earlier with Hangout which started supporting SMS. So, at that time I added priority to 999 (max value) in manifest file. And this worked.
But after recent update of ChatOn app, my app stopped receiving SMS. Please tell me how can I overcome with this.
For work around, I unchecked SMS option on ChatOn app.
Any help is appreciated.
There is no guaranteed way that your app can get "first crack" at SMS messages, on Android 4.3 and below. Even if you set your app to be the highest possible priority, other apps can do the same. GoSMS notably does this, and you have indicated that ChatOn does as well. If they get the message first and abort the broadcast, you will not receive the message.
There is nothing that you can do, other than to detect this possibility (using PackageManager) and alert users as to the potential behavior.
Note that on Android 4.4, this is a lot different:
The broadcast can no longer be aborted
There are separate broadcasts for apps that are monitoring SMS and the actual final SMS client app
If i'm developing an alternative Android SMS application, is there any way to replace the default sms application with my, so that my app receives the incoming sms message?
you just have to set a higher priority for your broadcast receiver like this. For example 100
<intent-filter android:priority="100">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
Then you have to call abortBroadcast(); when you want it to stop if you dont want it to propagate. This only works for orderedbroadcasts.
You cannot enforce your app on the users. As Corey mentioned users will have to switch off sms notifications in the default app to not getting the notification twice.