How would I have an activity or animation start when the users device receives an sms? I want to start/play an animation when a sms comes in while they are viewing my app. How would I go about doing that?
Asked
Active
Viewed 103 times
2 Answers
2
public class SmsReceiver extends BroadcastReceiver {
private static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(SMS_RECEIVED)) {
// here start the activity for animation or whatever you want to do
}
}
}
add this permission to your manifest
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
add the receiver under your application tag in your manifest
<receiver android:name=".SmsReceiver" >
<intent-filter android:priority="999">
<action android:name="android.provider.Telephony.SMS_RECEIVED" >
</action>
</intent-filter>
</receiver>

prvn
- 916
- 5
- 5
0
Create a BroadcastReceiver for SMS
http://developer.android.com/reference/android/content/BroadcastReceiver.html
and act accordingly
SO Example if you had used search: