Answer the question
In order to leave comments, you need to log in
asynctask. getBroadcast: how to use requestCode?
Hey!
In the asynchronous class we have:
Intent sentIn = new Intent(SENT_SMS_FLAG);
//Вот тут передать id:
final PendingIntent sentPIn = PendingIntent.getBroadcast(getApplicationContext(), id, sentIn, 0);
BroadcastReceiver sentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context c, Intent in) {
//Вот тут вот как узнать id???
switch (getResultCode()) {
case Activity.RESULT_OK:
// sent SMS message successfully;
Toast toast = Toast.makeText(getApplicationContext(),"Сообщение отправлено!", Toast.LENGTH_SHORT);
toast.show();
break;
default:
// sent SMS message failed
break;
}
}
};
smsManager.sendTextMessage(f[number], null, "text", sentPIn, deliverPIn);
PendingIntent getBroadcast (Context context, int requestCode, Intent intent, int flags)
Answer the question
In order to leave comments, you need to log in
So you can shove it into the Intent to which you pass:
Intent sentIn = new Intent(SENT_SMS_FLAG);
sentIn.putExtra("REQUEST_CODE", requestCode);
final PendingIntent sentPIn = PendingIntent.getBroadcast(getApplicationContext(), id, sentIn, 0);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question