0

I'm trying to figure out how to install an APK programmatically without it showing up in the all/manage apps - the listing of apps/icons.. etc

I've put together a game with Corona, but unfortunately Corona does not have any integration with c2dm yet and the devs never answer forum questions regarding it.. soooo.. i put together a app in eclipse that on startup logs the device with c2dm and then opens my game. Works fine, I get the notifications from my site... Problem is though there is now 2 apps listed in the manage apps for my game. I only need the first app that registers with c2dm listed. If the user opens the game directly their device won't be logged into c2dm.

Steve

  • 1
    This is not supported. If you want to only have one apk visible, you need to build all your functionality into it. That's barely more than a copy-and-paste of the components from your additional tree, and a few slight fixups. – Chris Stratton Apr 28 '12 at 20:00
  • if I could do that I would. Corona is done in Lua. When I decompile the apk I get .smali files, with obfuscation as far as I can tell. I assuming they do that, keeps people from using their free version for full on apps. I've been banging this around my head for the last week... Not being able to do push is pretty sad. Ansca is mostly all apple... its a trickle on the android side. I know one person with an Iphone and about 40 with android(s) – user1363325 Apr 29 '12 at 03:52
  • You actually could merge the smali files with those from decompiling a separate project. Hand edit the manifests together and rebuild. Trying to think if there are any other areas that would need fixing. – Chris Stratton Apr 29 '12 at 04:03
  • ok.. but wouldn't the activity(s) of the 2 apps clash? I've been at this whole android/java/eclipse deal now for the last week. I do stuff mostly in c# – user1363325 Apr 29 '12 at 04:59
  • No, you can have lots of activities in an app (though the names have to be unique). If there's going to be an issue it's going to be with combining or paralleling R.java, though if you use different package names for each source project you may get away with having one in each? – Chris Stratton Apr 29 '12 at 05:05
  • ok.. I'm gonna give this a try. Thankyou Chris, is it possible to give you the answer cred for this? – user1363325 Apr 29 '12 at 05:09
  • By the time you get it working it will be as much your answer as mine, and you will be in a better position to write up exactly what you had to do. BTW you will probably have to look up the commands to sign the rebuilt apk by hand. Also use fully qualified names (no relative to .) in the intent filters in the manifest - you'd hit that issue if you were combining them at original source level, too. – Chris Stratton Apr 29 '12 at 05:16
  • I've already been decompiling and recompiling and then signing the apps again.. all week... it will have to be a crapshot for the names, The apk from corona isn't anything I can change – user1363325 Apr 29 '12 at 05:34

2 Answers2

0

If you mean installing an apk programatically, then use intents

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() +    "/where/apk/is/stored/app.apk")), "application/vnd.android.package-archive");
startActivity(intent);  

If you dont want it to show on the list of apps (it will however be shown on Settings / Apps, but not on launcher), you can just remove from the manifest

action android:name="android.intent.action.MAIN"
category android:name="android.intent.category.LAUNCHER"

Source: Android: install .apk programmatically

Community
  • 1
  • 1
user809486
  • 888
  • 1
  • 7
  • 15
0

Problem is though there is now 2 apps listed in the manage apps for my game.

Correct. This is a good thing. And, fortunately for the user, it is a requirement -- malware authors would be very interested in being able to be installed and not be uninstalled, for example.

I only need the first app that registers with c2dm listed.

The user needs both listed, so the user can uninstall either app, force stop either app, keep track of your storage in both apps, etc.

If the user opens the game directly their device won't be logged into c2dm.

Then your app needs to handle this appropriately. Your game hopefully is not relying upon C2DM, anyway, since C2DM is unreliable (messages delayed, messages lost, etc.) and is not available on all devices (e.g., Kindle Fire).

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • the first app is closed out after it calls the second app "game" ( finish(); ) I'm not using c2dm for the game play, I have that all going thru my website... only push notifications for game play changes (ie: "It's Your Turn!") – user1363325 Apr 29 '12 at 03:05
  • @user1363325: "only push notifications for game play changes" -- again, unless you are willing to skip a turn, or have an hour pass between turns, C2DM is not a great choice for this. If you are already having game logic run through your Web site, I would have "game play changes" be handled that way as well (polling, WebSockets, etc.). – CommonsWare Apr 29 '12 at 10:21
  • I was only going to use c2dm for when the user didn't have the app actively running. Corona doesn't have a way currently to post notifications, even if the app is running. So polling and etc... aren't going to do me any good. I'm just going to finish this game out and move on the Marmalade... native c++, didn't come across it till yesterday. thanks for the help – user1363325 Apr 30 '12 at 16:00