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();
 }
Exemplo n.º 2
0
  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;
  }