2014-02-09 2 views
-1

방송 수신자가 있고 그 수신자의 방법으로 다시 방송 메시지를 보내고 있습니다.정적 방송에 오류가 발생했습니다

public static class MyBroadcastReceiver extends BroadcastReceiver 
{ 

    @Override 
    public void onReceive(Context context, Intent intent) 
    { 
     // TODO Auto-generated method stub 
     Intent intent1 = new Intent("com.test.test"); 
     sendBroadcast(intent1); 
    } 
} 

하지만 sendBroadcast

에 오류가 있습니다
cannot make a static reference to the non-static method sendbroadcast(intent) 
from the type context wrapper. 

날이 문제를 해결 도와주세요.

답변

2

사용

context.sendBroadcast(intent1); 

대신

sendBroadcast(intent1); 

sendBroadcast 때문에이 BroadcastReceiver 클래스의 방법이 아닙니다.

+0

의 구현을 위해 다음 링크를 참조해야하지만 상황이 sendbrodcast 전에 필요한 이유를 말해 answer.can 수있는 권리를 제공합니다.?. sendBroadcast는 어떤 클래스에 속합니까? –

+1

@wqrahd : [ContextWrapper] (http://developer.android.com/reference/android/content/ContextWrapper.html) 클래스 –

+0

클래스가 정적 인 경우 컨텍스트가 필요한 이유는 무엇입니까? –

-1

브로드 캐스트 리시버를 만들기 위해 잘못된 구문을 사용하고 있습니다. 먼저 java에서 정적 클래스의 의미를 이해해야합니까? Static Class

지금 당신은 내가 이미 수행 한 방송 수신기
Link 1

관련 문제