Skip to content

Instantly share code, notes, and snippets.

@jrichardsz
Last active February 12, 2017 19:34
Show Gist options
  • Select an option

  • Save jrichardsz/1c24501766ed02c6049ce2bc5696d5eb to your computer and use it in GitHub Desktop.

Select an option

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
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