繁体   English   中英

如何在我的应用程序的小部件菜单中添加我的应用程序的快捷方式

[英]How to add short cut of my app in my app's widget menu

我想将应用程序的快捷方式添加到应用程序的小部件菜单中。 怎么添加呢? 我找不到解决方案,也许我的搜索键是错误的。 谁能帮我?

为了将单击侦听器绑定到窗口小部件标题上显示的任何图标,可以通过以下步骤进行操作:

将这些代码添加到窗口小部件提供程序的onUpdate()方法中:

// Create an intent
Intent openMyAppIntent= new Intent(context, ActivityToBeOpened.class);

// Create pending intent with intent created above
PendingIntent openMyAppPendingIntent= PendingIntent.getActivity(context, 1, openMyAppIntent, 0);

// Bind pending intent with your remote view OnClickPendingIntent method
remoteView.setOnClickPendingIntent(R.id.app_icon_on_widget, openMyAppPendingIntent);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM