[英]Intent for sending Instagram direct message
I want people to be able to send a direct message to my Instagram account from my android application.我希望人们能够从我的 android 应用程序向我的 Instagram 帐户发送直接消息。 What is the intent for sending a direct message on Instagram?在 Instagram 上发送直接消息的意图是什么?
Thanks谢谢
You can use below code您可以使用以下代码
String type = "video/*";
String filename = "/myVideo.mp4";
String mediaPath = Environment.getExternalStorageDirectory() + filename;
createInstagramIntent(type, mediaPath);
private void createInstagramIntent(String type, String mediaPath){
// Create the new Intent using the 'Send' action.
Intent share = new Intent(Intent.ACTION_SEND);
// Set the MIME type
share.setType(type);
// Create the URI from the media
File media = new File(mediaPath);
Uri uri = Uri.fromFile(media);
// Add the URI to the Intent.
share.putExtra(Intent.EXTRA_STREAM, uri);
share.putExtra(Intent.EXTRA_STREAM, [URI of photo]);
share.putExtra(Intent.EXTRA_TEXT, [Text of caption]);
// Broadcast the Intent.
startActivity(Intent.createChooser(share, "Share to"));
}
To Share plain text to the Instagram DM(Direct) use following:要将纯文本共享到 Instagram DM(直接),请使用以下内容:
val shareIntent = Intent(Intent.ACTION_SEND)
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, "Assd") // set uri
shareIntent.setPackage("com.instagram.android")
startActivity(shareIntent)
Or You Also can use a file instead:或者您也可以使用文件代替:
String type = "video/*";
...
intent..putExtra(Intent.EXTRA_STREAM, [URI of photo]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.