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 a开发者_开发百科pplication (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
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
}
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.
精彩评论