android 프로그램에서 패키지 이름을 통해 핸드폰에 앱이 설치되어 있는지 판단합니다
1067 단어 android 모바일 개발
Intent intent = new Intent();
intent.setPackage(toAppPackageName);
intent.putExtra(Constants.KEY_UID_FROM_APP_NAME, curAppPackageName);
intent.putExtra(Constants.KEY_UID_OP_CODE, Constants.VALUE_UID_OP_CODE_SCAN);
intent.setAction("android.intent.action.iqiyi.sso");
// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Context context = getApplicationContext();
if (IntentTools.isIntentActionAvailable(context, intent)) {
startActivityForResult(intent, REQUEST_CODE_FOR_SCAN_ACCOUNT);
} else {
// APP,
finishOneScan();
}
isIntentActionAvailable(context, intent) ??
public static boolean isIntentActionAvailable(Context context, Intent intent) {
PackageManager packageManager = context.getPackageManager();
List list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
return list != null && list.size() > 0;
}