考虑到 2 个人拥有该应用程序。当其中一个用户想知道另一个用户的位置时,他会发送一条短信(内容可以是任何内容或特定的)。现在当另一个用户收到短信时(如果可能,他不应该知道他收到了短信)。然后他的位置被发送回请求它的用户。希望解释清楚。
public void onReceive(Context context, Intent intent)
{
//this stops notifications to others
this.abortBroadcast();
//---get the SMS message passed in---
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
String str = "";
if (bundle != null)
{
//---retrieve the SMS message received---
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for (int i=0; i<msgs.length; i++){
msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
str += "SMS from " + msgs[i].getOriginatingAddress();
from = msgs[i].getOriginatingAddress();
str += " :";
str += msgs[i].getMessageBody().toString();
msg = msgs[i].getMessageBody().toString();
str += "\n";
}
if(checksomething){
//make your actions
//and no alert notification and sms not in inbox
}
else{
//continue the normal process of sms and will get alert and reaches inbox
this.clearAbortBroadcast();
}
}
我得到了这个代码......我应该在这个里面做些什么改变......?