如何在Android开放的窗口小部件的应用程序? [英] how to open a application from widget in android?

查看:115
本文介绍了如何在Android开放的窗口小部件的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们单击窗口小部件在那个时候我需要打开一个活动的屏幕(或应用程序)。如何做到这一点?

when we click the widget at that time i need to open a 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);

检查了这一点

Check this out

<一个href="http://stackoverflow.com/questions/2471875/processing-more-than-one-button-click-at-android-widget">Processing多个按钮点击,在Android部件

这篇关于如何在Android开放的窗口小部件的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆