-1

I want to "pack" two applications in one Android APK file. Requirements:

  • When I install an APK fil it installs to separate apps.
  • If I uninstall an app, the other app would still remain installed.

Can I do it like that?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Andrei
  • 42,814
  • 35
  • 154
  • 218
  • try this it might help you [http://stackoverflow.com/questions/10682576/one-apk-file-that-installs-two-apps] – knownUnknown Jan 14 '17 at 06:47
  • Possible duplicate of [One .apk file that installs two apps](http://stackoverflow.com/questions/10682576/one-apk-file-that-installs-two-apps) – David Rawson Jan 14 '17 at 07:53

1 Answers1

0

First upload those apps which you want to be installed at Dropbox (only). Now obtain links of those APK files and in the link replace dropbox.com/..... with d.dropboxusercontent.com/...

Now, make an app and place the below code at "onCreate" or somewhere,

String destination = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/";
    String fileName = "AppName.apk";
    destination += FileName;
    final Uri uri = Uri.parse("file://" + destination);

    String URL = "d.dropboxusercontent.com/...............";

    DownloadManager.Request request = new DownloadManager.Request(Uri.parse(URL));
            request.setDescription(Main.this.getString(R.string.notification_description));
            request.setTitle(Main.this.getString(R.string.app_name));

            // Set destination
            request.setDestinationUri(uri);

            // Get download service and enqueue file
            final DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
            final long downloadId = manager.enqueue(request);

            // Set BroadcastReceiver to install app when .apk is downloaded
            BroadcastReceiver onComplete = new BroadcastReceiver() {
                public void onReceive(Context ctxt, Intent intent) {
                    Intent install = new Intent(Intent.ACTION_VIEW);
                    install.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    install.setDataAndType(uri,
                            manager.getMimeTypeForDownloadedFile(downloadId));
                    startActivity(install);

                    unregisterReceiver(this);
                    finish();
                }
            };

            // Register receiver for when .apk download is complete
            registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));

If you want to install multiple apps, then you can apply this code multiple times by changing variable names.

Please comment if it worked.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131