使用delphi使用外部画廊打开图像 [英] opening the image with the external gallery using delphi

查看:88
本文介绍了使用delphi使用外部画廊打开图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Delphi 10 Seattle创建了Android应用。我已经存储了图像路径,并且需要从那里在本地Android Gallery中打开图像。我该如何实现此功能?

I have created Android app using Delphi 10 Seattle. I have stored the image path and from there I need to open the image in the native Android Gallery. How can I implement this functionality?

推荐答案

Java相当于您要尝试执行的操作,如下所示(基于 open-an-image-using-uri-in-androids-default-gallery-image-viwer

The Java equivalent of what you're trying to do, looks like this (based on open-an-image-using-uri-in-androids-default-gallery-image-viwer)

Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://" + "/sdcard/test.jpg"), "image/*");
startActivity(intent);

因此,如果我们使用 send-android-intents-from-delphi-part-2 作为指导,我们应该获取代码看起来像这样:

So if we translate that to Delphi using sending-android-intents-from-delphi-part-2 as a guide, we should get code that looks something like this:

var
  Data: Jnet_Uri;
  Intent: JIntent;
begin
  Intent := TJIntent.Create;
  Intent.setAction(TJIntent.JavaClass.ACTION_VIEW);
  Data := TJnet_Uri.JavaClass.parse(StringToJString('file://' + '/sdcard/test.jpg'));
  Intent.setDataAndType(Data, StringToJString('image/*'));
  SharedActivity.startActivity(Intent);
end;

当然,最好使用

System.IOUtils.TPath.Combine(Path,Filename)代替上面示例代码的'/sdcard/test.jpg'
部分。

System.IOUtils.TPath.Combine(Path, Filename) in place of the '/sdcard/test.jpg' part of the example code above.

这篇关于使用delphi使用外部画廊打开图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆