Reputation: 32207
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?
Upvotes: 1
Views: 919
Reputation: 119
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
Upvotes: 1
Reputation: 119
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
Upvotes: 1
Reputation: 1006614
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".
Upvotes: 2