Getting battery capacity and usage of Android device

1. Get the battery capacity of Android device The battery capacity is mainly obtained by reflecting com.android.internal.os.PowerProfile Class, calling the getBatteryCapacity method to get it. The specific methods are as follows /** * Get the capacity of the battery * * @param context ...

Posted by kwstephenchan on Tue, 21 Jan 2020 10:20:42 -0800

Android critical instance (6) use of toolbar menu items

Selection of menu bar symbols There are many menu symbols in Android studio. Select drawable You can choose any symbol you want code implementation public class CrimeListFragment extends Fragment { public static final String SUBTITLE = "subtitle"; private RecyclerView mRecyclerView; private CrimeAdpater mCr ...

Posted by bsfischer on Tue, 21 Jan 2020 08:51:04 -0800

Custom ViewGroup - implement custom ViewPager

ViewGroup and View 1. View Group is a container that can hold views. It is responsible for measuring the width and height of subviews or sub controls, and determining the location of subviews or sub controls. Common methods are: onMesure(): measures the width and height of a subview or child control ...

Posted by GroundZeroStudio on Tue, 21 Jan 2020 03:06:58 -0800

Android threads and thread pools -- Reading Notes of Android development art exploration -- Chapter 11

Article directory 1, Thread form in Android 1.1 AsyncTask 1.1.1 usage 1.1.2 principle analysis: 1.2 HandlerThread 1.3 IntentService 2, Thread pool in Android 2.1 ThreadPoolExecutor 2.2 classification of thread pool 2.2.1 FixedThreadPool 2.2.2 CachedThreadPool 2.2.3 ScheduledThreadPool 2.2.4 Sin ...

Posted by RJP1 on Tue, 21 Jan 2020 00:05:38 -0800

mui solves the conflict between single webview and PopPicker

mui single webview mode, the page is as follows. There are two poppickers on it, and then the page can't slide up and down. <div class="mui-content us-reimburse"> <div class="block"> <div class="us-list-title"> Application information &lt ...

Posted by timclaason on Mon, 20 Jan 2020 10:56:40 -0800

Details of EventBus source code

When using EventBus, we first need to register EventBus: EventBus.getDefault().register(this); So let's use this code as an entry to explore the secrets of EventBus step by step! Let's first look at the getDefault() method: static volatile EventBus defaultInstance; public static EventBus getDefa ...

Posted by artic on Mon, 20 Jan 2020 02:14:51 -0800

Understand reactive programming and analyze LiveData deeply

/Start/   This article mainly analyzes the source code of LiveData. This article uses the source code analysis of Android SDK 29.   /Definition/   LiveData is a kind of observable data storage class, which has life cycle awareness and follows the life cycle of application components (e.g. Activ ...

Posted by rowantrimmer on Sat, 18 Jan 2020 21:15:03 -0800

Android running white list in the background, elegant for life

    Survival Status We know that there will be background killing on Android systems, and with the update of system versions, there will be an increasing trend in killing processes.The system's starting point is good because it saves memory, reduces power consumption, and avoids some rogue behav ...

Posted by zgkhoo on Sat, 18 Jan 2020 17:55:45 -0800

Android Edittext limits the number of decimal places, the size of input numbers and style attributes

Everyone is not new to Edittext. I won't say much here. I'll go straight to the topic. I'm just writing this article to record some tips for using Edittext: 1. Limit input range method 1: /** * Limit the range of input numbers */ public class RegionNumberEditText extends EditText { private Context context; private i ...

Posted by riyaz on Sat, 18 Jan 2020 07:24:38 -0800

Hand rolling an annotation frame

Runtime annotation is mainly implemented by reflection, while compile time annotation helps us to generate code during compilation, so compile time annotation is efficient, but it is a little more complex to implement. Runtime annotation is inefficient, but it is simple to implement. Let's first look at ...

Posted by dleone on Fri, 17 Jan 2020 21:03:12 -0800