Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory(),"Hello.apk")), "application/vnd.android.package-archive");
startActivity(i);
will pop up a dialog box prompts whether to install this Hello.apk
There is no way to suppress the dialog box, direct installation?
------ Solution ---------------------------------------- ----
silent installation should be possible, google it under the silent installation
------ Solution --------------------- -----------------------
landlord to such a request, it should be required to use the silent installation
------ For reference only ---------------------------------------
no! This is the android system must be running the shield can not!
------ For reference only -------------------------------------- -
silent installation permissions too demanding
------ For reference only -------------------------- -------------
silent installation:
new Thread () {
public void run ()
{
Process process = null;
InputStream in = null;
try
{
/ / Request 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"))
{
/ / After the successful installation of the operating
}
}
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 ();
add permissions, but not the same dynamic click
没有评论:
发表评论