1

我正在尝试设置一个消息应用程序,以便:

  1. 首先我们在 PreferenceConnector 上设置一条消息,然后我们收到消息
  2. BroadcastReceiver 检查消息内容是否相等
  3. 我想获得一个 PendingIntent。
尝试 {
        if (PreferenceConnector.readString(context,"MSG","tempmsg2").equals(messages[0].getMessageBody())) {
            Intent i=new Intent(context, SecureMobiActivity.class);                 
            PendingIntent pi=PendingIntent.getBroadcast(context, 0, i, 0);
        } 别的 {
            Toast.makeText(Remotelock.this, "消息不相等!", Toast.LENGTH_LONG).show();
        }
        捕获(异常 e){
        // TODO: 处理异常
            e.printStackTrace();
        }
4

1 回答 1

0

它的答案很简单

try {
    if (PreferenceConnector.readString(context,"MSG","tempmsg2").equals(messages[0].getMessageBody())) {
        Intent i = new Intent(mContext,SecureMobiActivity.class);
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mContext.startActivity(i);
    } else {
        Toast.makeText(Remotelock.this, "message are not equal!", Toast.LENGTH_LONG).show();
    }
    catch (Exception e) {
    // TODO: handle exception
        e.printStackTrace();
    }
于 2012-09-12T08:05:15.950 回答