The main app downloads another app and then uses it

What I want to do may be difficult to explain or understand, so I made a quick drawing. enter image description here

First of all, we have 2 Android apps. On display "Hello World" and B there is a button that (maybe) can download the application (on the Internet or locally).

When we press button B, download the app and install it (for example, if you download it in any market) and then use the app to change app B.

I don't know if this is possible:

  • To download the app and install it programmatically
  • Create an Android "polymorph" application.

If I need to summarize what I want with one sentence, it would be:
Modify app B with the app that B just downloaded and installed.

+3


source to share


2 answers


Then I'm pretty sure you can download those SDKs (apparently like the APK here) and use Fragment

either any input code or whatever.

You will probably need to use reflection though , because the main application "B" will not resolve the classes found in "A".



Maybe your "A" modules should expose the methods / variables / fragments it has, for example in an inline descriptive JSON asset, or something else that "B" can parse and know what to do.

Here, obviously, you need to move all of the "A" code away from "B", which means flexibility for "B".

+1


source


To download the app and install it programmatically:

Yes, you can do this programmatically, but the user will be prompted to install the app (for example, accept the permissions the new app will use).

    String filename = "yourAppName.apk";
    //trivial downloading asynctask
    DownloadApp appd = new DownloadApp(context, val, filename);
    if (appd.downnAndsave()) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setDataAndType(Uri.fromFile(new File(Environment
                        .getExternalStorageDirectory()
                        + "/download/"
                        + filename)),
                "application/vnd.android.package-archive");
        context.startActivity(intent);
    }

      



Create a "polymorph" Android app:

//if the download is complete then have a flag
//use this to run another application from your application B
    Intent intent = getPackageManager().getLaunchIntentForPackage("com.package.A");
    startActivity(intent);

      

0


source







All Articles