1.对包名的判断,异常则说明不存在:
try {
PackageManager pm = getPackageManager();
pm.getPackageInfo(\"com.org\", PackageManager.GET_ACTIVITIES);
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
2.对类名的判断,异常则说明不存在:
try {
Class.forName(\"com.org.MainActivity\");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
return;
}
本文地址:https://www.stayed.cn/item/23846
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我