android开机广播时序,Android9.0 SystemUI 简介篇 (一)

public void onCreate() {

super.onCreate();

// Set the application theme that is inherited by all services. Note that setting the // application theme in the manifest does only work for activities. Keep this in sync with // the theme set there. // 设置主题 setTheme(R.style.Theme_SystemUI);

SystemUIFactory.createFromConfig(this);

if (Process.myUserHandle().equals(UserHandle.SYSTEM)) {

// SYSTEM 用户 // 监听开机广播 IntentFilter bootCompletedFilter = new IntentFilter(Intent.ACTION_BOOT_COMPLETED);

// 设置优先级 bootCompletedFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);

// 注册开机广播接收器 registerReceiver(new BroadcastReceiver() {

@Override

public void onReceive(Context context, Intent intent) {

if (mBootCompleted) return;

// 移除本接收器 unregisterReceiver(this);

mBootCompleted = true;

if (mServicesStarted) {

final int N = mServices.length;

for (int i = 0; i < N; i++) {

mServices[i].onBootCompleted();

}

}

}

}, bootCompletedFilter);

// 监听语言改变并更新 SystemUi 的通知渠道 IntentFilter localeChangedFilter = new IntentFilter(Intent.ACTION_LOCALE_CHANGED);

registerReceiver(new BroadcastReceiver() {

@Override

public void onReceive(Context context, Intent intent) {

if (Intent.ACTION_LOCALE_CHANGED.equals(intent.getAction())) {

if (!mBootCompleted) return;

// Update names of SystemUi notification channels NotificationChannels.createAll(context);

}

}

}, localeChangedFilter);

} else {

// We don't need to startServices for sub-process that is doing some tasks. // (screenshots, sweetsweetdesserts or tuner ..) String processName = ActivityThread.currentProcessName();

ApplicationInfo info = getApplicationInfo();

if (processName != null && processName.startsWith(info.processName + ":")) {

return;

}

// For a secondary user, boot-completed will never be called because it has already // been broadcasted on startup for the primary SystemUI process. Instead, for // components which require the SystemUI component to be initialized per-user, we // start those components now for the current non-system user. // 第二用户启动的服务 startSecondaryUserServicesIfNeeded();

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值