Get list of installed applications within library Android
-
I've found this answer http://stackoverflow.com/questions/2695746/how-to-get-a-list-of-installed-android-applications-and-pick-one-to-run But it doesn't answer my problem completely, although I only have to find if a specific application is installed, I have no context in the library, so i can call getPackageManager() and get the list of applications. Are there any other way to do it? Maybe a Java only solution by searching in the Android file system? Please help!
-
Answer:
You will generally have to add Context parameter to your library API, to init function for example, and pass a Context from the application that uses it. However, there is a hackish workaround (single-line, to highlight that it's an ugly hack): if (Runtime.getRuntime().exec(new String[]{"/system/bin/sh","-c","cd /data/data/jackpal.androidterm"}).waitFor() == 0) { Log.d("!!!", "Android Terminal Emulator app is installed"); } This code will check if the private app directory exists in Andorid filesystem. You cannot list private directory of another app, or open any files from it, however you can check if the directory itself exists just by trying to chdir there.
Peter at Stack Overflow Visit the source
Related Q & A:
- What is Android studio library, how to add specific library and use it with my project?Best solution by stackoverflow.com
- Can Android be installed on iPhone?Best solution by wikihow.com
- How much would it cost to get my system installed by professional?Best solution by Yahoo! Answers
- How to get IE8 back? installed IE9 and hate it?Best solution by Yahoo! Answers
- What are some good free applications on the Android market?Best solution by play.google.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.