Example usage for android.content Intent getIntExtra

List of usage examples for android.content Intent getIntExtra

Introduction

In this page you can find the example usage for android.content Intent getIntExtra.

Prototype

public int getIntExtra(String name, int defaultValue) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:Main.java

public static float getBatteryLevel(Intent batteryIntent) {
    int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
    int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
    return level / (float) scale;
}

From source file:Main.java

public static int getChargingMode(Intent batteryStatus) {
    return batteryStatus.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
}

From source file:Main.java

public static String getChargeLevel(Intent paramIntent) {
    return Integer.toString(paramIntent.getIntExtra("level", 0)) + "%";
}

From source file:Main.java

public static int getBatteryLevel(Intent batteryChangedIntent) {
    int level = batteryChangedIntent.getIntExtra("level", 0);
    return (level * 100) / batteryChangedIntent.getIntExtra("scale", 100);
}

From source file:Main.java

public static boolean isChargingOrFull(Intent batteryStatus) {
    int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
    return status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL;
}

From source file:Main.java

public static float getChargePct(Intent batteryStatus) {
    int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
    int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
    return level / (float) scale;
}

From source file:Main.java

/**
 * Gets the board layout./*from ww  w  . j  a va  2 s.  c o m*/
 * 
 * @param intent
 *            the intent
 * 
 * @return the board layout
 */
public static int getBoardLayout(Intent intent) {
    return intent.getIntExtra(BOARD_LAYOUT_ID_KEY, 0);
}

From source file:Main.java

/**
 * Gets the actor session id./*  w w  w .j a va 2s  .c o  m*/
 * 
 * @param intent
 *            the intent
 * 
 * @return the actor session id
 */
public static int getActorSessionId(Intent intent) {
    return intent.getIntExtra(ACTOR_SESSION_ID_KEY, 0);
}

From source file:Main.java

/**
 * Gets the game id.//from  w w  w . ja va 2s  . c o m
 * 
 * @param intent
 *            the intent
 * 
 * @return the game id
 */
public static int getGameId(Intent intent) {
    return intent.getIntExtra(GAME_ID_KEY, 0);
}

From source file:Main.java

/**
 * Gets the player id./*from   www  .  ja v  a 2 s  .c o  m*/
 * 
 * @param intent
 *            the intent
 * 
 * @return the player id
 */
public static int getPlayerId(Intent intent) {
    return intent.getIntExtra(PLAYER_ID_KEY, 0);
}