当我单击右上角的“应用程序配置文件图像共享”按钮时,我试图将本机脚本应用程序显示为选择器意图,并且想知道如何在我的应用程序中处理这些事情。在选择器意图中单击我的应用程序后,需要在哪里添加代码以在应用程序中显示图像?
我在这里找到了类似的问题 How to show chooser Intent with my own android app on click of WhatsApp location? 给地图的地方,但是我想要它的图像。
我希望在打开意图时打开whats应用程序配置文件的图像,并在我的应用程序中显示该图像。并让用户选择在用户定义的文件夹结构中保存或取消。谁能指导我?
我尝试过这种方法来处理传入的图像,但是它不起作用。
let intent = android.getIntent();
let action = android.intent.getAction();
let type = android.intent.getType();
if (android.intent.ACTION_SEND.equals(action) && type != null) {
if ("text/plain".equals(type)) {
handleSendText(intent); // Handle text being sent
} else if (type.startsWith("image/")) {
handleSendImage(intent); // Handle single image being sent
}
} else if (android.intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
if (type.startsWith("image/")) {
handleSendMultipleImages(intent); // Handle multiple images being sent
}
} else {
// Handle other intents, such as being started from the home screen
}
function handleSendImage(intent) {
var imageUri = intent.getParcelableExtra(android.intent.EXTRA_STREAM);
console.log("-----image uri-------");
console.log(imageUri);
if (imageUri != null) {
// Update UI to reflect image being shared
}
}
答案 0 :(得分:0)
您必须为NativeScript活动更新intent-filter
,以使系统知道您的活动可以处理图片的选择。
<activity android:name="com.tns.NativeScriptActivity"...>
...
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>