How to install apk file without user intervention on custom system?

399 Views Asked by At

Now, I've see this type of question posted a few times but they were aimed at developers trying to do this on a smart phone or tablet. What I have here is a custom built system with root privileges and I can modify the underlying Android if need be. I have code that downloads the APK file and I can use the following (which I found bits of code on here for) but it still brings up a dialog box needing confirmation. This is not really possible as my system is designed to run unattended in remote locations so I need a way to update fully without user intervention.

Intent intent = new Intent();
intent.setAction(Intent.ACTION_INSTALL_PACKAGE);
String str = "file://" + Environment.getExternalStorageDirectory() + "/updates/AX9100-DG.apk";
try
{
    intent.setDataAndType(Uri.parse(str), "application/vnd.android.package-archive");

    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
    return;
}
catch (Exception exception)
{
    Log.d("UpdateTask", exception.getMessage());
}

Is this at all possible if I somehow can modify the underlying AOSP for this custom system?

0

There are 0 best solutions below