收到短信后如何将参数发送到另一个活动我尝试但它的显示错误
Intent 类型中的方法
putExtra(String, boolean)
不适用于参数(Bundle)
下面是我的代码:
public class SmsReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent)
{
//---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 += msgs[i].getMessageBody().toString();
}
Intent l = new Intent(context,AgAppMenu.class);
Bundle bundle2 = new Bundle();
bundle.putString("msg", str);
l.putExtra(bundle);
l.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(l);
Toast.makeText(context, "SucessFull Login", Toast.LENGTH_SHORT).show();