diff options
Diffstat (limited to 'docs/html/training')
-rw-r--r-- | docs/html/training/basics/intents/filters.jd | 4 | ||||
-rw-r--r-- | docs/html/training/basics/intents/sending.jd | 8 | ||||
-rw-r--r-- | docs/html/training/sharing/send.jd | 14 |
3 files changed, 15 insertions, 11 deletions
diff --git a/docs/html/training/basics/intents/filters.jd b/docs/html/training/basics/intents/filters.jd index 9b6a111..10bf43d 100644 --- a/docs/html/training/basics/intents/filters.jd +++ b/docs/html/training/basics/intents/filters.jd @@ -148,8 +148,8 @@ the recipient's address using the {@code send} or {@code sendto} URI scheme. For {@link android.content.Intent#CATEGORY_DEFAULT} category in the intent filter. The methods {@link android.app.Activity#startActivity startActivity()} and {@link android.app.Activity#startActivityForResult startActivityForResult()} treat all intents as if they -contained the {@link android.content.Intent#CATEGORY_DEFAULT} category. If you do not declare it, no -implicit intents will resolve to your activity.</p> +declared the {@link android.content.Intent#CATEGORY_DEFAULT} category. If you do not declare it +in your intent filter, no implicit intents will resolve to your activity.</p> <p>For more information about sending and receiving {@link android.content.Intent#ACTION_SEND} intents that perform social sharing behaviors, see the lesson about <a diff --git a/docs/html/training/basics/intents/sending.jd b/docs/html/training/basics/intents/sending.jd index 79c017b..30dc95a 100644 --- a/docs/html/training/basics/intents/sending.jd +++ b/docs/html/training/basics/intents/sending.jd @@ -241,9 +241,13 @@ 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 +// Create intent to show chooser Intent chooser = Intent.createChooser(intent, title); -startActivity(chooser); + +// Verify the intent will resolve to at least one activity +if (intent.resolveActivity(getPackageManager()) != null) { + startActivity(chooser); +} </pre> <p>This displays a dialog with a list of apps that respond to the intent passed to the {@link diff --git a/docs/html/training/sharing/send.jd b/docs/html/training/sharing/send.jd index f5da68f..e869d5f 100644 --- a/docs/html/training/sharing/send.jd +++ b/docs/html/training/sharing/send.jd @@ -75,10 +75,12 @@ startActivity(sendIntent); <p>If there's an installed application with a filter that matches {@link android.content.Intent#ACTION_SEND} and MIME type text/plain, the Android system will run it; if more than one application matches, the system displays a disambiguation dialog (a "chooser") -that allows the user to choose an app. If you call +that allows the user to choose an app.</p> + +<p>However, if you call {@link android.content.Intent#createChooser(android.content.Intent, CharSequence) -Intent.createChooser()} -for the intent, Android will <strong>always</strong> display the chooser. This has some +Intent.createChooser()}, passing it your {@link android.content.Intent} object, it returns a version +of your intent that will <strong>always display the chooser</strong>. This has some advantages:</p> <ul> @@ -102,10 +104,8 @@ startActivity(<strong>Intent.createChooser(sendIntent, getResources().getText(R. <p>Optionally, you can set some standard extras for the intent: {@link android.content.Intent#EXTRA_EMAIL}, {@link android.content.Intent#EXTRA_CC}, -{@link android.content.Intent#EXTRA_BCC}, {@link android.content.Intent#EXTRA_SUBJECT}. However, -if the receiving application is not designed to use them, nothing will happen. You can use -custom extras as well, but there's no effect unless the receiving application understands them. -Typically, you'd use custom extras defined by the receiving application itself.</p> +{@link android.content.Intent#EXTRA_BCC}, {@link android.content.Intent#EXTRA_SUBJECT}. +If the receiving application is not designed to use them, it simply ignores them.</p> <p class="note"><strong>Note:</strong> Some e-mail applications, such as Gmail, expect a {@link java.lang.String String[]} for extras like {@link android.content.Intent#EXTRA_EMAIL} and |