Android: access to the "system" -doubles

I am currently working on an application to display battery status, and I would like to use Android-drawables instead of my own images to reduce the size of the application.

I found this page listing available images and availability for each SDK version:
http://www.fixedd.com/projects/android_drawables_display

My question is: how can I access the "system" duals? If you click on the link and select the Status tab, there are some batteries, such as stat_sys_battery_0, but I can’t access it, Eclipse does not offer intellisense for it and will not compile the application if I use one of these drawings .

Since these drawings are part of all SDK versions, would I think I should use them, or are these “special” drawings protected in such a way that they can only be used by system functions (and not applications)?

Any idea is welcome.

Select0r

+4
source share
3 answers

Actually there is a way to access the system icons, but it does not work, as indicated in the documentation, but I will add it in case someone is interested:

intent.getIntExtra(BatteryManager.EXTRA_ICON_SMALL, -1)

You will receive an icon resource ID that corresponds to the current battery status:
http://developer.android.com/reference/android/os/BatteryManager.html#EXTRA_ICON_SMALL

Additionally for ACTION_BATTERY_CHANGED: an integer containing the resource identifier icon of a small status icon indicating the current battery status.

However, it always returns the same icon, regardless of the actual battery level. Finding an icon using simple random numbers may work, but I don't know if the identifiers are consistent across SKD levels, as well as across different machines, so I would rather not rely on this.

+1
source

Hope this is what you were looking for:

 private BroadcastReceiver mBatInfoReceiver = new BroadcastReceiver(){ @Override public void onReceive(Context arg0, Intent intent) { int level = intent.getIntExtra("level", 0); int batteryIconId = intent.getIntExtra("icon-small", 0); Button toolBarBattery = (Button) findViewById(R.id.toolBarButton); LevelListDrawable batteryLevel = (LevelListDrawable) getResources().getDrawable(batteryIconId); batteryLevel.setLevel(level); toolBarBattery.setBackgroundDrawable(batteryLevel); } }; 
+3
source

I found another link with information that not all drawings are publicly available. He does not say why some drawings will be private, but I think I will have to live with the fact and copy the images I need into my application.
http://androiddrawableexplorer.appspot.com/

NOTE. Some images in the Android bank are not publicly available and therefore cannot be used directly (you can copy them to your application, but you cannot refer to them through the "android" package namespace).

+2
source

Source: https://habr.com/ru/post/1338318/


All Articles