我使用这种方式安装apk
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory(),"Hello.apk")), "application/vnd.android.package-archive");
startActivity(i);
会弹出一个对话框提示是否安装这个Hello.apk有没有办法不弹出对话框,直接安装?

解决方案 »

  1.   

    没有!这是android系统必须运行的,屏蔽不了!
      

  2.   

    静默安装应该是可以的,google下静默安装吧
      

  3.   

    静默安装:
    new Thread() {
    public void run()
    {
    Process process = null;
    InputStream in = null;
    try
    {
    // 请求root
    process = Runtime.getRuntime().exec(
    "pm install -r " + apkName + "\n");
    in = process.getInputStream();
    int len = 0;
    byte[] bs = new byte[256];
    while (-1 != (len = in.read(bs)))
    {
    String state = new String(bs, 0, len);
    if (state.equals("Success\n"))
    {
    // 安装成功后的操作 }
    } libFile.delete();
    apkFile.delete();
    try
    {
    Thread.sleep(1000);
    } catch (InterruptedException e)
    {
    }
    } catch (Exception e)
    {
    } finally
    {
    try
    {
    if (in != null)
    {
    in.close();
    }
    } catch (IOException e)
    {
    }
    }
    }
    }.start();
    加权限,但是动态点击一样的不行