Android M新特性之Behavior Changes
1、Runtime Permissions
On your apps that target the M Preview release or higher, make sure to check for and request permissions at runtime. To determine if your app has been granted a permission, call the new Context.checkSelfPermission()
method. To request a permission, call the new Activity.requestPermission()
method. Even if your app is not targeting the M Preview release, you should test your app under the new permissions model.
2、Power-Saving Optimizations
If a device is unplugged and left stationary with the screen off for a period of time, it goes into Doze mode where it attempts to keep the system in a sleep state.
The following restrictions apply to your apps while in Doze:
- Network access is disabled, unless your app receives a high priority Google Cloud Messaging tickle.
- Wake locks are ignored.
- Alarms scheduled with the
AlarmManager
class are disabled, except for alarms that you've set with thesetAlarmClock()
method andAlarmManager.setAndAllowWhileIdle()
. - WiFi scans are not performed.
- Syncs and jobs for your sync adapters and
JobScheduler
are not permitted to run.
3、App standby
With this preview, the system may determine that apps are idle when they are not in active use.
4、Adoptable Storage Devices
With this preview, users can adopt external storage devices such as SD cards. Adopting an external storage device encrypts and formats the device to behave like internal storage. This feature allows users to move both apps and private data of those apps between storage devices. When moving apps, the system respects theandroid:installLocation
preference in the manifest.
Context
methods:ApplicationInfo
fields:
5、Apache HTTP Client Removal
This preview removes support for the Apache HTTP client. If your app is using this client and targets Android 2.3 (API level 9) or higher, use the HttpURLConnection
class instead. This API is more efficient because it reduces network use through transparent compression and response caching, and minimizes power consumption. To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in yourbuild.gradle
file:
android {
useLibrary 'org.apache.http.legacy'
}
6、AudioManager Changes
Setting the volume directly or muting specific streams via the AudioManager
class is no longer supported. ThesetStreamSolo()
method is deprecated, and you should call the AudioManager.requestAudioFocus()
method instead. Similarly, the setStreamMute()
method is deprecated; instead, call theAudioManager.adjustStreamVolume()
method and pass in the direction value ADJUST_MUTE
orADJUST_UNMUTE
.
7、Text Selection
When users select text in your app, you can now display text selection actions such as Cut, Copy, and Paste in a floating toolbar
8、Android Keystore Changes
With this preview, the Android Keystore provider no longer supports DSA. ECDSA is still supported.
9、Wi-Fi and Networking Changes
This preview introduces the following behavior changes to the Wi-Fi and networking APIs.
- Your apps can now change the state of
WifiConfiguration
objects only if you created these objects. You are not permitted to modify or deleteWifiConfiguration
objects created by the user or by other apps. - Previously, if an app forced the device to connect to a specific Wi-Fi network by using
enableNetwork()
with thedisableAllOthers=true
setting, the device disconnected from other networks such as cellular data. In this preview, the device no longer disconnects from such other networks. If your app’stargetSdkVersion
is“20”
or lower, it is pinned to the selected Wi-Fi network. If your app’stargetSdkVersion
is“21”
or higher, use the multinetwork APIs (such asopenConnection()
,bindSocket()
, and the newConnectivityManager.bindProcessToNetwork()
method) to ensure that its network traffic is sent on the selected network.
10、Camera Service Changes
In this preview, the model for accessing shared resources in the camera service has been changed from the previous “first come, first serve” access model to an access model where high-priority processes are favored.
11、Runtime
The ART runtime now properly implements access rules for the newInstance()
method. This change fixes a problem where Dalvik was checking access rules incorrectly in previous versions. If your app uses thenewInstance()
method and you want to override access checks, call the setAccessible()
method with the input parameter set to true
. If your app uses the v7 appcompat library or the v7 recyclerview library, you must update your app to use to the latest versions of these libraries. Otherwise, make sure that any custom classes referenced from XML are updated so that their class constructors are accessible.
This preview updates the behavior of the dynamic linker. The dynamic linker now understands the difference between a library’s soname
and its path (public bug 6670), and search by soname
is now implemented. Apps which previously worked that have bad DT_NEEDED
entries (usually absolute paths on the build machine’s file system) may fail when loaded.
The dlopen(3) RTLD_LOCAL
flag is now correctly implemented. Note that RTLD_LOCAL
is the default, so calls todlopen(3)
that didn’t explicitly use RTLD_LOCAL
will be affected (unless your app explicitly used RTLD_GLOBAL
). With RTLD_LOCAL
, symbols will not be made available to libraries loaded by later calls to dlopen(3)
(as opposed to being referenced by DT_NEEDED
entries).
12、APK Validation
The platform now performs stricter validation of APKs. An APK is considered corrupt if a file is declared in the manifest but not present in the APK itself. An APK must be re-signed if any of the contents are removed.
13、USB Connection
Device connections through the USB port are now set to charge-only mode by default. To access the device and its content over a USB connection, users must explicitly grant permission for such interactions. If your app supports user interactions with the device over a USB port, take into consideration that the interaction must be explicitly enabled.
14、Android for Work Changes
This preview includes the following behavior changes for Android for Work:
- Work contacts in personal contexts. The Google Dialer Call Log now displays work contacts when the user views past calls. Setting
setCrossProfileCallerIdDisabled()
totrue
hides the work profile contacts in the Google Dialer Call Log. Work contacts can be displayed along with personal contacts to devices over Bluetooth only if you setDevicePolicyManager.setBluetoothContactSharingDisabled()
tofalse
. By default, it is set totrue
. - WiFi configuration removal: WiFi configurations added by a Profile Owner (for example, through calls to the
addNetwork()
method) are now removed if that work profile is deleted. - WiFi configuration lockdown: Any WiFi configuration created by an active Device Owner can no longer be modified or deleted by the user if
Settings.Global.WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN
is non-zero. The user can still create and modify their own WiFi configurations. Active Device Owners have the privilege of editing/removing any WiFi configurations, including those not created by them. - Download Work Policy Controller via Google account addition: When a Google account that requires management via a Work Policy Controller (WPC) app is added to a device outside of a managed context, the add account flow now prompts the user to install the appropriate WPC. This behavior also applies to accounts added via Settings > Accounts and in the initial device setup wizard.
- Changes to specific DevicePolicyManager API behaviors:
- Calling the
setCameraDisabled()
method affects the camera for the calling user only; calling it from the managed profile doesn’t affect camera apps running on the primary user. - In addition, the
setKeyguardDisabledFeatures()
method is now available for Profile Owners, as well as to Device Owners. - A Profile Owner can set these keyguard restrictions:
KEYGUARD_DISABLE_TRUST_AGENTS
andKEYGUARD_DISABLE_FINGERPRINT
, which affect the keyguard settings for the profile’s parent user.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS
, which only affects notifications generated by applications in the managed profile.
- The
createAndInitializeUser()
andcreateUser()
methods have been deprecated. - The
setScreenCaptureDisabled()
method now also blocks the assist structure when an app of the given user is in the foreground. EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM
now defaults to SHA-256. SHA-1 is still supported for backwards compatibility but will be removed in future.EXTRA_PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM
now only accepts SHA-256.- Device initializer APIs which existed in the MNC preview are now removed. They will not appear in the final M release.
EXTRA_PROVISIONING_RESET_PROTECTION_PARAMETERS
is removed so NFC bump provisioning cannot programmatically unlock a factory reset protected device.- Android for Work APIs are optimized for M runtime permissions, including Work profiles, assist layer, and others. New
DevicePolicyManager
permission APIs don't affect pre-M apps.
- Calling the
- Changes to other APIs:
- Data Usage: The
android.app.usage.NetworkUsageStats
class has been renamedandroid.app.usage.NetworkStats
.
- Data Usage: The
- Changes to global settings:
- These settings can no longer be set via
setGlobalSettings()
:BLUETOOTH_ON
DEVELOPMENT_SETTINGS_ENABLED
MODE_RINGER
NETWORK_PREFERENCE
WIFI_ON
- These global settings can now be set via
setGlobalSettings()
:WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN
- These settings can no longer be set via
Android M新特性之Behavior Changes的更多相关文章
- 可能是最早的学习Android N新特性的文章
可能是最早的学习Android N新特性的文章 Google在今天放出了Android N开发者预览版.Android N支持Nexus6及以上的设备.5太子Nexus5不再得到更新. Android ...
- Android O新特性和行为变更总结zz
https://mp.weixin.qq.com/s/Ezfm-Xaz3fzsaSm0TU5LMw Android O 行为变更https://developer.android.google.cn/ ...
- Android N 新特性
2016年5月19日,谷歌在美国加州的山景城举办了 Google I/O 开发者大会中发布.2016年6月,Android N正式命名为“牛轧糖” 本届I/O开发者大会上,Google重点介绍了And ...
- 从开发者角度解析 Android N 新特性!
大清早看到 Google 官方博客发布 Android N 的开发者预览版,立马从床上跳起来开始仔仔细细的读起来. 从开发者角度来看,Android N 的更新并不算大.网上之前流传的一些 Andro ...
- Android R 新特性分析及适配指南
Android R(Android 11 API 30)于2020年9月9日正式发布,随国内各终端厂商在售Android设备的版本更新升级,应用软件对Android R 版本的兼容适配已迫在眉睫. 对 ...
- Android 13 新特性及适配指南
Android 13(API 33)于 2022年8月15日 正式发布(发布时间较往年早了一些),正式版Release源代码也于当日被推送到AOSP Android开源项目. 截止到笔者撰写这篇文章时 ...
- Android N 新特性 + APP开发注意事项
1. 多窗口MultiWindow 多窗口MultiWindow,这是Android N里对开发者影响比较大的特性,也是大家疑问比较多的地方.站在开发者的角度其实不必太担心这个特性会导致我们需要修改很 ...
- Android开发学习之路-Android N新特性-多窗口模式
我们都知道,在最新的Android N系统中,加入了一个新的功能,就是多窗口模式.多窗口模式允许我们在屏幕上显示两个窗口,每个窗口显示的内容不同,也就是说,我们可以一遍看电视剧,一边聊微信. 这里我们 ...
- Android M新特性之Permissions
User does not have to grant any permissions when they install or upgrade the app. Instead, the app r ...
随机推荐
- Proteus 8 画原理图仿真 1602 LCD显示字符
以下是源程序: #include <reg52.h> #include<intrins.h> /** * P2 上接的是 D1 ~ D7 */ sbit RS = P3 ^ ; ...
- linux查看修改线程默认栈空间大小(ulimit -s)
linux查看修改线程默认栈空间大小 ulimit -s 1.通过命令 ulimit -s 查看linux的默认栈空间大小,默认情况下 为10240 即10M 2.通过命令 ulimit -s 设置大 ...
- C#预处理器指令
在C#中有许多名为“预处理指令”的命令,这些命令从来不会转化为可执行代码中的命令,但会影响编译过程的各个方面.例如,使用预处理器指令可以禁止编译器编译代码的某一部分.如果计划发布两个版本的代码,即基本 ...
- 分布式算法系列——一致性Hash算法
摘自:http://www.blogjava.net/hello-yun/archive/2012/10/10/389289.html
- iOS - Mac OS X 终端命令
Mac OS X 终端命令 1)显示当前目录的路径 pwd 2)列出文件 ls 参数 目录名 参数: -w 显示中文,-l 详细信息, -a 包括隐藏文件,每一行开头是 "d" 则 ...
- Uiautomator ——API详解
版权声明:本文出自carter_dream的博客,转载必须注明出处. 转载请注明出处:http://www.cnblogs.com/by-dream/p/4921701.html 简单的例子 以一个简 ...
- Linux IO实时监控iostat命令详解
简介 iostat主要用于监控系统设备的IO负载情况,iostat首次运行时显示自系统启动开始的各项统计信息,之后运行iostat将显示自上次运行该命令以后的统计信息.用户可以通过指定统计的次数和时间 ...
- Java 实现word 中写入文字图片的解决方案
JAVA生成WORD文件的方法目前有以下两种方式: 一种是jacob 但是局限于windows平台 往往许多JAVA程序运行于其他操作系统 在此不讨论该方案; 一种是poi但是他的excel处理很程序 ...
- [分享] 晒一晒我的Windows7_SP1封装母盘(多图,附部分工具),老鸟飘过~
[分享] 晒一晒我的Windows7_SP1封装母盘(多图,附部分工具),老鸟飘过~ 大宝贝1 发表于 2012-8-9 18:01:57 https://www.itsk.com/thread-20 ...
- 习题-第5章Web自动化测试
一.选择题 二.判断题 三.填空题 四.简答题 五.设计题