如何从Android中的小部件打开应用程序? [英] How to open an application from widget in Android?
本文介绍了如何从Android中的小部件打开应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我们单击窗口小部件时,我需要打开一个活动屏幕(或应用程序).该怎么做?
When we click the widget at that time I need to open an activity screen (or application). How to do this?
推荐答案
您需要在窗口小部件上设置onClickpendingIntent
You need to set an onClickpendingIntent on your widget
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);
检查一下
这篇关于如何从Android中的小部件打开应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文