Explain Android 7.0 settings loading options

First, the settings loading option mentioned above refers to the option displayed in the main interface of the application settings. This modification needs to modify the system source code.

Android 7.0 settings has one more recommended option and a sidebar at the top, which makes the operation more convenient.

Native 7.0 main interface sidebar

Android 6.0

Before Android 6.0 development, you will know that the settings loading option of 6.0 is through loading dashboard_ Categories.xml, get the options to be displayed, and judge whether to display them in settingsactivity. Therefore, it is relatively simple to add an option in 6.0, directly on the dashboard_ Categories.xml Add icon, title, summary, or target fragment and intent, so that you can jump to the corresponding interface smoothly. But on 7.0, Google refactored settings.

Android 7.0

The settings option of 7.0 is no longer available from the dashboard_ Load the option list in categories.xml. Instead, configure the action of intent filter in androidmanifest.xml and search the specified action through packagemanager. Then you can get the option list to be displayed, and you also need to judge in the code to judge which functions need to be displayed or not.

Tileutils. Java uses several actions to obtain the corresponding activities in the system, such as several in settings

Search through packagemanager to obtain this series of activity information,

The icon, title and summary are configured through meta data in androidmanifest.xml, which includes the icon, title and description displayed in settings. There are also categories and target fragments displayed in settings.

The code below androidmanifest.xml of settings is the activity configuration of settings - > about phone.

The idea of displaying various options in settings is relatively simple, so it is relatively simple to add function options directly in settings.

Add a third party APK to the settings option

If you need to add a packaged APK to settings, you need three steps.

1. Add action.

The activities that can be searched by the packagemanager are added to the option list of settings after searching

1. Add the displayed option information.

Add the following meta data to the startup activity corresponding to androidmanifest.xml of the APK. It's better to have the APK to provide the company's technical support, otherwise it's difficult to change and compile the confused code.

Add the corresponding package name to the whitelist of tileutils.java.

This is also some security issues considered by Android. If the package name is not added to the white list, it will not be displayed.

The last is the full compilation, which has been verified by brushing the machine.

Compared with Android 6.0, it is easier to add function options on 7.0. Just write the function, add the necessary parameters in androidmanifest.xml of settings, or configure the necessary parameters in androidmanifest.xml of independent APK, and then add the package name in tileutils.java. There are fewer changes to be made, and Google has put a lot of methods into com.android.settinglibs to streamline some of the code.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>