// 如何判断某个Activity的Action的应用程序是否安装
PackageManager pm = getPackageManager();
// 指定要检测的Activity action 好比 com.android.phone.action.TOUCH_DIALER
Intent intent = new Intent("com.android.phone.action.TOUCH_DIALER");
// 在系统中查询指定的Activity Action
List<ResolveInfo> resolveInfo = pm.queryIntentActivities(intent, PackageManager.GET_INTENT_FILTERS);
if (resolveInfo.size() == 0)
System.out.println("不存在该Action"); android
// 指定要查找的Broadcast Action
Intent in = new Intent("mobile.android.MYBROADCAST");
// 在系统中查找指定的Broadcast Action
List<ResolveInfo> queryBroadcastReceivers = pm.queryBroadcastReceivers(intent, PackageManager.GET_INTENT_FILTERS);
if (queryBroadcastReceivers.size() == 0) {
System.out.println("不存在该广播");
}
// 判断指定的ContentProvider是否存在只须要根据ContentResolver对象相应的方法的返回值进行判断便可
Uri uri = Uri.parse("content://mobile.android.regioncontentprovider/cities");
Cursor cursor = getContentResolver().query(uri, new String[] { "city_code as _id", "city_name" }, null, null, null);
if (cursor == null)
System.out.println("不存在此Uri");
} ide
//.......判断Sevice 这里指的是AIDL Service spa
if(bindService(new Intent("mobile.android.IMyService"),serviceConnection,Context.BIND_AUTO_CREATE)){ code
//不存在 对象
} ci