2013-06-25 2 views

답변

1

구체적인 방법이 있는지 알지 못하지만 방송 할 내 Intent에 특정 action을 추가합니다. 그것은 다음과 같이 수 :

Intent broadcastIntent = new Intent(MyClass.class.getName()); 
sendBroadcast(broadcastIntent); 

을 그럼 당신은 방송을 수신 할 때, 당신은 단순히 특정 동작을 확인합니다 :

@Override 
public void onReceive(Context context, Intent intent) { 
    if (intent.getAction().equals(MyClass.class.getName()) { 
     // Ignore the broadcast as it's the caller calling itself... 
    } else { 
     // Do something with the broadcast... 
    } 
} 

단지 바르지이 (할 수있는 다른 방법이있을 수 있습니다 엑스트라를 Intent에 넣은 다음 onReceive 방법으로 읽음) 이것이 발신자가 누구인지를 알 수있는 가장 간단한 방법입니다.

+0

보낸 사람의 클래스를 식별하는 의도에 추가하면 작업을 수행했습니다. 감사합니다. – Steveo