List of usage examples for android.content Intent getIntExtra
public int getIntExtra(String name, int defaultValue)
From source file:ack.me.truconnectandroiddemo.TruconnectService.java
public static int getMode(Intent intent) { return intent.getIntExtra(EXTRA_MODE, 0); }
From source file:ack.me.truconnectandroiddemo.TruconnectService.java
public static int getResponseCode(Intent intent) { return intent.getIntExtra(EXTRA_RESPONSE_CODE, -1); }
From source file:com.andremion.heroes.ui.section.view.SectionActivity.java
public static int getPosition(int resultCode, Intent data) { if (resultCode == RESULT_OK && data != null && data.hasExtra(EXTRA_POSITION)) { return data.getIntExtra(EXTRA_POSITION, EXTRA_NOT_FOUND); }//from w w w. java 2 s . co m return EXTRA_NOT_FOUND; }
From source file:com.andremion.louvre.preview.PreviewActivity.java
public static int getPosition(int resultCode, Intent data) { if (resultCode == RESULT_OK && data != null && data.hasExtra(EXTRA_POSITION)) { return data.getIntExtra(EXTRA_POSITION, NO_POSITION); }/*from ww w .j av a 2 s .c o m*/ return NO_POSITION; }
From source file:Main.java
public static float getCurrentBattery(Context context) { Intent batteryInfoIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); // int status = batteryInfoIntent.getIntExtra( "status" , 0 ); // int health = batteryInfoIntent.getIntExtra( "health" , 1 ); // boolean present = batteryInfoIntent.getBooleanExtra( "present" , false ); int level = batteryInfoIntent.getIntExtra("level", 0); int scale = batteryInfoIntent.getIntExtra("scale", 0); // int plugged = batteryInfoIntent.getIntExtra( "plugged" , 0 ); // int voltage = batteryInfoIntent.getIntExtra( "voltage" , 0 ); // int temperature = batteryInfoIntent.getIntExtra( "temperature" , 0 ); // String technology = batteryInfoIntent.getStringExtra( "technology" ); // Log.i("Battery: ", "status: " + status); // Log.i("Battery: ", "health: " + health); // Log.i("Battery: ", "present: " + present); // Log.i("Battery: ", "level: " + level); // Log.i("Battery: ", "scale: " + scale); // Log.i("Battery: ", "plugged: " + plugged); // Log.i("Battery: ", "voltage: " + voltage); // Log.i("Battery: ", "temperature: " + temperature); // Log.i("Battery: ", "technology: " + technology); return level / (float) scale; }
From source file:com.onesignal.NotificationOpenedProcessor.java
public static void processFromActivity(Context inContext, Intent inIntent) { // Pressed an action button, need to clear the notification and close the notification area manually. if (inIntent.getBooleanExtra("action_button", false)) { NotificationManagerCompat.from(inContext).cancel(inIntent.getIntExtra("notificationId", 0)); inContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); }/*from w w w . ja va 2 s. c o m*/ processIntent(inContext, inIntent); }
From source file:ameircom.keymedia.Activity.transition.FabTransform.java
/** * Create a {@link FabTransform} from the supplied {@code activity} extras and set as its * shared element enter/return transition. */// w ww .j a v a 2 s.c o m public static boolean setup(@NonNull Activity activity, @Nullable View target) { final Intent intent = activity.getIntent(); if (!intent.hasExtra(EXTRA_FAB_COLOR) || !intent.hasExtra(EXTRA_FAB_ICON_RES_ID)) { return false; } final int color = intent.getIntExtra(EXTRA_FAB_COLOR, Color.TRANSPARENT); final int icon = intent.getIntExtra(EXTRA_FAB_ICON_RES_ID, -1); final FabTransform sharedEnter = new FabTransform(color, icon); if (target != null) { sharedEnter.addTarget(target); } activity.getWindow().setSharedElementEnterTransition(sharedEnter); return true; }
From source file:ccv.checkhelzio.nuevaagendacucsh.transitions.FabTransition.java
/** * Create a {@link FabTransition} from the supplied {@code activity} extras and set as its * shared element enter/return transition. *///from w w w . j av a 2s. co m public static boolean setup(@NonNull Activity activity, @Nullable View target) { final Intent intent = activity.getIntent(); if (!intent.hasExtra(EXTRA_FAB_COLOR) || !intent.hasExtra(EXTRA_FAB_ICON_RES_ID)) { return false; } final int color = intent.getIntExtra(EXTRA_FAB_COLOR, Color.TRANSPARENT); final int icon = intent.getIntExtra(EXTRA_FAB_ICON_RES_ID, -1); final FabTransition sharedEnter = new FabTransition(color, icon); if (target != null) { sharedEnter.addTarget(target); } activity.getWindow().setSharedElementEnterTransition(sharedEnter); return true; }
From source file:count.ly.messaging.CrashDetails.java
/** * Returns the current device battery level. *///from w w w.ja va 2 s . c o m static String getBatteryLevel(Context context) { try { Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, -1); // Error checking that probably isn't needed but I added just in case. if (level > -1 && scale > 0) { return Float.toString(((float) level / (float) scale) * 100.0f); } } catch (Exception e) { if (Countly.sharedInstance().isLoggingEnabled()) { Log.i(Countly.TAG, "Can't get batter level"); } } return null; }
From source file:Main.java
static public boolean isDisconnectedIntent(Intent intent) { boolean res = false; NetworkInfo networkInfo = (NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); if (networkInfo != null) { NetworkInfo.State state = networkInfo.getState(); res = (state.equals(NetworkInfo.State.DISCONNECTING) || state.equals(NetworkInfo.State.DISCONNECTED)) && (networkInfo.getType() == ConnectivityManager.TYPE_WIFI); } else {//from w w w .j a va 2s .c o m int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_UNKNOWN); if (wifiState == WifiManager.WIFI_STATE_DISABLED || wifiState == WifiManager.WIFI_STATE_DISABLING) { res = true; } } return res; }