Android 2 apps in 1

346
January 14, 2017, at 2:53 PM

Please help me with this: I want to "pack" 2 applications in 1 Android apk. With requirements:

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

Can I do it like that?

Answer 1

First upload those apps which you want to be installed at DROPBOX (only). Now obtain links of those apks and in the link replace dropbox.com/..... into 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 compete
            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.

Rent Charter Buses Company
READ ALSO
My app runs on every device except samsung devices

My app runs on every device except samsung devices

I almost completed my appIt runs on every device except samsung device every version

312
Implementing actions to CardViews other than the one clicked

Implementing actions to CardViews other than the one clicked

Lets say I have 3 cards: A, B, CIf I click on card C, do something, and at the same time for A and B, do something else

283
ListView with If statement

ListView with If statement

I have a ListView that display numbersThe user should press on an item and gets to other activity

453
Resize ImageView container to exactly match an image that gets placed inside of it

Resize ImageView container to exactly match an image that gets placed inside of it

I have an ImageView that is set to a width of match_parent, a height of wrap_content and a scaletype of centerInsideI then, in the code, place a horizontal rectangular bitmap inside of it and the bitmap fills the width correctly

376