R
R
RoadToGamedev2020-10-13 18:19:26
Java
RoadToGamedev, 2020-10-13 18:19:26

How do I start NativeActivity from Java?

Hello. I need to implement that NativeActivity would be launched from Java code.
I am new to the world of Java and android in general.
Right now my NativeActivity is starting magically. As that itself.
From such XML.

<activity android:name="android.app.NativeActivity"
                android:configChanges="orientation|keyboardHidden|screenSize"
                android:screenOrientation="landscape"
                android:clearTaskOnLaunch="true">

            <!-- Tell NativeActivity the name of our .so -->
            <meta-data android:name="android.app.lib_name" android:value="example" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

All i need is to add lib.so as i am new to java and android.
It's hard for me to implement jni methods from C.
For the first time, I thought, can I run a java code that will be a placeholder, perform the actions I need and write them to a file. After that, NativeActivity will be launched and read the necessary information from the file. Yes, it looks like a 5th wheel, a crutch. But I estimate my strength soberly.
Tell me how to make XML markup and what classes to use? And in general, how is this approach better to use in Android? Maybe someone knows another approach to solving this problem?

Thank you all in advance.
Thank you very much for the template working code!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question