Accessing android:installLocation manifest attribute

前端 未结 4 1260
小鲜肉
小鲜肉 2021-01-02 20:15

I\'m trying to write an Android 2.2 app that will find installed apps that can be moved to the SD card. The permission to do this is encoded in the AndroidManifest.xml file

4条回答
  •  [愿得一人]
    2021-01-02 20:30

    You may access this attribute by next example:

    PackageInfo packageInfo = context.getPackageManager().getPackageInfo(mPackageName, 0);
    if (packageInfo.installLocation != PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY) {
        .....
    }
    

    http://developer.android.com/reference/android/content/pm/PackageInfo.html#installLocation
    was introduced in API 21

    But this field exists even in Android 2.3 http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3_r1/android/content/pm/PackageInfo.java/

提交回复
热议问题