2011-10-04 14 views

答えて

1

解決策が見つかりました。 BroadcastReceiver

`

public void onReceive(Context context, Intent intent) 
{ 
    //---get the SMS message passed in--- 
    Bundle bundle = intent.getExtras(); 
    if (bundle != null) 
    { 

    //---retrieve the SMS message received--- 
    Object[] pdus = (Object[]) bundle.get("pdus"); 
    msgs = SmsMessage.createFromPdu((byte[])pdus[0]); 
    Log.i(TAG, msgs.getMessageBody()); 
    Intent intent2 = new Intent("com.uba.messagereceived"); 
    str = "SMS From "+msgs.getOriginatingAddress()+":"+msgs.getMessageBody().toString()+"..."; 
    intent2.putExtra("letter", str); 
    intent2.putExtra("address", msgs.getOriginatingAddress()); 
    intent2.putExtra("txt", msgs.getMessageBody().toString()); 
    context.sendBroadcast(intent2); 

    } 
    //---display the new SMS message--- 
    Toast.makeText(context, str, Toast.LENGTH_SHORT).show(); 

if(yMsg == msgg && xNum == no) 
    { 
    setStatus("valid"); 
    Intent mp = new Intent(context,UserMainPage.class); 
    context.startActivity(mp); 
    Toast.makeText(context,"The Validation completed: "+this.getStatus(), Toast.LENGTH_SHORT).show(); 
    } 

else 
    { 
    setStatus("not Valid"); 
    Toast.makeText(context,"The Validation completed: "+this.getStatus(), Toast.LENGTH_SHORT).show(); 
    } 

    } 

`

のonReceive方法を用い
関連する問題