Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android check for dependent application during installation?

I want to publish my application (ABC). Its an audiobook file(just for example.) wrapped as apk. When the user install this application it needs to check whether another application (XYZ) already installed or not. If not let the user know they have to install the application XYZ first before installing ABC.

Thanks in advance

Rajesh

like image 586
user278445 Avatar asked Mar 25 '10 19:03

user278445


2 Answers

If you know the package name of the application you are looking for you can use the PackageManager to test for the existence of an application.

try{
     ApplicationInfo info = getPackageManager()
                             .getApplicationInfo("com.myproject", 0 );
     //-- application exists
    } catch( PackageManager.NameNotFoundException e ){
     //-- application doesn't exist
}
like image 122
JeremyFromEarth Avatar answered Oct 15 '22 11:10

JeremyFromEarth


In case XYZ is a shared library, you may set-up the android manifest of your application to prevent users installing ABC without XYZ. Please use the element inside the AndroidManifest.xml of ABC, by stating:

<uses-library android:name="package name of XYZ" android:required="true" />

Hope this help your problem.

like image 35
Livio Avatar answered Oct 15 '22 11:10

Livio