2012-09-11 5 views
1

나는 그런 메시지 응용 프로그램 설정하려고에 PendingIntent를 사용하는 방법 :브로드 캐스트 리시버

  1. 먼저 우리가 PreferenceConnector에 메시지를 설정하고 우리는 다음 메시지가 있음을 확인 브로드 캐스트 리시버
  2. 을 메시지가 나타납니다 내용이 동등한 경우
  3. 나는 PendingIntent를 얻고 싶습니다.
 
try { 
     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); 
     } else { 
      Toast.makeText(Remotelock.this, "message are not equal!", Toast.LENGTH_LONG).show(); 
     } 
     catch (Exception e) { 
     // TODO: handle exception 
      e.printStackTrace(); 
     } 
+0

매우 간단하다. – Peter

답변

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(); 
    } 
관련 문제