내 매니페스트 파일에 활동 및 브로드 캐스트 리시버를 선언했지만 별도의 공용 클래스로 내 활동에 onReceive()
코드가 있습니다. adb 명령 줄에서 브로드 캐스트를 트리거하려고하면 classnotfound
오류가 발생합니다.브로드 캐스트 리시버를 별도의 파일로 만들어야합니까?
제 질문은 broadcastreceiver
을 별도의 파일로 별도의 클래스로 만들어야합니까?
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityAsDialogActivity.this.requestWindowFeature(Window.FEATURE_NO_TITLE);
:
:
}
public class TestEmail extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(MYINTENT)){
Log.d("Manju ==>","ActivityAsDialogActivity, Got the intent"+MYINTENT);
Toast.makeText(context, "Don't panik but your time is up!!!!.",
Toast.LENGTH_LONG).show();
}//end of if statment
}//end of onReceiver
}//end of Broadcast
}//end of class ActivityAsDialogActivity
아래 매니페스트 파일을
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mot.activityasdialog"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".ActivityAsDialogActivity"
android:excludeFromRecents="true"
android:theme="@style/EmptyActivity"
android:configChanges="keyboardHidden|orientation|screenSize|uiMode">
<!-- android:theme="@android:style/Theme.Holo.Dialog"
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.mot.activityasdialog.ActivityAsDialogActivity.TestEmail" android:enabled="true">
<intent-filter>
<action android:name="com.mot.MANJU"></action>
</intent-filter>
</receiver>
</application>
</manifest>
그리고 그들이 그 (것)들에 대하여 논평 할 것을 돕지 않은 경우에. –