브로드 캐스트 리시버를 작동 시키려고합니다. 가능한 한 단순해야, 나는이처럼 내 매니페스트이 있습니다Android 브로드 캐스트 리시버가 작동하지 않습니다.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mytest.intentRec" android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="true">
<activity android:name=".mainAct" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.mytest.intentRec.MyIntentRec"
android:enabled="true" >
</receiver>
</application>
<uses-sdk android:minSdkVersion="7" />
</manifest>
내가이 주요 활동을 mainAct이 볼 수 있듯이,이 한 번 시작 브로드 캐스트 전송을 제외한 아무것도하지 않는다 :
public class mainAct extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.sendBroadcast(new Intent());
}
}
및 나는 그것이 수만큼 간단 클래스 MyIntentRec을 가지고 :
public class MyIntentRec extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.v("IntentRec", "got it");
}
}
내가 기대하는 것은 그 나는 방송이 전송되고 포착되고 및 로그 항목이 writte 것을 내 응용 프로그램을 시작할 때 엔. 로그 항목이 표시되지 않으며 오류가 표시되지 않습니다. 매니 페스트에 오류가 있거나 브로드 캐스트를 보내는 중입니다. 방금 빈 의도를 만들었습니다. 특정 속성에 대한 의도가 필요합니까?
이것은 잘 동작한다. 그러나 위의 의견에 게시 된대로. 의도 필터가 필요하지 않습니다. 의도 필터없이 어떻게해야합니까? – AndyAndroid