Chi*_*mar 9 android android-intent instagram
我正在使用社交应用程序的共享功能Intent
.
我在Instagram上分享图片时遇到问题.
有时我收到消息
无法加载图片.
这是我的代码:
String path="content://media/external/images/media/32872";
Intent shareIntent = new Intent();
shareIntent.setType("image/jpeg");
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(path));
shareIntent.setPackage("com.instagram.android");
startActivity(shareIntent);
Run Code Online (Sandbox Code Playgroud)
我该如何摆脱这个问题?
如果您有文件,则使用以下代码共享图像,
private void shareIntagramIntent(String path) {
Intent intent = getActivity().getPackageManager()
.getLaunchIntentForPackage("com.instagram.android");
if (intent != null) {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setPackage("com.instagram.android");
try {
shareIntent.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file://" + path));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
shareIntent.setType("image/jpeg");
startActivity(shareIntent);
} else {
// bring user to the market to download the app.
// or let them choose an app?
intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse("market://details?id="
+ "com.instagram.android"));
startActivity(intent);
}
}
Run Code Online (Sandbox Code Playgroud)
小智 0
尝试这个:
\n\nFile filepath = Environment.getExternalStorageDirectory(); \ncacheDir = new File(filepath.getAbsolutePath() + "/LikeIT/"); \ncacheDir.mkdirs(); \nIntent intent = new Intent(); \nintent.setType("image/*"); \nintent.setAction(Intent.ACTION_SEND); \nintent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + filepath.getAbsolutePath())); \nactivity.startActivity(intent);\xc2\xa0\xc2\xa0\n
Run Code Online (Sandbox Code Playgroud)\n
归档时间: |
|
查看次数: |
4120 次 |
最近记录: |