How can I install a “bundle” of applications (apk's) on device with prompting user only once

My application is based on multiple applications (each one has different apk signatures). I want to install one apk and after one confirmation the device should install all applications in the "bundle".

I managed to install the bundle of applications but after every installation I have a confirmation before installing(see below).

I need this to be a seamless process where the user will only have to confirm the installation process only once.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    installAPK(R.raw.apk0, 0);
}

private void installAPK(int apk, int apk_code) {
    try {


        InputStream in = this.getResources().openRawResource(apk);

        byte[] b = new byte[in.available()];

        int read = in.read(b);

        // String tempFileName = "currentapk.apk";

        FileOutputStream fout = openFileOutput(tempFileName,
                MODE_WORLD_READABLE);

        fout.write(b);
        fout.close();
        in.close();

        File tempFile = getFileStreamPath(tempFileName);

        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(tempFile),
                "application/vnd.android.package-archive");
        startActivityForResult(Intent.createChooser(intent, "install"),
                apk_code);
    }

    catch (Exception ex) {
        ex.printStackTrace();
    }
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    File tempFile = getFileStreamPath(tempFileName);

    if (tempFile.delete()) {
        Log.d("******PACKAGING******", "FILE DELETED!");
    }

    switch (requestCode) {
    case 0: {

        installAPK(R.raw.apk1, 1);
        break;
    }

    case 1: {
        installAPK(R.raw.apk2, 2);
        break;
    }
          case 2: {
        installAPK(R.raw.apk3, 3);
        break;
    }

Any idea how I can get this to install with prompting the user only once?

Answers


I need this to be a seamless process where the user will only have to confirm the installation process only once.

Fortunately, this is not possible -- as zapi notes, for security reasons. Users have the right to know what is being installed and to have the ability to say "no, I do not want that".

Of course, you are welcome to create your own ROM mod that has all these apps built in, then convince people to install that ROM. This eliminates the per-app user choice. A business that wishes to distribute devices with apps pre-installed would go this route, not only to avoid the prompting, but to prevent people from uninstalling those apps once they get their modded device.


Need Your Help

Mockito methods are not accessible

mockito

I have mockito setup on my project with this maven lines:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.