Instagram 分享意图的结果代码 android
Result code for sharing intent for instagram android
如果我通过 intent 成功地与 instagram 分享了一张图片,结果代码总是给出 0。请帮忙。提前致谢。
我已经尝试了很多。
这是我的代码:
File imageFileToShare = new File(filePath);
Uri uri = Uri.fromFile(imageFileToShare);
Intent shareInstagramIntent = new Intent(Intent.ACTION_SEND);
shareInstagramIntent.setPackage("com.instagram.android");
shareInstagramIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareInstagramIntent.setType("image/*");
shareInstagramIntent.putExtra(Intent.EXTRA_TEXT, text);
startActivityForResult(shareInstagramIntent, INSTAGRAM);
这是我的 onActivityResult :
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case INSTAGRAM:
logI("Request e: " + resultCode);
if (resultCode == thisActivity.RESULT_OK) {
Utilities.showAlert(thisActivity, "Image shared with instagram successfully");
new PostPointsTask("instagram").execute("");
} else {
Utilities.showAlert(thisActivity, "Image shared with instagram was cancelled");
}
}
}
instagram 没有分享意图的回调,最好使用 instagram sdk 来分享你的消息。
如果我通过 intent 成功地与 instagram 分享了一张图片,结果代码总是给出 0。请帮忙。提前致谢。
我已经尝试了很多。
这是我的代码:
File imageFileToShare = new File(filePath);
Uri uri = Uri.fromFile(imageFileToShare);
Intent shareInstagramIntent = new Intent(Intent.ACTION_SEND);
shareInstagramIntent.setPackage("com.instagram.android");
shareInstagramIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareInstagramIntent.setType("image/*");
shareInstagramIntent.putExtra(Intent.EXTRA_TEXT, text);
startActivityForResult(shareInstagramIntent, INSTAGRAM);
这是我的 onActivityResult :
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case INSTAGRAM:
logI("Request e: " + resultCode);
if (resultCode == thisActivity.RESULT_OK) {
Utilities.showAlert(thisActivity, "Image shared with instagram successfully");
new PostPointsTask("instagram").execute("");
} else {
Utilities.showAlert(thisActivity, "Image shared with instagram was cancelled");
}
}
}
instagram 没有分享意图的回调,最好使用 instagram sdk 来分享你的消息。