jueves, 17 de julio de 2014

Android: Easy share


Uri uri = Uri.fromFile(new File(path));
       
Intent shareIntent = new Intent(Intent.ACTION_SEND);  
shareIntent.setType("image/*");  
shareIntent.putExtra(Intent.EXTRA_TEXT, "text"); 
shareIntent.putExtra(Intent.EXTRA_TITLE, "title"); 
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "subject");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); *
startActivity(Intent.createChooser(shareIntent, "Share via"));

Note: This can be used with facebook if the application is installed.


* If you leave out the flag, when returning to your app (from homescreen, from recents etc.), you would see the Activity of the share target (messaging/mailing/IM app) instead of yours.







No hay comentarios:

Publicar un comentario