Android Training精要(四) Intent注意事项

来源:互联网 发布:淘宝开店星密码靠谱吗 编辑:程序博客网 时间:2024/06/07 06:11

判断有处理Intent的Activity

PackageManager packageManager = getPackageManager();List<ResolveInfo> activities = packageManager.queryIntentActivities(mapIntent, 0); boolean isIntentSafe = activities.size() > 0;  // Start an activity if it's safe if (isIntentSafe) {     startActivity(mapIntent); }

將可以處理Intent的所有app列表做成下拉選擇框的形式

Intent intent = new Intent(Intent.ACTION_SEND); // Always use string resources for UI text. // This says something like "Share this photo with" String title = getResources().getString(R.string.chooser_title); // Create and start the chooser Intent chooser = Intent.createChooser(intent, title); startActivity(chooser);




0 0
原创粉丝点击