发送intent前验证

来源:互联网 发布:淘宝怎么看订单号 编辑:程序博客网 时间:2024/05/16 17:02
// Build the intentUri location = Uri.parse("geo:0,0?q=1600+Amphitheatre+Parkway,+Mountain+View,+California");Intent mapIntent = new Intent(Intent.ACTION_VIEW, location);// Verify it resolvesPackageManager packageManager = getPackageManager();List<ResolveInfo> activities = packageManager.queryIntentActivities(mapIntent, 0);boolean isIntentSafe = activities.size() > 0;  // Start an activity if it's safeif (isIntentSafe) {    startActivity(mapIntent);}