当前位置: 代码迷 >> Android >> android widget 中怎么调用系统Intent
  详细解决方案

android widget 中怎么调用系统Intent

热度:242   发布时间:2016-05-01 10:18:05.0
android widget 中如何调用系统Intent
如题,在widget开发中,我想调用系统播放器,不知道该怎么实现,有知道的情告诉下。

------解决方案--------------------
引用:
Quote: 引用:

http://blog.csdn.net/yudajun/article/details/7752226

谢谢你的回答,不过这是在activity中启动的,我要的是在widget中启动的。

public class ExampleAppWidgetProvider extends AppWidgetProvider {

    public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
        final int N = appWidgetIds.length;

        // Perform this loop procedure for each App Widget that belongs to this provider
        for (int i=0; i<N; i++) {
            int appWidgetId = appWidgetIds[i];

            // Create an Intent to launch ExampleActivity
            Intent intent = new Intent(context, ExampleActivity.class);
            PendingIntent pendingIntent = PendingIntent.getActivity(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);

            // Tell the AppWidgetManager to perform an update on the current App Widget
            appWidgetManager.updateAppWidget(appWidgetId, views);
  相关解决方案