我想在单击选项菜单项时启动服务。
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
menu.add("Help").setIcon(R.drawable.HelpActivity).setIntent(new Intent(this,HelpActivity.class));//this is activity intent .It works fine
menu.add("Update Media").setIcon(R.drawable.update_icon).setIntent(new Intent(this,MediaUpdate.class));//this is service intent.It dose not works
return super.onCreateOptionsMenu(menu);
}
显现
</service>
<service android:name="com.Dexter.otp.services.MediaUpdate" >
</service>
单击更新媒体时,我收到日志错误
11-30 12:46:10.775: E/MenuItemImpl(4918): Can't find activity to handle intent; ignoring
11-30 12:46:10.775: E/MenuItemImpl(4918): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.Dexter.otp/com.Dexter.otp.services.MediaUpdate}; have you declared this activity in your AndroidManifest.xml?
似乎无法通过菜单项启动服务/广播。