在执行以下代码时,我没有com.android.bluetooth
在 android 4.2.1 中获得,但是当我在 4.1.2 中执行相同的代码时com.android.bluetooth
,列表中会出现。是版本问题还是设备问题?
PackageManager pm = getPackageManager();
List<ResolveInfo> appsList = pm.queryIntentActivities( in, 0);
if(appsList.size() > 0){
//select bluetooth
String packageName = null;
String className = null;
boolean found = false;
for(ResolveInfo info: appsList){
Toast.makeText(MainActivity.this, packageName, Toast.LENGTH_SHORT).show();
packageName = info.activityInfo.packageName;
if( packageName.equals("com.android.bluetooth")){
className = info.activityInfo.name;
found = true;
break;// found
}
}
if(! found){
Toast.makeText(this, "not found",
Toast.LENGTH_SHORT).show();
// exit
}
else{
in.setClassName(packageName, className);
startActivity(in);
}
}