80,351
社区成员
发帖
与我相关
我的任务
分享
//系统应用路径(/system/app/)
final File path =new File( Environment.getRootDirectory(),"/app");
File file = new File(path, "/Launcher3");
if (!file.exists()) {
file = new File(path, "/Launcher");
}
if (file.exists()) {
//系统桌面路径
final String finalFile = file.getAbsolutePath();
ThreadPools.execute(() -> {
//单用户模式
String cmd="mount -o rw,remount /system";
//强制删除系统桌面
String delLauncher="rm -rf "+ finalFile;
//修改文件权限
String modifyPermissionsCmd="chmod 777 /system";
//移动app到system/app下
String moveCmd="cp " + getPackageResourcePath() + " " + path.getAbsolutePath();
//重启
String reboot ="reboot";
AppUtils.executeCmd(cmd,delLauncher,modifyPermissionsCmd,moveCmd,reboot);
});
}
ThreadPools是线程池,AppUtils.executeCmd是操作命令<activity android:name=".MainActivity">
<intent-filter>
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
这个让系统层面实现会简单很多
解决了没有啊,我也遇到了。。。
做个人吧。。。。。在这样搞 我们这行 就臭了
2L可以将系统桌面替换成应用界面,但是操作跳转到其他活动界面之后返回好像会重新走一遍主活动界面流程,导致一些变量重新初始化 [quote=引用 16 楼 立青_ 的回复:][quote=引用 12 楼 SentinEM 的回复:][quote=引用 10 楼 心的夙愿 的回复:]解决了没有啊,我也遇到了。。。
//系统应用路径(/system/app/)
final File path =new File( Environment.getRootDirectory(),"/app");
File file = new File(path, "/Launcher3");
if (!file.exists()) {
file = new File(path, "/Launcher");
}
if (file.exists()) {
//系统桌面路径
final String finalFile = file.getAbsolutePath();
ThreadPools.execute(() -> {
//单用户模式
String cmd="mount -o rw,remount /system";
//强制删除系统桌面
String delLauncher="rm -rf "+ finalFile;
//修改文件权限
String modifyPermissionsCmd="chmod 777 /system";
//移动app到system/app下
String moveCmd="cp " + getPackageResourcePath() + " " + path.getAbsolutePath();
//重启
String reboot ="reboot";
AppUtils.executeCmd(cmd,delLauncher,modifyPermissionsCmd,moveCmd,reboot);
});
}
2L可以将系统桌面替换成应用界面,但是操作跳转到其他活动界面之后返回好像会重新走一遍主活动界面流程,导致一些变量重新初始化 [quote=引用 12 楼 SentinEM 的回复:][quote=引用 10 楼 心的夙愿 的回复:]解决了没有啊,我也遇到了。。。
//系统应用路径(/system/app/)
final File path =new File( Environment.getRootDirectory(),"/app");
File file = new File(path, "/Launcher3");
if (!file.exists()) {
file = new File(path, "/Launcher");
}
if (file.exists()) {
//系统桌面路径
final String finalFile = file.getAbsolutePath();
ThreadPools.execute(() -> {
//单用户模式
String cmd="mount -o rw,remount /system";
//强制删除系统桌面
String delLauncher="rm -rf "+ finalFile;
//修改文件权限
String modifyPermissionsCmd="chmod 777 /system";
//移动app到system/app下
String moveCmd="cp " + getPackageResourcePath() + " " + path.getAbsolutePath();
//重启
String reboot ="reboot";
AppUtils.executeCmd(cmd,delLauncher,modifyPermissionsCmd,moveCmd,reboot);
});
}
ThreadPools是线程池,AppUtils.executeCmd是操作命令[/quote]没有其他回复就拿你的结帖了...
客户有需求是留有系统桌面,可输密退出[/quote]为啥一定要有系统桌面,如果只是简单的打开应用或简单功能,干脆写在自己的app里,说白了系统桌面也是App啊,把功能全写在自己的App,输密退出变成跳转到另一个活动2L可以将系统桌面替换成应用界面,但是操作跳转到其他活动界面之后返回好像会重新走一遍主活动界面流程,导致一些变量重新初始化 [quote=引用 10 楼 心的夙愿 的回复:]解决了没有啊,我也遇到了。。。
//系统应用路径(/system/app/)
final File path =new File( Environment.getRootDirectory(),"/app");
File file = new File(path, "/Launcher3");
if (!file.exists()) {
file = new File(path, "/Launcher");
}
if (file.exists()) {
//系统桌面路径
final String finalFile = file.getAbsolutePath();
ThreadPools.execute(() -> {
//单用户模式
String cmd="mount -o rw,remount /system";
//强制删除系统桌面
String delLauncher="rm -rf "+ finalFile;
//修改文件权限
String modifyPermissionsCmd="chmod 777 /system";
//移动app到system/app下
String moveCmd="cp " + getPackageResourcePath() + " " + path.getAbsolutePath();
//重启
String reboot ="reboot";
AppUtils.executeCmd(cmd,delLauncher,modifyPermissionsCmd,moveCmd,reboot);
});
}