我想开始从弹出的对话框中后台服务,它只是不工作对我来说开始从对话框中的Android
这是打开的对话框中的代码服务:
reportWrongLang.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
FragmentManager fm = getFragmentManager();
ReportWrongLangDialog Dialog = new ReportWrongLangDialog(imageInfo.getParam("imageId")[0], getApplicationContext());
Dialog.show(fm, "are_you_sure_dialog");
}
在ReportWrongLangDialog我很节省appContext,以及图像标识
,并在对话框中按下
报告按钮,我想启动后台服务,将有关图像的报表时
为的onClick
report.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
System.out.println("got imageid: " + imageId);
Intent intent = new Intent(appContext, ReportImageService.class);
intent.putExtra("ReportType", "IMAGE_REPORT");
intent.putExtra("ImageID", imageId);
intent.putExtra("Extra", "2");
appContext.startService(intent);
System.out.println("after service start");
}
});
的代码,其中ReportImageService.class是,我想启动该服务。 当我按下报表按钮什么也没有发生..
什么可以是问题?我只能假设应用程序上下文有问题
是否永远不会调用点击函数,或者是不会调用服务的startCommand/onCreate?如果第二个,你是如何确定的? – 2013-03-20 19:47:01
的的onClick函数被调用 - 我可以看到,通过syso消息 启动命令从未发生过: 公共ReportImageService(){ \t \t超( “reportimageservice”); \t \t System.out.println(“in report service constraintctor”); \t} \t @覆盖 \t保护无效onHandleIntent(意向意图){ \t \t的System.out.println( “报告服务”); } 没有syso在任何时间 – 2013-03-20 19:52:07
你忘了在清单中声明你的服务吗? – 2013-03-20 20:09:22