Is It Possible To Send Video Url To Instagram Application Using Intent In Android?
I am using below code for sending video url to instagram app but no luck String type = 'video/*'; String mediaPath= 'www.example.com/abcd.mp4'; Intent share = new Intent(Intent.ACT
Solution 1:
After lot of searching finally I found the solution. First we need to download video from url(if video not stored in local storage) then we apply below code.
/* Button click to share video on Instagram */
btn_instagram.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(View v) {
if(isPackageInstalled("com.instagram.android")) {
createInstagramIntent(localuri);
}else{
AlertDialog.Builderalert=newAlertDialog.Builder(ReflipActivity.this);
alert.setTitle("Warning");
alert.setMessage("Instagram App not found");
alert.setPositiveButton("OK", newDialogInterface.OnClickListener() {
publicvoidonClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alert.show();
}
}
});
// Check Instagram app is installed on device or not
privatebooleanisPackageInstalled(String packagename) {
PackageManager pm = getPackageManager();
try {
pm.getPackageInfo(packagename, PackageManager.GET_ACTIVITIES);
returntrue;
} catch (PackageManager.NameNotFoundException e) {
returnfalse;
}
}
// And finally fire the Intent for Instagram
privatevoidcreateInstagramIntent(String filename){
Stringsettype="video/*";
StringmediaPath= filename;
// Create the new Intent using the 'Send' action.Intentshare=newIntent(Intent.ACTION_SEND);
// Set the MIME type
share.setType(settype);
share.setPackage("com.instagram.android");
// Create the URI from the mediaFilemedia=newFile(mediaPath);
Uriuri= Uri.fromFile(media);
// Add the URI to the Intent.
share.putExtra(Intent.EXTRA_STREAM, uri);
// Broadcast the Intent.
startActivity(Intent.createChooser(share, "Share to"));
}
Post a Comment for "Is It Possible To Send Video Url To Instagram Application Using Intent In Android?"