Posts

Showing posts with the label intent

Android Trick - Pick photo from Gallery and 3rd party app

In Android we can using Intent to share data between applications. Simple usage for this part is Picking images or photos from the other applications. Normally the codes is like the following: private void pickPhotoFromGallery() {     Intent intent = new Intent();     intent.setType( "image/*" );     intent.setAction(Intent.ACTION_PICK);     //following line code will specify the dialog title of choosing different content source app     startActivityForResult(Intent.createChooser(intent, "Complete action using" ),SELECT_PHOTO ); } Noticed that if I set Intent Action as Intent.ACTION_PICK it will only select images from System Gallery App. if I called  intent.setAction(Intent. ACTION_GET_CONTENT );  It will get from the other apps. And the result is not same. From Gallery app the uri format is like : content://xxx/xx/xx but the other app will return uri like : file:///xxx/xx/xx ...

Android Trick - Using intent to Send SMS and come back

Damon In Android we can use Intent to send SMS or calling phone number and something else. System will start default ( Or show a list of apps who can accept this intent ) app. Then if you want to come back to your own application after that you will need this . Intent sendIntent = new Intent(Intent.ACTION_SENDTO);  sendIntent.setData(Uri.parse("sms:" + number)); sendIntent.putExtra("sms_body", smsContent);  sendIntent.putExtra("exit_on_sent", true); startActivity(sendIntent); Not sure whether it also works for the other Intents.