android 系统开机向导apk 初始化后的开机引导app 屏蔽home键
<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.android.provision">...<application><activityandroid:name="DefaultActivity"android:theme="@android:style/
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.provision">
...
<application>
<activity
android:name="DefaultActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
android:excludeFromRecents="true">
<intent-filter android:priority="1">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.SETUP_WIZARD" />
</intent-filter>
</activity>
</application>
</manifest>
1、 <category android:name="android.intent.category.SETUP_WIZARD" />
可以运行在launcher之前的apk、
2、 接下来看下这个app除了显示引导界面,还要做什么
在最后,保存了设备开机引导的状态,
private void finishSetupWizard() {
// Add a persistent setting to allow other apps to know the device has been provisioned.
Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1);
PackageManager pm = getPackageManager();
if (pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK) == true) {
Settings.Secure.putInt(getContentResolver(), Settings.Secure.TV_USER_SETUP_COMPLETE, 1);
}
// remove this activity from the package manager.
ComponentName name = new ComponentName(this, DefaultActivity.class);
pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
finish();
}
3、android HOME键失效!
其实我们还可以发现,当导航app未设置完成时HOME键是不起作用的,原因就是状态控制了, Settings.Secure.USER_SETUP_COMPLETE
这样用户就不能够跳过第一次的开机设置了。
中的isUserSertupComplete()函数其实就是对一些按键的响应添加了判断条件
boolean isUserSetupComplete() {
boolean isSetupComplete = Settings.Secure.getIntForUser(mContext.getContentResolver(),
Settings.Secure.USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0;
if (mHasFeatureLeanback) {
isSetupComplete &= isTvUserSetupComplete();
}
return isSetupComplete;
}
i
更多推荐
所有评论(0)