开发者

Android check for dependent application during installation?

开发者 https://www.devze.com 2022-12-24 08:47 出处:网络
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 (XY

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号