I can use skype (or any other) application from my android app with url schemes like 'skype://'
.
But can i check existence of schema on user mobile phone? Like canOpenURL
in iOS
Thanks.
A scheme is meaningless on its own -- it has to be tied to some action ( ACTION_VIEW
, ACTION_CALL
, etc.) in an Intent
.
Your Java code can call resolveActivity()
on PackageManager
to determine if any given Intent
will be handled by the system if you were to call startActivity()
with that Intent
.
You can use the following to check if the intent can be handled:
public static boolean intentIsAvailable(Context ctx, Intent intent) {
final PackageManager mgr = ctx.getPackageManager();
List<ResolveInfo> list =
mgr.queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
return list.size() > 0;
}
usage:
if(intentIsAvailable(appContext, yourIntent)){
startActivity(intent);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.