Android music player widget

↘锁芯ラ 提交于 2019-11-30 05:20:01

Added <service android:name=".MusicService" android:enabled="true" /> to the manifest!

In the onUpdate(...) method of your AppWidgetProvider, use something like this to start a service (this example associates the service to a button click event):

Intent intent = new Intent(context, MusicService.class);
PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, 0);

// Get the layout for the App Widget and attach an on-click listener to the button
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget_provider_layout);
views.setOnClickPendingIntent(R.id.button, pendingIntent);

For more info look here

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!