Example usage for android.view Menu addIntentOptions

List of usage examples for android.view Menu addIntentOptions

Introduction

In this page you can find the example usage for android.view Menu addIntentOptions.

Prototype

public int addIntentOptions(int groupId, int itemId, int order, ComponentName caller, Intent[] specifics,
        Intent intent, int flags, MenuItem[] outSpecificItems);

Source Link

Document

Add a group of menu items corresponding to actions that can be performed for a particular Intent.

Usage

From source file:net.dahanne.spring.android.ch3.restful.example.recipeapp.RecipesList.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate menu from XML resource
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.list_options_menu, menu);

    Intent intent = new Intent(null, getIntent().getData());
    intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
    menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE, 0, 0, new ComponentName(this, RecipesList.class), null,
            intent, 0, null);//from ww w . ja va2s.  c  o m

    return super.onCreateOptionsMenu(menu);
}

From source file:com.google.android.demos.rss.app.ChannelActivity.java

private void addAlternativeOptionsMenuItems(Menu menu) {
    int groupId = MENU_GROUP_INTENT_OPTIONS;
    int itemId = Menu.NONE;
    int order = Menu.NONE;
    ComponentName caller = getComponentName();
    Intent[] specifics = null;//from   ww w .j a  v a  2s  .  co  m
    Intent intent = new Intent();
    intent.setData(getIntent().getData());
    intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
    int flags = 0;
    MenuItem[] outSpecificItems = null;
    menu.addIntentOptions(groupId, itemId, order, caller, specifics, intent, flags, outSpecificItems);
}

From source file:com.google.android.demos.jamendo.app.PlaylistActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    int groupId = MENU_GROUP_INTENT_OPTIONS;
    int itemId = Menu.NONE;
    int order = Menu.NONE;
    ComponentName caller = getComponentName();
    Intent[] specifics = null;/*  w w w .j  av  a  2  s .c om*/
    Intent intent = new Intent();
    long id = ContentUris.parseId(getIntent().getData());
    intent.setDataAndType(JamendoContract.createPlaylistUri(JamendoContract.FORMAT_M3U, Playlists.ID, id),
            JamendoContract.CONTENT_TYPE_M3U);
    intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
    int flags = 0;
    MenuItem[] outSpecificItems = null;
    menu.addIntentOptions(groupId, itemId, order, caller, specifics, intent, flags, outSpecificItems);
    return menu.hasVisibleItems();
}

From source file:com.google.android.demos.jamendo.app.AlbumActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    int groupId = MENU_GROUP_INTENT_OPTIONS;
    int itemId = Menu.NONE;
    int order = Menu.NONE;
    ComponentName caller = getComponentName();
    Intent[] specifics = null;/*from   www.ja v  a  2s . co  m*/
    Intent intent = new Intent();
    long id = ContentUris.parseId(getIntent().getData());
    intent.setDataAndType(JamendoContract.createPlaylistUri(JamendoContract.FORMAT_M3U, Albums.ID, id),
            JamendoContract.CONTENT_TYPE_M3U);
    intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
    int flags = 0;
    MenuItem[] outSpecificItems = null;
    menu.addIntentOptions(groupId, itemId, order, caller, specifics, intent, flags, outSpecificItems);
    return menu.hasVisibleItems();
}

From source file:com.example.android.notepad.NotesList.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    // This is our one standard application action -- inserting a
    // new note into the list.
    menu.add(0, MENU_ITEM_INSERT, 0, R.string.menu_insert).setShortcut('3', 'a')
            .setIcon(android.R.drawable.ic_menu_add);

    // ilya: add refresh
    menu.add(0, MENU_ITEM_REFRESH, 0, "Refresh").setShortcut('4', 'r').setIcon(android.R.drawable.ic_menu_view);

    // Generate any additional actions that can be performed on the
    // overall list.  In a normal install, there are no additional
    // actions found here, but this allows other applications to extend
    // our menu with their own actions.
    Intent intent = new Intent(null, getIntent().getData());
    intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
    menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE, 0, 0, new ComponentName(this, NotesList.class), null,
            intent, 0, null);//from   w w  w .ja v  a 2s  .  c  o m

    return true;
}

From source file:net.lp.actionbarpoirot.actions.UiActionManager.java

/**
 * For onCreateOptionsMenu, generate the category-alternative intent-based items.
 * /*from w  w w  .  jav  a2 s  .c  o m*/
 * @param menu
 * @param context
 * @param uri
 * @param component
 * @param extraCategories
 */
public void onCreateAlternativeOptionsMenu(Menu menu, C context, Uri uri, Class<? extends C> component,
        List<String> extraCategories) {
    // Generate any additional actions that can be performed on the
    // overall list. In a normal install, there are no additional
    // actions found here, but this allows other applications to extend
    // our menu with their own actions.
    Intent intent = new Intent(null, uri);
    intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
    if (extraCategories != null) {
        for (String extraCategory : extraCategories) {
            intent.addCategory(extraCategory);
        }
    }
    menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE, 0, UiAction.ORDER_SIXTH_OR_ALTERNATIVE,
            new ComponentName(context, component), null, intent, 0, null);
}

From source file:com.example.android.notepad.NotesList.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    //final boolean haveItems = getListAdapter().getCount() > 0;
    boolean haveItems = true;

    // If there are any notes in the list (which implies that one of
    // them is selected), then we need to generate the actions that
    // can be performed on the current selection.  This will be a combination
    // of our own specific actions along with any extensions that can be
    // found./*from  w w w  .  j  a  v a 2 s  .com*/
    if (haveItems) {
        // This is the selected item.
        Uri uri = ContentUris.withAppendedId(getIntent().getData(), getSelectedItemId());

        // Build menu...  always starts with the EDIT action...
        Intent[] specifics = new Intent[1];
        specifics[0] = new Intent(Intent.ACTION_EDIT, uri);
        MenuItem[] items = new MenuItem[1];

        // ... is followed by whatever other actions are available...
        Intent intent = new Intent(null, uri);
        intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
        menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE, 0, 0, null, specifics, intent, 0, items);

        // Give a shortcut to the edit action.
        if (items[0] != null) {
            items[0].setShortcut('1', 'e');
        }
    } else {
        menu.removeGroup(Menu.CATEGORY_ALTERNATIVE);
    }

    return true;
}