Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The adaptation of Android8.0 (2)

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Friends, today we will continue to decompose the adaptation of Android8.0, and today we will "nibble" on the startup page, version adaptation and system restrictions.

1. Startup page adaptation

Recently, I accidentally found that the startup page of the application crashed on the 8.0 system. I quickly went to BUG. After running it, I found the following exception:

Only the full screen opaque activity can set the orientation.

Solutions are as follows:

1.1.If you do not consider the orientation of the configuration screen, you can simply remove the android:screenOrientation= "portrait"

1.2.If you want to fix the orientation of the screen and solve the problem of white (black) screen caused by slow startup, you can find the Activity in which you set transparent Activity, then change android:windowIsTranslucent to false in his theme, and then add true

1.3. refer to the solution given by Google: don't disable the preview window, but follow the common Material Design pattern. You can use the windowBackground theme property of the activity to provide a simple custom drawing for starting the activity.

2. 8.0 version installation adaptation

After the android 8.0 system update, the switch for unknown application installation permissions is removed and replaced by a management list of applications from unknown sources, which requires the user to give permission to allow app to install applications from unknown sources.

2.1. Add permissions

2.2, and then determine whether the permission to "allow installation of unknown sources" of the application is enabled when the user clicks on the update, and if not, guide the user to open the permission to "allow installation of unknown sources" of the application.

Note: if you update the version by yourself, you need to cooperate with the notification channel to display the progress of the version download.

3. Permission policy changes at run time

Before Android 8.0, if the application requested permission at run time and was granted that permission, the system mistakenly granted the application other permissions that belonged to the same permission group and registered in the inventory. In 8.0, this behavior was corrected, and the system only granted the application the permission explicitly requested.

Apply together with group permissions:

Several new phone-related permissions have been introduced in 8.0:

ANSWER_PHONE_CALLS allows your application to answer incoming calls programmatically. To handle incoming calls in your application, you can use the acceptRingingCall () function.

READ_PHONE_NUMBERS permissions allow your application to read phone numbers stored in the device.

These permissions are classified as dangerous and belong to the PHONE permission group.

1. Execution restrictions in the background

1.1. Backend service restrictions: when the application is idle, there are restrictions on the backend services that the application can use. These restrictions do not apply to front desk services, which are more likely to attract the attention of users.

1.2. Broadcast restrictions: with limited exceptions, applications cannot register implicit broadcasts with manifests. They can still register these broadcasts at run time, and they can use manifests to register explicit broadcasts specifically for them.

Note: by default, these restrictions apply only to O-specific applications. However, users can enable these restrictions for any application from the Settings screen, even if the application does not target O as the platform.

2. Backend service restrictions

The system can distinguish between foreground and background applications. (the background definition for service restriction purposes is different from the definition of memory management usage; an application may be in the background according to the definition of memory management, but in the foreground according to the definition of being able to start the service. ) the application is considered to be in the foreground if any of the following conditions are met:

Has a visible Activity (regardless of whether the Activity is started or paused).

Front desk service is available.

Another foreground application has been associated with that application (either by binding to one of the services or by using one of the content providers). For example, if another application is bound to the service of that application, the application is in the foreground:

IME

Wallpaper service

Notification listener

Voice or text service

If the above conditions are not met, the application will be considered to be in the background.

The backend service will be dropped by kill. It is officially recommended to use AlarmManager, SyncAdapter and JobScheduler instead of backend service.

3. Broadcast restrictions

If the application is registered to receive a broadcast, the receiver of the application consumes resources each time a broadcast is sent, imposing some restrictions on the broadcast in 7.0, and 8.0 makes these restrictions more stringent:

Applications for Android 8.0 cannot continue to register broadcast receivers for implicit broadcasts in their list

Applications can continue to register explicit broadcasts in their listings

Applications can register receivers for any broadcast, whether implicit or explicit, using Context.registerReceiver () at run time

Broadcasts that require signature permissions are not subject to this restriction because they are sent only to applications signed with the same certificate, not to all applications on the device.

4. Backstage location restrictions

Android 8.0 limits the frequency at which background applications can retrieve users' current locations (the location of background applications cannot be received)

(note: the above content is quoted from Google Chinese developer website: https://developer.android.google.cn)

With the new system in hand, we still need to know more about the changes and use our own ability to solve the problems in the actual development process. Dear friends, what problems have you encountered in the process of adapting to 8.0? welcome to leave a message and discuss and solve it together. If there is any mistake in the article, please leave a message and point it out.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report