Android - Intent that open widget context menu

一世执手 提交于 2019-12-10 15:40:18

问题


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();
        }
    }

The problem whith this code is that I only go to the phone Home screen:


(source: androidtapp.com)

I want that when I launch the Intent it goes to the Home screen and open the widget context menu:


(source: taosoftware.co.jp)


回答1:


Take a look at Commonsware's answer to this question: Add widget to homescreen from Android application

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.



来源:https://stackoverflow.com/questions/10113645/android-intent-that-open-widget-context-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!