开发者

How to start Service on click of Widget Button?

开发者 https://www.devze.com 2023-03-25 18:50 出处:网络
I am able to start Activity class on click of wid开发者_如何学Goget button, but whentry same for start service it\'s not working, let me know how can i call start service here.

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

精彩评论

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