當前位置:首頁 » 安卓系統 » android程序靜默安裝

android程序靜默安裝

發布時間: 2023-05-10 14:28:25

『壹』 Android 靜默安裝和自啟動(1、Root環境下)

各種以android硬體平台為基礎的【公示屏】、【廣告屏】等等,雖然很少有升級,但是不可避免的會遇到,而此類APP的使用場景,一般沒人會去幫助你版本更新,點擊安裝,故而需要:靜默安裝。

1、確認安裝包是否存在,並可讀寫
2、隱示啟動:action和data的schema來控制彈出安裝工具類APP,然後點擊安裝...
3、升級完:BootReceiver 監聽到Intent.ACTION_PACKAGE_REPLACED,然後自啟動

靜默安裝apk介面,無需開放root,也無需system許可權。

『貳』 android如何實現靜默安裝哦

原理

  • 靜默安裝、卸載的原理就是利用pm install命令來安裝apk,pm uninstall 來卸載apk.

  • 智能安裝是利用android系統提供的無障礙服務AccessibilityService,來模擬用戶點擊,從而自動安裝.

java">//靜默安裝
privatevoidinstallSlient(){
Stringcmd="pminstall-r/mnt/sdcard/test.apk";
Processprocess=null;
DataOutputStreamos=null;
BufferedReadersuccessResult=null;
BufferedReadererrorResult=null;
StringBuildersuccessMsg=null;
StringBuildererrorMsg=null;
try{
//靜默安裝需要root許可權
process=Runtime.getRuntime().exec("su");
os=newDataOutputStream(process.getOutputStream());
os.write(cmd.getBytes());
os.writeBytes(" ");
os.writeBytes("exit ");
os.flush();
//執行命令
process.waitFor();
//獲取返回結果
successMsg=newStringBuilder();
errorMsg=newStringBuilder();
successResult=newBufferedReader(newInputStreamReader(process.getInputStream()));
errorResult=newBufferedReader(newInputStreamReader(process.getErrorStream()));
Strings;
while((s=successResult.readLine())!=null){
successMsg.append(s);
}
while((s=errorResult.readLine())!=null){
errorMsg.append(s);
}
}catch(Exceptione){
e.printStackTrace();
}finally{
try{
if(os!=null){
os.close();
}
if(process!=null){
process.destroy();
}
if(successResult!=null){
successResult.close();
}
if(errorResult!=null){
errorResult.close();
}
}catch(Exceptione){
e.printStackTrace();
}
}
//顯示結果
tvTest.setText("成功消息:"+successMsg.toString()+" "+"錯誤消息:"+errorMsg.toString());
}

『叄』 如何實現Android APP靜默安裝

8.1. 靜默安裝包(Silent Installation): 所謂靜默安裝包,有這么幾個特點:安裝過程沒有界面;安裝過程不需要用戶進行任何輸入;也不會在Taskbar中顯示一個安裝程序的Icon。 如何創建一個靜默安裝包: 1. 靜默安裝包的製作是在主程序完成後進行的,先錄制靜默腳本文件,通過在命令行運行安裝包Setup.exe 給入參數/r,這時會啟動的依然是有界面操作的安裝,按照正常操作方式完成安裝。 2. 完成上一步之後,會在系統的Windows或WINNT文件夾下產生一個Setup.iss文件(可以通過按照時間排序查找),將此文件復制到Setup.exe同一目錄下,改名為Setup.iss.install(靜默安裝腳本)。 3. 繼續在命令行執行Setup.exe /r,完成後將新生成的Setup.iss文件同樣復制到Setup.exe目錄下,改名為Setup.iss.uninstall(靜默卸載腳本)。 運行靜默安裝包: 1. Setup.exe /s f1"Setup.iss.install的路徑" f2「指定生成靜默安裝Log的路徑」 如果不通過f2指定log路徑,則會在setup.exe同路徑下生成一個Setup.log的文件。 2. 靜默卸載調用方法同1。 =====================================

『肆』 android沒有root的情況下怎麼實現靜默安裝

手機ROOT方法:x0dx0a1、下載安裝KingRoot 電腦版x0dx0a2、用USB數據線連接手機Root過程中,保持手機連接PCx0dx0a3、按提示開始Root操作整個過程需要5-10分鍾x0dx0a4、Root成功!x0dx0ax0dx0a註:手機ROOT之後是不在保修條約裡面的,需要解除ROOT許可權即可。

『伍』 android在root許可權下實現apk的靜默卸載,靜默安裝,重啟

1.靜默卸載實現:

/**

    * 靜默卸載app

    *

    * @param context

    * @param packageName app的包名

    * @throws IOException

    * @throws InterruptedException

    */

    public static void uninstallApp(Context context, String packageName) throws IOException, InterruptedException {

        List<PackageInfo> packageInfos = context.getPackageManager().getInstalledPackages(PackageManager.GET_ACTIVITIES);

        for (PackageInfo packageInfo1 : packageInfos) {

            if (packageName.equals(packageInfo1.packageName)) {

                String suPath = "/system/xbin/su";

                File file = new File(suPath);

                if (!file.exists()) {

                    suPath = "/system/bin/su";

                }

                Process process = Runtime.getRuntime().exec(suPath);

                String cmd = "pm uninstall " + packageName + "\n" + "exit\n";

                process.getOutputStream().write(cmd.getBytes());

                process.waitFor();

                break;

            }

        }

    }

2.靜默安裝實現:

/**

    * 靜默安裝app

    *

    * @param filePath

    * @throws IOException

    * @throws InterruptedException

    */

    public static void installApp(String filePath) throws IOException, InterruptedException {

        String suPath = "/system/xbin/su";

        File file = new File(suPath);

        if (!file.exists()) {

            suPath = "/system/bin/su";

        }

        Process process = Runtime.getRuntime().exec(suPath);

        String cmd = "pm install -r " + filePath + "\n" + "exit\n";

        process.getOutputStream().write(cmd.getBytes());

        process.waitFor();

    }

最後加上重啟命令:

/**

    * 重啟系統

    *

    * @return

    */

    public static boolean reboot() {

        try {

            String suPath = "/system/xbin/su";

            File file = new File(suPath);

            if (!file.exists()) {

                suPath = "/system/bin/su";

            }

            Process process = Runtime.getRuntime().exec(suPath);

            String cmd = "reboot\nexit\n";

            process.getOutputStream().write(cmd.getBytes());

            return true;

        } catch (IOException error) {

            return false;

        }

    }

注意卸載和安裝需要在子線程中執行;如果單純關機則用「reboot -p」命令。

『陸』 安卓手機如何實現靜默安裝軟體

實現是容易的,後果是嚴重的。
一旦開啟靜默安裝模式,病毒和黑客程序基本上在你的手機上就可以長驅直入了。
不建議開。

給軟體root許可權就可以靜默安裝。比如安卓市場就可以。

熱點內容
安卓怎麼錄屏只錄一點 發布:2025-05-19 17:12:39 瀏覽:521
甘肅移動服務密碼在哪裡 發布:2025-05-19 17:11:15 瀏覽:541
java內部類訪問外部類方法 發布:2025-05-19 17:10:30 瀏覽:286
用解壓造句 發布:2025-05-19 17:01:55 瀏覽:341
openwrt編譯取消跑碼 發布:2025-05-19 16:50:28 瀏覽:125
知道了寬頻賬號密碼如何連接 發布:2025-05-19 16:49:49 瀏覽:656
時間輪資料庫 發布:2025-05-19 16:45:20 瀏覽:269
ipad緩存垃圾怎麼清理 發布:2025-05-19 16:44:46 瀏覽:536
視頻加解壓 發布:2025-05-19 16:35:28 瀏覽:7
c語言大學教程第六版 發布:2025-05-19 16:04:21 瀏覽:741