问题描述
在我的应用我想,当用户点击一个按钮,在应用程序关闭本身并自动打开添加新的widget上下文菜单。
我在做这样的:
in my application I want that when a user click a button the application closes itself and automatically opens the add new widget context Menu.I'm making this:
if (viewId == R.id.bt_homeScreen) {
finish();
try {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
startActivity(intent);
} catch (ActivityNotFoundException e) {
Toast.makeText(this.getApplicationContext(), getResources().getString(R.string.homeClientAlert), Toast.LENGTH_SHORT).show();
}
}
这蒙山code的问题是,我只能到手机的主屏幕:
The problem whith this code is that I only go to the phone Home screen:
我想,当我启动意图不言而喻到主屏幕,并打开窗口小部件的上下文菜单:
I want that when I launch the Intent it goes to the Home screen and open the widget context menu:
推荐答案
看看Commonsware的回答这个问题:Add小部件从Android应用程序主萤幕
Take a look at Commonsware's answer to this question: Add widget to homescreen from Android application
您将能够显示部件选择菜单,但你将无法处理在一个正常的应用程序,选择。这使得使用appwidget选择必须实现AppWidgetHost中的应用。主屏幕上的应用程序都属于这一类,没有正常的应用程序。
You will be able to show the widget selection menu but you won't be able to process that selection in a normal app. The application that makes use of an appwidget selection must implement an AppWidgetHost. Home screen apps fall into this category, no normal apps.
这篇关于Android的 - 意向打开窗口小部件的上下文菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!