【发布时间】:2011-08-02 09:13:04
【问题描述】:
我可以在单击小部件按钮时启动 Activity 类,但是当尝试相同的启动服务时它不起作用,请告诉我如何在这里调用启动服务。
谢谢
【问题讨论】:
我可以在单击小部件按钮时启动 Activity 类,但是当尝试相同的启动服务时它不起作用,请告诉我如何在这里调用启动服务。
谢谢
【问题讨论】:
使用这行代码
startService(new Intent(this, YOUR_SERVICE_CLASS_NAME.class));
【讨论】:
试试这个代码人
Intent i = new Intent(this, MyWidget.class);
PendingIntent pi = PendingIntent.getBroadcast(context,0, i,0);
RemoteViews updateView = new RemoteViews(context.getPackageName(),R.layout.n);
updateViews.setOnClickPendingIntent(R.id.update_button,pi);
【讨论】: