// Path: app/src/main/java/huyifei/mymvp/util/Tools.java
// public class Tools {
//     /**
//      * 获取系统时间 从月份开始到秒结束
//      * @return
//      */
//     public static String getCurrentTime() {
//         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM月dd日    HH:mm:ss", Locale.CHINA);
//         Date curDate = new Date(System.currentTimeMillis());
//         return simpleDateFormat.format(curDate);
//     }
// }


import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.BatteryManager;
import android.os.Bundle;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import huyifei.mymvp.R;
import huyifei.mymvp.util.Tools;
        battery = findViewById(R.id.battery);
        IntentFilter batteryFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
        Intent batteryIntent = getApplicationContext().registerReceiver(null, batteryFilter);
        int total = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, 1);
        int current = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
        float percent = current * 100 / total;
        battery.setText(String.valueOf(percent));
    }

    @Override
    protected void onResume() {
        super.onResume();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(MY_ACTION);
        registerReceiver(mMyReceiver, intentFilter);


        IntentFilter intentFilter1 = new IntentFilter();
        intentFilter1.addAction(MY_ACTION_1);
        registerReceiver(mSecondReceiver, intentFilter1);
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        unregisterReceiver(mMyReceiver);
        unregisterReceiver(mSecondReceiver);


// Path: app/src/main/java/huyifei/mymvp/util/Tools.java
// public class Tools {
//     /**
//      * 获取系统时间 从月份开始到秒结束
//      * @return
//      */
//     public static String getCurrentTime() {
//         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM月dd日    HH:mm:ss", Locale.CHINA);
//         Date curDate = new Date(System.currentTimeMillis());
//         return simpleDateFormat.format(curDate);
//     }
// }


// Path: app/src/main/java/huyifei/mymvp/broadcastreceiver/BroadcastReceiverActivity.java
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.BatteryManager;
import android.os.Bundle;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import huyifei.mymvp.R;
import huyifei.mymvp.util.Tools;

        battery = findViewById(R.id.battery);
        IntentFilter batteryFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
        Intent batteryIntent = getApplicationContext().registerReceiver(null, batteryFilter);
        int total = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, 1);
        int current = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
        float percent = current * 100 / total;
        battery.setText(String.valueOf(percent));
    }

    @Override
    protected void onResume() {
        super.onResume();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(MY_ACTION);
        registerReceiver(mMyReceiver, intentFilter);


        IntentFilter intentFilter1 = new IntentFilter();
        intentFilter1.addAction(MY_ACTION_1);
        registerReceiver(mSecondReceiver, intentFilter1);
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        unregisterReceiver(mMyReceiver);
        unregisterReceiver(mSecondReceiver);


        if (mLocalBroadcastManager != null) {