"Android Code Snippet"
Share intent for android
public void shareImageToFriend(String filepath){
if(filepath.length()>0){
File opt = new File(filepath);
Intent intent = new Intent(Intent.ACTION_SEND);
File file = new File(opt.getPath());
String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(file.getAbsolutePath());
String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
intent.setType(mimetype);
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
startActivityForResult(Intent.createChooser(intent, "Share this using"), 100);
}
}
Share intent for android
public void shareImageToFriend(String filepath){
if(filepath.length()>0){
File opt = new File(filepath);
Intent intent = new Intent(Intent.ACTION_SEND);
File file = new File(opt.getPath());
String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(file.getAbsolutePath());
String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
intent.setType(mimetype);
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
startActivityForResult(Intent.createChooser(intent, "Share this using"), 100);
}
}
No comments:
Post a Comment