4

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:

http://cdn.androidtapp.com/wp-content/uploads/2009/02/rc33-google-voice-search-for-android-on-home-screen.jpg
(source: androidtapp.com)

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

http://www.taosoftware.co.jp/en/android/calendarwidget/img/choosewidget.png
(source: taosoftware.co.jp)

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
user1327579
  • 53
  • 1
  • 5

1 Answers1

2

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.

Community
  • 1
  • 1
Jose_GD
  • 2,279
  • 1
  • 21
  • 34