user1105115
user1105115

Reputation: 503

API missing from PackageManager

It's weird I found PackageManager has public APIs like installPackage(...)/deletePackage(...) although in the comment it's marked as Hide, here http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.2_r1.1/android/content/pm/PackageManager.java#PackageManager.deletePackage%28java.lang.String%2Candroid.content.pm.IPackageDeleteObserver%2Cint%29, but the reference page google provides hide this API.

So my question is how can I access such APIs?

Thank you all very much for help.

Kindest regards, Nessus.

Upvotes: 1

Views: 1242

Answers (2)

Darth Beleg
Darth Beleg

Reputation: 2667

In general you should not use "hidden" APIs in your applications. These methods are for internal usage and can be changed or even removed without notice. They are often not available for non-system applications due to permission restriction. If you want to use these APIs in your application then you may build your app within the platform build.

There is also a workaround to build application that uses hidden API in Eclipse: you can collect compiled framework libraries from the platform build and add them to build path as "User library", framework_intermediates/classes-full-debug.jar should be enough for the package manager.

Upvotes: 1

alex2k8
alex2k8

Reputation: 43214

It was declared as public just to simplify the SDK developers life. But it never was expected to be called by outside developers. See also this post.

But if you really need to call this method, you can use reflection. Thought I suggest to look around for an alternative solution using official API.

Upvotes: 1

Related Questions