我正在尝试构建一个从特定发件人那里读取 SMS 的程序。然后它将文本解析为地址。带有地址和两个按钮的弹出窗口自动出现,OK(取消弹出窗口)和 Map(将地址发送到显示地址的 MapView)。我不知道如何创建一个显示时间、地址和呼叫类型的弹出窗口。
package bkgdService;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.widget.Toast;
public class SMSReceiver extends BroadcastReceiver
{
public int calltypeIndexA;
private String time;
private String callType;
private String location;
public void onReceive(Context context, Intent intent)
{
Bundle myBundle = intent.getExtras();
SmsMessage [] messages = null;
if (myBundle != null)
{
Object [] pdus = (Object[]) myBundle.get("pdus");
messages = new SmsMessage[pdus.length];
for (int i = 0; i < messages.length; i++)
{
if (messages[i].getOriginatingAddress() == "messaging@iamresponding.com")
{
messages[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
String message = messages[i].getMessageBody();
this.time = SupportMethods.findTime(message);
this.callType = SupportMethods.findCallType(message);
}
}
//ADD POPUP
}
}
}