Last active
February 12, 2017 19:34
-
-
Save jrichardsz/1c24501766ed02c6049ce2bc5696d5eb to your computer and use it in GitHub Desktop.
Fix to ERROR No package identifier when getting value for resource number in min3d framework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package android.common; | |
| import android.content.Context; | |
| import android.content.pm.ApplicationInfo; | |
| import android.content.pm.PackageManager; | |
| import android.util.Log; | |
| import java.io.File; | |
| /** | |
| * Created by jrichardsz on 12/02/2017. | |
| */ | |
| public class ResourceUtils { | |
| public static String getGlobalResourcePackageIdentifier(Context context) throws Exception { | |
| String packageName = context.getPackageName(); | |
| PackageManager pm = context.getPackageManager(); | |
| try { | |
| ApplicationInfo ai = pm.getApplicationInfo(packageName, 0); | |
| String apk = ai.dataDir; | |
| return apk.substring(apk.lastIndexOf(File.separator)+1); | |
| } catch (Throwable x) { | |
| throw new Exception("Failed when try to get global package identifier",x); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment