android 4.4 - Important Behavior Changes

来源:互联网 发布:js怎么训练 编辑:程序博客网 时间:2024/05/21 10:13

Important Behavior Changes


If you have previously published an app for Android, be aware that your app might be affected by changes in Android 4.4.

If your app reads from external storage...

Your app can not read shared files on the external storage when running on Android 4.4, unless your app has theREAD_EXTERNAL_STORAGE permission. That is, files within the directory returned by getExternalStoragePublicDirectory()are no longer accessible without the permission. However, if you need to access only your app-specific directories, provided by getExternalFilesDir(), then you do not need the READ_EXTERNAL_STORAGE permission.

If your app uses WebView...

Your app might behave differently when running on Android 4.4, especially when you update your app's targetSdkVersionto "19" or higher.

The code underlying the WebView class and related APIs has been upgraded to be based on a modern snapshot of the Chromium source code. This brings a variety of improvements for performance, support for new HTML5 features, and support for remote debugging of your WebView content. The scope of this upgrade means that if your app uses WebView, it's behavior may be impacted in some cases. Although known behavior changes are documented and mostly affect your app only when you update your app's targetSdkVersion to "19" or higher—the new WebView operates in "quirks mode" to provide some legacy functionality in apps that target API level 18 and lower—it's possible that your app depends on unknown behaviors from the previous version of WebView.

So if your existing app uses WebView, it's important that you test on Android 4.4 as soon as possible and consult Migrating to WebView in Android 4.4 for information about how your app might be affected when you update yourtargetSdkVersion to "19" or higher.

If your app uses AlarmManager...

When you set your app's targetSdkVersion to "19" or higher, alarms that you create using either set() or setRepeating()will be inexact.

To improve power efficiency, Android now batches together alarms from all apps that occur at reasonably similar times so the system wakes the device once instead of several times to handle each alarm.

If your alarm is not associated with an exact clock time, but it's still important that your alarm be invoked during a specific time range (such as between 2pm and 4pm), then you can use the new setWindow() method, which accepts an "earliest" time for the alarm and a "window" of time following the earliest time within which the system should invoke the alarm.

If your alarm must be pinned to an exact clock time (such as for a calendar event reminder), then you can use the newsetExact() method.

This inexact batching behavior applies only to updated apps. If you've set the targetSdkVersion to "18" or lower, your alarms will continue behave as they have on previous versions when running on Android 4.4.

If your app syncs data using ContentResolver...

When you set your app's targetSdkVersion to "19" or higher, creating a sync with addPeriodicSync() will perform your sync operations within a default flex interval of approximately 4% of the period you specify. For example, if your poll frequency is 24 hours, then your sync operation may occur within roughly a one-hour window of time each day, instead of at exactly the same time each day.

To specify your own flex interval for sync operations, you should begin using the new requestSync() method. For more details, see the section below about Sync Adapters.

This flex interval behavior applies only to updated apps. If you've set the targetSdkVersion to "18" or lower, your existing sync requests will continue to behave as they have on previous versions when running on Android 4.4. 
0 0
原创粉丝点击