安卓7 java_[RK3399] android7.1 设置开机启动apk

平台:

RK3399+android7.1

开机启动apk

(1)修改类:

./frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java

(2)修改代码位置:

boolean startHomeActivityLocked(int userId, String reason) {

if (mFactoryTest == FactoryTest.FACTORY_TEST_LOW_LEVEL

&& mTopAction == null) {

// We are running in factory test mode, but unable to find

// the factory test app, so just sit around displaying the

// error message and don't try to start anything.

return false;

}

Intent intent = getHomeIntent();

ActivityInfo aInfo = resolveActivityInfo(intent, STOCK_PM_FLAGS, userId);

if (aInfo != null) {

intent.setComponent(new ComponentName(aInfo.applicationInfo.packageName, aInfo.name));

// Don't do this if the home app is currently being

// instrumented.

aInfo = new ActivityInfo(aInfo);

aInfo.applicationInfo = getAppInfoForUser(aInfo.applicationInfo, userId);

ProcessRecord app = getProcessRecordLocked(aInfo.processName,

aInfo.applicationInfo.uid, true);

if (app == null || app.instrumentationClass == null) {

intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);

mActivityStarter.startHomeActivityLocked(intent, aInfo, reason);

}

} else {

Slog.wtf(TAG, "No home screen found for " + intent, new Throwable());

}

//完全开机后启动app

startAppOrService(mContext,"com.tencent.mm");

return true;

}

(3)启动apk方法:

/**

* start 新增启动第三方应用的方法

*/

private void startAppOrService(Context context,String appPackage) {

PackageManager doupackageManager = context.getPackageManager();

Intent intent = new Intent();

try{

intent = doupackageManager.getLaunchIntentForPackage(appPackage);

if(intent!=null){

context.startActivity(intent);

Slog.wtf(TAG,"startApp="+appPackage);

}else{

Slog.wtf(TAG,"startApp=null");

}

}catch(Exception e){

Slog.wtf(TAG,"startApp_exception");

}

}

本文地址:https://blog.csdn.net/qq_32014215/article/details/107566544

希望与广大网友互动??

点此进行留言吧!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值