install / uninstall APKs programmatically (by PackageManager)

NJDude

Expert
Licensed User
Longtime User
You can try this to Install:
B4X:
Dim i As Intent 

i.Initialize(i.ACTION_VIEW, "file:///sdcard/MyAPK.apk")
i.SetType("application/vnd.android.package-archive")

StartActivity(i)

To Uninstall:
B4X:
Dim i As Intent

i.Initialize("android.intent.action.DELETE", "package:com.example.app")

StartActivity(i)

Is that what you want to do?
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
NJDude, i know about this manual install\uninstall by Intents.
Question is for background installation\uninstallation APKs by the launcher that is a custom Market.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Yes, this application is planned to be main ROM launcher.
Must it be in system app folder evn for debugging ?
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
But links in my first post shows

public abstract void installPackage(
Uri packageURI, IPackageInstallObserver observer, int flags,
String installerPackageName);

public abstract void deletePackage(
String packageName, IPackageDeleteObserver observer, int flags);

Seems, there some people posted that used, and there is link to a working Eclipse code.
Do you mean now these functions cannot be tried anywhow with help of Reflection ?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Seems, real way is only by Shell commands to install\uninstall hidden.
 
Upvote 0

Dogbonesix

Active Member
Licensed User
Longtime User
Too manykeys, I guess

I was getting errors loading my first key and after many tries I believe there are several keys now. In fact I am not really sure how I got this far.

But my problem now is below:

Installation will fail if the signing key is different than the previous used key.
In that case you will need to manually uninstall the existing application.
Completed successfully.

I have two questions: 1) How do I manually uninstall the application?

Or

As the application is quite small - just recode (cut and paste) a new application with different package and application labels and start a new signing process?
 
Upvote 0

Dogbonesix

Active Member
Licensed User
Longtime User
See Above Post

I was looking too deep. Solution :signOops:too simple... Just delete the application on the phone not on B4A...
 
Upvote 0

Devv

Active Member
Licensed User
Longtime User
It is not possible to silently install or uninstall an APK unless your application is part of OS ROM.

You only need to have root access , i had tested this on multiple devices , no need for ROM integration so far ...
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
This is an old thread!!! Why are you ansering on an 2,5 years old thread?
If you have an issue then you should create a new thread
 
Upvote 0
Top