3

What I want to do is maybe hard to explain or to understand so I made a quick drawing.enter image description here

First of all, we have 2 Android apps. A display "Hello World" and B has a button which (maybe) can download an app (on web or local).

When we click on B button, that download A app, and install it (like if you download it with any market) and then, use A app to modify B app.

I don't know if it's even possible :

  1. To download app and install it programmatically
  2. Create a "polymorph" Android app like that.

If I have to sum up what I want with one sentence it would be :
Modify B application with A app which B just downloaded and installed.

  • Is "A" an application or an extension/plugin? BTW the way I can think of to make that work with an *application* would be to just detect its presence and activate new things in "B", just like a "pro to unlock feature" app. – shkschneider Jun 17 '15 at 08:29
  • A is an app, I mean B has to download a SDK then install it. Then B have to "morph" with A comportement – Alexandre Baptiste Jun 17 '15 at 08:34

2 Answers2

1

I'm then sure you can download those SDK (apparently as APK here) and use Fragments or any code to inject or something.

Probably will need to use reflection though, because you main application "B" won't resolve the classes that are in "A".

Maybe your "A" modules should expose the methods / variables / fragments it has, like in an embedded JSON descriptive asset or something, that "B" could parse and know what to do with.

The point here is obviously to move all the "A" code away from "B", meaning flexibility for "B".

shkschneider
  • 17,833
  • 13
  • 59
  • 112
  • I was thinking the same way but i don't really know how to do that. I think that A must contain some stored code or idk what – Alexandre Baptiste Jun 17 '15 at 08:49
  • Of course it will have code. If you want something more refine than plain Activities, I only see my option, which indeed involves a bit of work: come on, you are injecting an application into another :) – shkschneider Jun 17 '15 at 08:55
  • Yeah :p That's a subject for my traineeship, i'm still a bit new with Android i have to work hard ^-^ – Alexandre Baptiste Jun 17 '15 at 08:57
  • What you are trying to do is *not* easy job. Define more what you what "A" to integrate into "B" so we could help further: inject Fragments, Activity, Objects, Statics?.. – shkschneider Jun 17 '15 at 09:02
  • The fact is that i have nothing defined yet. I have to make my app B evolve du to A, nothing specific asked, i have to discover or know if that's possible and with which way – Alexandre Baptiste Jun 17 '15 at 11:55
  • "Maybe your "A" modules should expose the methods / variables / fragments it has, like in an embedded JSON descriptive asset or something, that "B" could parse and know what to do with" I think that's exatcly what I need but now i need to find how to do ^-^ – Alexandre Baptiste Jun 17 '15 at 11:59
0

To download app and install it programmatically:

Yes you can do it programmatically but the user will be prompted to install the app(like accepting 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 like that:

//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);
Gun2sh
  • 870
  • 12
  • 22
  • Can I download an app from a server? And with polymorph, i mean, B has to change with A comportment, but still see B comportement aswell. With your solution, A will completly replace B no? – Alexandre Baptiste Jun 17 '15 at 08:48
  • No it wont replace B, Have you used Teamviewer Quicksupport application in android?it has the similar feature that you asked. It downloads another app but it cant replace the old one as you cannot uninstall an app with another – Gun2sh Jun 17 '15 at 09:05
  • You can still see [this](http://stackoverflow.com/questions/12771444/how-to-self-uninstall-an-app) – Gun2sh Jun 17 '15 at 09:06
  • I don't want to uninstall my old. I want my "old" app to evolve with the downloaded one – Alexandre Baptiste Jun 17 '15 at 11:48