我想從BroadcastReceiver類調用推送通知後臺服務,但我的應用程序崩潰。下面的代碼給出:從BroadcastReceiver調用後臺服務
public class AlarmReceiver extends BroadcastReceiver {
static int count=1;
@Override
public void onReceive(Context context, Intent intent) {
Intent myIntent=new Intent(context,NotifyService.class);
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myIntent);
}
}
清單項:
<receiver android:name=".AlarmReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<service android:name=".NotifyService">
</service>
錯誤:
05-24 15:17:00.042: ERROR/AndroidRuntime(424): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.alarm/com.android.alarm.NotifyService}; have you declared this activity in your AndroidManifest.xml?
當我把這種服務,通過它的工作的活動,但我的目標是從BroadcastReceiver調用此服務。
哦! yaa ...感謝CommonsWare .....現在它的工作... – Andy 2010-05-25 05:18:01