보내는 모든 SMS (또는 부분 SMS)에 대해 PendingIntent를 제공합니다. 이 PendingIntent에는 SMS (또는 부분)가 성공적으로 보내지거나받을 때 받게 될 Intent를 넣었습니다. 이 인 텐트에서는 추가 정보를 사용하여 추가 정보를 입력 할 수 있습니다. 메시지를 보낼 때, 예를 들어, 코드는 ... 다음과 같을 수
String receiverCodeForThisMessage = "STRING_CODE_FOR_MY_SMS_OUTCOME_RECEIVER";
int uniqueCodeForThisPartOfThisSMS = 100*numberSMSsentSoFar+PartNumberOfThisSMSpart;
Intent intent = new Intent(receiverCodeForThisMessage);
intent.putExtra("TagIdentifyIngPieceOfInformationOne", piece1);
intent.putExtra("TagIdentifyIngPieceOfInformationTwo", piece2);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, uniqueCodeForThisPartOfThisSMS, intent, 0);
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage("phonenumber", "Fred Bloggs", "Hello!", pendingIntent, null);
하지만 그 전에, 당신은 결과와 사용자가 설정 의도를 얻을 것이다 수신기를 등록합니다
; 그 의도에서 당신은 정보 조각을 추출합니다 :
registerReceiver(new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent) {
// Get information about this message
int piece1 = intent.getIntExtra("TagIdentifyIngPieceOfInformationOne", -1);
int piece2 = intent.getIntExtra("TagIdentifyIngPieceOfInformationTwo", -1);
if (getResultCode() == Activity.RESULT_OK) {
// success code
}
else {
// failure code
}
}, new IntentFilter(receiverCodeForThisMessage));
그럼 당신의 아이디어는 좋아 보인다. ID 추가를 시도 했습니까? – keyser