我试图检测某个应用是否支持Android Wear或是表情。
PackageManager pm = getActivity().getPackageManager();
List<PackageInfo> packs = pm.getInstalledPackages(0);
for (int i = 0; i < packs.size(); i++)
{}
代码是否正在使用。任何反馈或建议都会很棒!
答案 0 :(得分:0)
检查系统上是否存在Android Wear软件包:
public void foobar() {
boolean doesExist = isPackageInstalled("com.google.android.wearable.app");
}
private boolean isPackageInstalled(String packagename) {
PackageManager pm = getApplicationContext().getPackageManager();
try {
pm.getPackageInfo(packagename, PackageManager.GET_ACTIVITIES);
return true;
} catch (NameNotFoundException e) {
//swallow exception
return false;
}
}