Make your app compatible with Android Oreo

Source: Internet
Author: User

Unknowingly Android Oreo has been released for a few months, and your app is starting to use the latest platform? Do you encounter some tricky issues during the app migration? How is your Android app compatible with Oreo?

We should all know that every major upgrade, in the compatibility of this piece will always appear more or less problems, today come together to explore the compatibility of the application.

Do not know if you remember, from the Andriod 7.0 update compatibility test data results, Top1000 mainstream applications in the number of incompatible applications reached 166, resulting in a total compatibility rate of only 83%, compared to the previous Andriod 6.0 update caused by the application incompatibility problem more prominent.

For the Andriod 8.0 after the upgrade of compatibility, the major application vendors are also very concerned. From this Google developers Conference can also see the intentions of Google, specifically made a "let your app compatible with Android Oreo" theme sharing, here also simple to share to everyone, I hope that you will apply to the migration of Andriod 8.0 when there are some help.

As a developer, our app should keep up to date with the latest Android version compatibility, mainly from two aspects to share: Android apps are compatible with some of the best practice experiences and some of the changes in Android Oreo.

When the first Android Oreo preview version was released in mid-March, it was found that Chinese applications were only 60% compatible and later invested a great deal of resources and work.

After the official release on August 25, there are 993 compatible Top1000 mainstream applications in China, with a compatibility ratio of 96% applied in China today.

1. Non-public API

Some of the experience is not to use some nonpublic APIs in development, because those non-public APIs may change function signatures or function lists at any time in a post-update, and may even be removed or altered to behave.

If you have a strong desire to use can tell Google, will try to collect and provide some open APIs to developers, such as in Android Oreo open Inmemorydexclassloader directly from memory loaded Dex, Do not call Dexclassloader directly, otherwise the resulting file will have some impact.

2.DEX/SO file

Do not directly manipulate or tamper with dex/so files, preferably using Android Studio or other compilation tools directly generated by the Dex/so file. In the apk aspect also added more checks, dynamic connector again to the user request permission, such as writable permissions and executable permissions, if modified so file may error.

3. Upgrading third-party SDKs

Some of the more common third-party SDKs in many applications, some of which are hardened and hot-fix frameworks that use a lot of DEX operations and private APIs, will cause apps that use these SDKs to crash when new versions of Android appear.

So it is often necessary to see whether these SDKs are updated, and basically will work closely with these SDK providers, and will update to the latest version as soon as possible after the upgrade.

4.Janus Vulnerability

From Android 5.0, if the app only uses the SDK Android Jarsigner signature mechanism, there will be a Janus vulnerability that would use art to execute a malicious Dex file attached to the APK.

Currently fixed in December release, users can update patches, suggesting that developers use the V1+V2 signature mechanism.

5. Privacy

For the security and privacy of the user, Settings.secure.ANDROID_ID will return different values each time for each app based on the signature key and user profile, which means that an app will not be able to know the android_id of other applications. After applying the query ID to some ads, it can be reset by the user.

Query Net.hostname System Properties will return NULL, if you need to access user accounts, get_accounts permissions are no longer sufficient, you need to use accountchooseractivity to pop up a selection box to allow users to choose.

6. Alarms

For the alarm aspect, a new floating layer is designed, on top of all applications, but underneath the system and key windows. If you continue to use System_overlay in Android Oreo, it is automatically replaced with Application_overlay. Settings in Android Oreo are more intuitive to use Type_application_overlay, and users can also make it easier to manage behaviors and settings.

7. Notice

In Android Oreo, you must use a notification channel for all notifications.

8. Multi-application window display

Multi-window display is also a new feature in Android Oreo, you can use a flag_activity_launch_adjacent to tell the system to use multiple windows. It is important to note that only activity in an active screen is considered an activity Task, not a paused activity. The Multi-window mode switch is the same as the flip-screen event, and the standard UI module should be no problem in this respect, if the multi-window can not be supported by android:resizeableactivity= "Fasle" to set.

9. Extra-long screen support

Android Oreo also support the extra-long screen, many manufacturers are now publishing a special screen phone, for many applications to screen aspect ratio has a false hypothesis, otherwise there will be a black border, or UI module and touch points are not aligned, or some corners of the UI will be obscured and so on.

If the scene is not suitable for the extra-long screen, you need to apply the maximum aspect ratio by using the Android:max_aspect meta Data,api 26 or above using Android:maxaspectratio in the following ways: API 25 or below.

The next step is to focus on background checks and location restrictions, first not to give developers the trouble, but for Android users to get better system health and battery performance experience, and developers can develop the user needs of the function. In summary, there are three areas:

1. Backstage no way to start the service, the front desk start service is still no problem;

2. Implicit broadcasts registered in the manifest are not supported;

For these two main target SDK for Android Oreo will be affected, but unfortunately users can now enable this restriction on the app.

3. Background apps get more restrictive restrictions to get the location. All applications running on Android Oreo will be affected and need to be addressed immediately.

1. Service

The most important principle is that the user is visible. If the application is doing resource-intensive work, the user should be aware that starting the service from the background will fail, throwing a illegalstateexception to the caller who started the service.

Developers need to decide whether to be in the foreground when calling StartService, note that Intentservice is also a background service, you can use a new class Jobintentservice, which can be used in many places to replace Intentservice. Most services do not have long-time interactions and can use Jobscheduler or firebase cloud to work, making the system more efficient to dispatch work.

2. Broadcasting

You cannot receive more implicit broadcasts by declaring sinks in manifest, which means that there are no explicit target components. If you cannot monitor broadcasts through action_package_replaced, you can use action_my_package_replaced to monitor display broadcasts. In many cases where broadcasts are used, Jobscheduler can be used instead.

3. Location information Restrictions

Positioning is very battery-intensive, when there are many applications to locate, the battery will consume quickly, will lead to poor user experience, and even some functions will be invalidated, so added some background positioning restrictions. If the app is in the foreground, its location collection policy is constant and is subject to some restrictions if used in the background.

Specifically, only a few locations can be received per hour, and location information is based on the entire device, as long as it is restricted to run on Android Oreo. Using batch processing can cause a delay of a certain amount of time, but it is also a good choice to get more data location information points.

Android Oreo inside to do some optimization, GPS is very accurate but very power consumption, WiFi will be a bit better but still more power, optimized when the device remains connected to the same static WiFi access point means that the user did not move too much from the original location, the system will not be new location calculation.

In addition, you can better detect the switch between different wifi, such as at home and work when the use of Android devices, only when switching WiFi to update the location, usually stay at home and stay at work place in the time period will not update location information.

The same strategy has made similar changes to geo-fencing, with the current information about geo-fencing increasing from a few 10 seconds to about 2 minutes, with only one-tenth power consumption.

You can not use Pengdingintent.getservice () in Android Oreo to get background updates, although you can continue to use them, but they work only in the foreground. Instead, you should use Pengdingintent.getbroadcast () and define a receiver in manifest, defined as display broadcast.

4. Location information policy

What should I do if I need to gather location information intensively in the background? Here are some ways to define some geo-fencing features that can be used to get a precise location when a geo-fence changes, and to know how to use firebase cloud for updates in the future. Then use batch to collect more data points to return together, although only a few times per hour to receive information, but can get more data, for many programs is sufficient, but not to provide real-time location data. You can use SetInterval to set the update time, use Setmaxwaittime to set the maximum time interval for the batch, and use Setfastestinterval to set the passive acquisition location information.

The above is the topic of the general content of the sharing, in addition to these in the development and migration, there will be some other compatibility issues, will be in the next share to sort out. If you are in the migration app to Android Oreo also met some problems, also welcome the message to discuss together.

This article copyright for the public Share talent show (Shareexpert)--Xin 鱻 all, if necessary reprint please contact the author authorized, hereby declare!

Make your app compatible with Android Oreo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.