我正在尝试在共享图像内容时从whats应用访问图像。所以我已经在android清单中为选择器意图编写了代码。现在要处理传入的图像,我编写了如下代码
application.android.on(application.AndroidApplication.activityStartedEvent, function (args) {
console.log("Event: " + args.eventName + ", Activity: " + args.activity);
// Event: activityStarted, Activity: com.tns.NativeScriptActivity@8a3b9cc
let intent = args.activity.getIntent();
let action = intent.getAction();
let type = intent.getType();
console.log(intent);
//Intent { act=android.intent.action.SEND typ=image/* flg=0x1b080001 cmp=org.myapp.new_app/com.tns.NativeScriptActivity clip={image/* U:content://com.whatsapp.fileprovider/external/WhatsApp/.Shared/photo.jpg} (has extras) }
console.log(action);
//android.intent.action.SEND
console.log(type);
// image/*
let imageUri = intent.getParcelableExtra(intent.EXTRA_STREAM);
console.log(imageUri);
//null
}
我希望输出不为空
答案 0 :(得分:0)
日志已经显示了您必须从意图(剪辑)中准确读取的内容。
intent.getClipData().getItemAt(0).getUri()