进步对话未显示

时间:2017-04-01 13:26:12

标签: android

我有一个Listview,其中包含来自Firebase的数据。获取数据需要时间,所以我添加了一个进度对话框,但它没有显示出来。

public class BatteryReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        int deviceStatus = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
        int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
        int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
        int percentage = (int) (((float) level / (float) scale) * 100.0f);

        switch (deviceStatus) {
            case BatteryManager.BATTERY_STATUS_CHARGING:
                context.getString((R.string.bat_charge), "Charging:", percentage, "%");
                break;
            case BatteryManager.BATTERY_STATUS_DISCHARGING:
                context.getString((R.string.bat_charge), "Discharging:", percentage, "%");
                break;
            case BatteryManager.BATTERY_STATUS_FULL:
                context.getString((R.string.bat_charge), "Full:", percentage, "%");
                break;
            case BatteryManager.BATTERY_STATUS_UNKNOWN:
                context.getString((R.string.bat_charge), "Unknown:", percentage, "%");
                break;
            case BatteryManager.BATTERY_STATUS_NOT_CHARGING:
                context.getString((R.string.bat_charge), "Not charging:", percentage, "%");
                break;
        }
    }

0 个答案:

没有答案