Twoja aplikacja będzie musiała mieć pozwolenie na używanie dla android.permission.RECEIVE_SMS w twoim manifeście.
Gdy już to zrobisz, możesz zarejestrować odbiornik dla android.provider.Telephony.SMS_RECEIVED
.
Następnie należy utworzyć swoją receiver.
<receiver android:name=".SMSBroadcastReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
Odbiornik powinien przedłużyć BroadcastReceiver oraz w metodzie onReceive() po odebraniu intencję dla android.provider.Telephony.SMS_RECEIVED_ACTION
chcesz pobierać wiadomości i określić, czy jest taki, który chcesz zwrócić uwagę.
Twój kod może wyglądać mniej więcej tak.
public class SMSBroadcastReceiver extends BroadcastReceiver {
private static final String TAG = "SMSBroadcastReceiver";
private static final String SMS_RECEIVED_ACTION = "android.provider.Telephony.SMS_RECEIVED"
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(SMS_RECEIVED)) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
Object[] pdus = (Object[]) bundle.get("pdus");
final SmsMessage[] messages = new SmsMessage[pdus.length];
for (int i = 0; i < pdus.length; i++) {
messages[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
}
if (messages.length > -1) {
//You have messages, do something with them here to determine if you want to look at them and other actions.
}
}
}
}
}
http://stackoverflow.com/questions/11872320/auto-launching-android-app-after-install – KOTIOS
jest aplikacja w Google Play [Android] (https://play.google utracony. com/store/apps/details? id = com.androidlost & hl = en), które wywołują usługę rejestracji wiadomości google push za pośrednictwem przychodzącego SMS-a bez uruchamiania aplikacji nawet raz dla wersji 3.0+ – test