android applicationinfo类中怎么获取包名
1个回答
展开全部
我
public static int getVerCode(Context context) {
int verCode = -1;
try {
verCode = context.getPackageManager().getPackageInfo(
"包名", 0).versionCode;
} catch (NameNotFoundException e) {
Log.e("msg", e.getMessage());
}
return verCode;
}
public static String getVerName(Context context) {
String verName = "";
try {
verName = context.getPackageManager().getPackageInfo(
"包名", 0).versionName;
} catch (NameNotFoundException e) {
Log.e("msg", e.getMessage());
}
return verName;
}
public static int getVerCode(Context context) {
int verCode = -1;
try {
verCode = context.getPackageManager().getPackageInfo(
"包名", 0).versionCode;
} catch (NameNotFoundException e) {
Log.e("msg", e.getMessage());
}
return verCode;
}
public static String getVerName(Context context) {
String verName = "";
try {
verName = context.getPackageManager().getPackageInfo(
"包名", 0).versionName;
} catch (NameNotFoundException e) {
Log.e("msg", e.getMessage());
}
return verName;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询