コード例 #1
0
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.meat_toppings);
   Intent i = getIntent();
   size = i.getStringExtra("size");
   numVeggieToppings = i.getIntExtra("numVeggieToppings", 0);
   setMeatToppingsView();
   setNextButton();
 }
コード例 #2
0
ファイル: Utilities.java プロジェクト: kim0z/gpslogger
  public static float GetBatteryLevel(Context context) {
    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);

    if (level == -1 || scale == -1) {
      return 50.0f;
    }

    return ((float) level / (float) scale) * 100.0f;
  }