Skip to content

Instantly share code, notes, and snippets.

@adipascu
Created November 23, 2014 05:26
Show Gist options
  • Save adipascu/c888a5f16a95d9e0e9a9 to your computer and use it in GitHub Desktop.
Save adipascu/c888a5f16a95d9e0e9a9 to your computer and use it in GitHub Desktop.
Android intents
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), 0);
Intent pickContactIntent = new Intent(Intent.ACTION_PICK, Uri.parse("content://contacts"));
pickContactIntent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE); // Show user only contacts w/ phone numbers
startActivityForResult(pickContactIntent, 0);
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivity(sendIntent);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, "uriToImage");
shareIntent.setType("image/jpeg");
startActivity(shareIntent);
//startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.send_to)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment