开发者

How to start Service on click of Widget Button?

I am able to start Activity class on click of wid开发者_如何学Goget button, but when try same for start service it's not working, let me know how can i call start service here.

thanks


Use this line of code

startService(new Intent(this, YOUR_SERVICE_CLASS_NAME.class)); 


Try this code man

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜