//構造context,繞過通常包名簽名驗證。 try { CheckPermissionUtil.getSingInfo( this.createPackageContext("com.android.phone", Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY)); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); }
//獲取getBasePackageName包名 獲取context實際包名。 public static String getBasePackageName(Context context) { String value = null; try { Class<?> c = Class.forName("android.content.Context"); Method method = c.getMethod("getBasePackageName"); method.setAccessible(true);//設置訪問權限 value = (String) (method.invoke(context)); } catch (Exception e) { e.printStackTrace(); } finally { return value; } }