1

different android devices will occasionally have different onscreen features (such as the buttons at the bottom of the screen in kindle fire apps). How can you change the behavior of these kind of buttons? I can't find any resources on doing such a thing..

** EDIT **

I found out that what I referred to as the "bottom buttons" is more appropriately called the Options Bar per some Kindle Fire documentation from Amazon

** EDIT **

Considering both answers say that this isn't possible, I decided it's time for an example. It looks like the menu I want to make is actually part of the application, but has a button listener for those system buttons. How do I go about finding example code for using those buttons?

Pulse app screenshot kindle fire

Jacksonkr
  • 31,583
  • 39
  • 180
  • 284

3 Answers3

2

How can you change the behavior of these kind of buttons?

You ask the manufacturer of the device in question how to modify things that they did that lie outside of the Android SDK. The odds are very good that the answer is "you can't".

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • There's apps out there already that have made these kinds of adjustments to the "options bar" on the Kindle Fire (I'm not at work or I would send you names). I've submitted two emails to amazon's KF development team. On the first reply they sent me on a wild goose chase. Hopefully the second response will be more helpful, but we'll see! – Jacksonkr Dec 12 '11 at 00:41
  • @Jackson: It's conceivable that those apps did things that lie outside of the Fire's explicit support. Since Amazon curates the AppStore, one assumes it's at least OK to modify them, but "OK" and "willing to help you do it" are two different things. :-) That being said, my answer was more for your general question -- there's no single way to find out how to do things that lie outside the SDK on specific types of hardware. – CommonsWare Dec 12 '11 at 00:45
  • There are two buttons in the `Options Bar` that do nothing by default (one looks like a print while the other is for in-app searches). They are just asking to be given some functionality by development. I too am at a loss for why the documentation is non-existent for making modifications to the `Options Bar`. In the meantime I'm going to continue following your advice by seeking advice from Amazon. – Jacksonkr Dec 12 '11 at 00:57
  • I recently added an edit that will likely make more sense if you have moment to look at it. Thanks! – Jacksonkr Feb 27 '12 at 15:50
  • @Jackson: Those are HOME, BACK, and MENU, respectively, from left to right. You would "listen" for them the same way on the Fire as you would on any Android device. Usually, the right answer is to simply leave them alone and use the built-in facilities for them (e.g., `onCreateOptionsMenu()` for defining what appears when MENU is pressed). – CommonsWare Feb 27 '12 at 19:38
1

How can you change the behavior of these kind of buttons?

behavior? You cant change behavior of 3rd party apps buttons that placed at the bottom of kindle fire (Its just OptionsMenu, and called by pressing "Menu" button on other android based devices)

You can disable these buttons - Home, Back and other stuff... (but not on kindle)

Kindle Fire does not support apps that contain disable_keyguard permissions or customize the lockscreen.

https://developer.amazon.com/help/faq.html#KindleFire

Galymzhan Sh
  • 119
  • 11
1

here it is: (java)

package com.wali.jackonsoptionsmenu;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;

public class JacksonsOptionsMenuActivity extends Activity {
private final static String TAG = JacksonsOptionsMenuActivity.class
        .getSimpleName();

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
}

// this one is called once before showing OptionsMenu
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    Log.d(TAG,
            "onCreateOptionsMenu: called once, while creating options menu");
    getMenuInflater().inflate(R.menu.jackonsmenu, menu); // this one
                                                            // inflates your
                                                            // xml based
                                                            // menu into
                                                            // memory and
                                                            // sets to menu,
                                                            // from
                                                            // 'R.menu.jacksonsmenu
                                                            // to 'menu'
    return true; // if You want to handle bottom bar menu (OptionsMenu) you
                    // have to return 'true'
}

// this one is called everytime, but before showing the menu
// if You want to change button name, icon or other stuff, do it here
// its something like preparing
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    Log.d(TAG,
            "onPrepareOptionsMenu: called everytime before showing the OptionsMenu");

    return true;
}

// this one is called everytime, after the OptionsMenu is shown
// this one comes, if everything is ok in Your implementation, otherwise,
// nothing
@Override
public boolean onMenuOpened(int featureId, Menu menu) {
    Log.d(TAG, "onMenuÖpened: called everytime after the OptionsMenu shown");

    return true;
}

// this on is called when an item selected try item.getItemId()
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Log.d(TAG, "onOptionsItemSelected: called when an item selected");

    switch (item.getItemId()) {
    case R.id.menuRefreshAll:
        Log.i(TAG, "onOptionsItemSelected: refreshing everything");
        break;

    case R.id.menuManageSources:
        Log.i(TAG, "onOptionsItemSelected: managing sources");
        break;
    }

    return true;
}

// this on is called everytime after the optionsmenu is disappeared
@Override
public void onOptionsMenuClosed(Menu menu) {
    Log.d(TAG,
            "onOptionsMenuClosed: called everytime after the OptionsMenu is disappeared");

    Log.i(TAG, "Hey Jackson, I'm disappeared");
}
}

xml file

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

  <item android:id="@+id/itemStatus" android:title="@string/titleStatus"
    android:icon="@android:drawable/ic_menu_edit"></item>
  <item android:title="@string/titleTimeline" android:id="@+id/itemTimeline"
    android:icon="@android:drawable/ic_menu_sort_by_size"></item>
  <item android:id="@+id/itemPrefs" android:title="@string/titlePrefs"
    android:icon="@android:drawable/ic_menu_preferences"></item>
  <item android:icon="@android:drawable/ic_menu_delete"
    android:title="@string/titlePurge" android:id="@+id/itemPurge"></item>
  <item android:title="@string/titleRefresh" android:id="@+id/itemRefresh"
    android:icon="@android:drawable/ic_menu_rotate"></item>
</menu>

there are some tricks: if You have multiple activities with same OptionsMenu: 1. Create a base activity with OptionsMenu 2. Inherit this base activity on other activies, that handles same OptionsMenu

Result: same Menu on multiple activities

Regards, Galymzhan Sh

Galymzhan Sh
  • 119
  • 11