Reputation: 841
i'm using the code
private void sendSms(String phoneNo, String message){
PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(this, MainScreen.class), 0);
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNo, null, message, pi, null);
}
i have utilized the onSaveInstanceState to save values such as text and spinner position, which will keep things saved and consistent while receiving intents, navigating away from the activity, etc
not sure if i can put extras in the pending intent, so that when it starts my main activity, i can use those extras. because somehow, when the pending intent goes through, i need it to restore to the way it was before the intent was called
Upvotes: 0
Views: 1522
Reputation: 11844
You can.. but you must clear the previous pending intent or use the one shot flag while constructing your pending intent.. like this
Intent sentIntent = new Intent(SENT_SMS_ACTION);
sentIntent.putExtra(MESSAGE_ID_TAG, messageId);
PendingIntent sentPendingIntent = PendingIntent.getBroadcast(this, 0, sentIntent, PendingIntent.FLAG_ONE_SHOT);
Upvotes: 3