[Plugin] Android Camera

Hey @RobMilliken soo glad that my plugin help some people, now regarding to your problem, yes absolutely, you can send different types between c++ and java, lets say for example send a string and return a bool if is not empty

java:



public boolean AndroidThunkJava_RecvString(String path)
{
    return (path != "");
}


The must important thing here is: “(Ljava/lang/String;)Z” this is how you define parameters, if you want to know how to interchange more types just look for the FJavaWrapper, inside you will fine thousands of examples, bool, string, int, bytes, etc.

you can retrieve your method like this:



AndroidThunkJava_RecvString = FJavaWrapper::FindMethod(ENV, FJavaWrapper::GameActivityClassID, "AndroidThunkJava_RecvString", "(Ljava/lang/String;)Z", false);
if (!AndroidThunkJava_RecvString)
{
    __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, "ERROR: AndroidThunkJava_RecvString Method cant be found T_T ");
    return JNI_ERR;
}


And then finally you can call your c++ method:



bool AndroidThunkCpp_RecvString(const FString& path)
{
    bool result = false;
    if (AndroidThunkJava_RecvString && ENV)
    {
        jstring Argument = ENV->NewStringUTF(TCHAR_TO_UTF8(*path));
        result = FJavaWrapper::CallBooleanMethod(ENV, FJavaWrapper::GameActivityThis, AndroidThunkJava_RecvString, Argument);
        ENV->DeleteLocalRef(Argument);
    }
    return result;
}


Cheers

@**ZkarmaKun Yes, this will certainly help! I’ll be studying/experimenting with this!

Also I updated my earlier change to get your code working on 4.20 with one line I had forgotten - if anyone is interested look back at my original post on changes to get to work on 4.20.

Yes! Again, highly encourage others to study this excellent example of plugin communication with the Android! Thanks again so much! Rob.**

Quick update - ONE line that creates a feature that others earlier were asking for, AUTO FOCUS.

In the file, AndroidCamera_APL.xml, add a line below the existing line 70:
cameraparametersandroid.JPG
This



        cameraParam.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);


Autofocus is working after that one line addition on my Pixel 2XL. I owe this gem to this source: How to autofocus Android camera automatically? - Stack Overflow

Note if you want to dive more in depth to actually take a picture/video, you may need to do more than this, but this fits my needs nicely. **ZkarmaKun **already had the “addFeature” for “android.hardware.camera.autofocus” - all that needed to be added was to “make it so” with that one line. Since the app I am working on currently is to help people with vision problems see better, of course, this is a must feature!

I changed the resolution by add “vidcap://camera_id?width=xx?height=xx?fps=xx” to Open Url node

I’m so excited about this. It’s exactly what I’ve been looking for for days so I can get bluetooth working!
I’m having a little trouble though - I wonder if anyone can help.

I’m on UE4.22.0
(Installed, not pulled from github)

I’ve downloaded and expanded the project to it’s own project folder.
Then I’ve opened and edited the files @RobMilliken has noted as needing changing.
Upon trying to open the project, it asks if I’d like to rebuild AndroidCameraProj and AndroidCamera, I click yes.
It then tells me “AndroidCameraProj could not be compiled. Try rebuilding from source manually”.
The project doesn’t open.

I then open the .sln file in Visual Studio 2019 and try and build the project from there but I get this error:


Error    MSB3073    The command "**"C:\Program Files (x86)\Epic Games\4.14\Engine\Build\BatchFiles\Build.bat" AndroidCameraProjEditor Win64 Development "D:\Dropbox\Learning\2019_SoftEngProj\Research\Examples\AndroidCameraProj\AndroidCameraProj.uproject" -waitmutex"** exited with code 3.

Quoting:


**File:**
*C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets*
**Line:**
*44*

It’s obviously because I don’t have 4.14 installed and that’s what it wants to build with, but where do I tell it not to build with that?
(I’ve updated the version number in the .uproject file but no effect)

Also, right clicking and choosing rebuild Visual Studio files returns this error:


Running C:/Program Files/Epic Games/UE_4.22/Engine/Binaries/DotNET/UnrealBuildTool.exe  -projectfiles -project="D:/Dropbox/Learning/2019_SoftEngProj/Research/Examples/AndroidCameraProj/AndroidCameraProj.uproject" -game -rocket -progress -log="D:\Dropbox\Learning\2019_SoftEngProj\Research\Examples\AndroidCameraProj/Saved/Logs/UnrealVersionSelector-2019.04.25-23.14.27.log"
Discovering modules, targets and source code for project...
While compiling D:\Dropbox\Learning\2019_SoftEngProj\Research\Examples\AndroidCameraProj\Intermediate\Build\BuildRules\AndroidCameraProjModuleRules.dll:
d:\Dropbox\Learning\2019_SoftEngProj\Research\Examples\AndroidCameraProj\Source\AndroidCameraProj.Target.cs(19,12) : error CS0246: The type or namespace name 'UEBuildBinaryConfiguration' could not be found (are you missing a using directive or an assembly reference?)
d:\Dropbox\Learning\2019_SoftEngProj\Research\Examples\AndroidCameraProj\Source\AndroidCameraProjEditor.Target.cs(19,12) : error CS0246: The type or namespace name 'UEBuildBinaryConfiguration' could not be found (are you missing a using directive or an assembly reference?)
ERROR: Unable to compile source files.

Any know what I need to do to get this up and running?

Thanks in advance! Dale.

Hi everyBody,
I have a simple question about Android Camera popup Permission activation.
My problem is ; when i open my app from google play and start it, there is no popup who ask user if he accept to use the camera (The only popup is for share file and use photo). When i put the camera ON in the App Setting of the phone everything is working good. Any Idea how to fix it or how to activate a check box from user ?
Thanks

@daledesilva Just now seeing this ask about the engine version. At least one issue is the .uproject file on the root of your project directory. Check it out in your fav text editor. You’ll see an “EngineAssociation” number. Change it to your engine number you want to us that you have available. If that is not the problem, it is A problem. Hopefully the only issue. I’ve got this code working through 4.23 so far. You may have to “solve” again or go through a prompt to change engine. That can only be a good thing.

@Poolpio_team Run a boolean check w/ the blueprint “Check Android Permission” if it is false, kindly ask the user to go into their settings and change it. (Maybe provide a screenshot.)