gpt4 book ai didi

C# 安卓 MediaStore.ACTION_IMAGE_CAPTURE

转载 作者:行者123 更新时间:2023-11-30 01:19:37 26 4
gpt4 key购买 nike

尝试在 Unity C# 中访问 Android native 相机组件,但无法正确移植 java 代码。我有另一个 intent call 用于共享,但我似乎无法让它工作。

这是我的代码:

static int REQUEST_IMAGE_CAPTURE = 1;

public void TakePhotoWithCamera()
{
AndroidJavaClass intentClass = new AndroidJavaClass("android.provider.MediaStore");
AndroidJavaObject intentObject = new AndroidJavaObject("android.provider.MediaStore");

intentObject.GetStatic<string>("ACTION_IMAGE_CAPTURE");

AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");
currentActivity.Call("startActivity", intentObject, REQUEST_IMAGE_CAPTURE);
}

最佳答案

与其删除问题,因为我很难找到任何可以帮助我的东西,我会发布我所做的。

static int REQUEST_IMAGE_CAPTURE = 1;

public void TakePhotoWithCamera()
{
AndroidJavaClass IntentClass = new AndroidJavaClass("android.content.Intent");
AndroidJavaObject IntentObject = new AndroidJavaObject("android.content.Intent");

AndroidJavaObject MSObject = new AndroidJavaObject("android.provider.MediaStore");

IntentObject.Call<AndroidJavaObject>("setAction", MSObject.GetStatic<string>("ACTION_IMAGE_CAPTURE"));

AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");
currentActivity.Call("startActivityForResult", IntentObject, REQUEST_IMAGE_CAPTURE);
}

关于C# 安卓 MediaStore.ACTION_IMAGE_CAPTURE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37315263/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com