native-activity

APP_CMD_WINDOW_RESIZED is not called but native window is resized

不打扰是莪最后的温柔 提交于 2019-12-22 10:28:53
问题 I've native app, which is configured to not destroy activity on device orientation change. <activity android:name="android.app.NativeActivity" ... android:configChanges="orientation|screenSize" ... > When the devices orientation changes only following Native life-cycle command is triggered. /** * Command from main thread: the current device configuration has changed. */ APP_CMD_CONFIG_CHANGED In the command handler I can see that the window size has been changed with ANativeWindow_getHeight

Is it necessary to call system.loadLibrary explicitly for accessing the native methods in a NativeActivity sub class?

做~自己de王妃 提交于 2019-12-11 02:43:35
问题 I have an Android app with an activity derived from NativeActivity like this: public class MyNativeActivity extends android.app.NativeActivity { public native void TellNativeSide(int info); static { System.loadLibrary("MyNatAct"); // <--- is this necessary? } public int OtherMethods(...) ... } On the C/C++ side, I have extern "C" void Java_mycom_nativity_MyNativeActivity_TellNativeSide(JNIEnv *env, jobjectactivityobj, jint info) { ... do something } // java native TellNativeSide() method //

Android NDK crash when reading/writing files

微笑、不失礼 提交于 2019-12-10 12:17:50
问题 I have ported a very large application to Android. It receives binary data over TCP/IP, and writes it to files which it uses now and then in the application. The directory to which it saves the files is by default set to ./file_cache. It goes wrong here: fileHandle = fopen(filename,"wb"); filename in this case is "file_i" where i starts from 0 and increments for every file. The program crashes on writing, and it doesn't have to crash on the first file, sometimes it gets as far as the 10th

Android: calling Java class from C++ Native Activity

廉价感情. 提交于 2019-12-09 14:03:46
问题 Java code: package local.ttt; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Typeface; public class Text2Bitmap { static Bitmap getBitmap(String text,int fontsize) { Paint paint=new Paint(); paint.setStyle(Paint.Style.FILL); paint.setColor(Color.WHITE); paint.setTextSize(fontsize); paint.setAntiAlias(true); paint.setTypeface(Typeface.DEFAULT); int outwidth=(int)Math.round(paint.measureText

android ndk data save/load

醉酒当歌 提交于 2019-12-07 18:14:42
问题 I'm working on porting PC OpenGL application onto Android. I've chosen to use that NDK android_native_app_glue framework stuff. As I understood, it would allow to me stay on C++ and write no even single JAVA code line. And it sounded promising. The first unclear thing to me it data saving/loading. My application's data format is binary and my original PC-related code uses plain "stdio.h" FILE operations: fopen, fread, fwrite, etc to create, write and read from "mygame.bin" file. How do I port

Can I use NativeActivity with ActivityGroup?

百般思念 提交于 2019-12-07 16:49:47
问题 I know ActivityGroup is deprecated. But I am trying to combine user interface of NativeActivty with some Java/Android API View s. I am trying to make one hybrid user interface where a part of the screen is from NativeActivity . I used this example and tried ActivityGroup with some simple activities. This work perfectly with any Activity (Even if I play video using VideoView). But when I tried to load NativeActivity it not working. (I tried Teapot demo from NDK samples). By "not working" I

Checking if directory (folder) exists in apk via native code only

我与影子孤独终老i 提交于 2019-12-06 11:26:14
I need to check wether a certain directory exists in apk. The android/asset_manager.h api seems to be inconsistent - it returns NULL when AAsset* AAssetManager_open(AAssetManager* mgr, const char* filename, int mode); fails to open a file, but for directories AAssetDir* AAssetManager_openDir(AAssetManager* mgr, const char* dirName); 's implementation always returns a new AAssetDir(...) , even if internally it failed to open/find the directory in apk. It is quite irritating that AAssetDir is forward-declared and it's implementation is hidden away in the .cpp file, otherwise it would've been

How do I enable full screen immersive mode for a Native Activity NDK app?

浪子不回头ぞ 提交于 2019-12-06 08:58:05
Reading the documentation at https://developer.android.com/training/system-ui/immersive.html I can't seem to find any information on how to set full screen immersive mode in a Native Activity NDK app (without using JNI) as it seems full screen immersive mode can only be toggled from Java. As it cannot be set from the manifest ( Set Android immersive full screen mode in manifest ), is there any way to request it via EGL? Seems the only way to enable full screen immersive mode is to call setSystemUiVisibility via JNI ahead of requesting a surface via EGL? Answering my own question, you can set

Can I use NativeActivity with ActivityGroup?

白昼怎懂夜的黑 提交于 2019-12-05 22:16:21
I know ActivityGroup is deprecated. But I am trying to combine user interface of NativeActivty with some Java/Android API View s. I am trying to make one hybrid user interface where a part of the screen is from NativeActivity . I used this example and tried ActivityGroup with some simple activities. This work perfectly with any Activity (Even if I play video using VideoView). But when I tried to load NativeActivity it not working. (I tried Teapot demo from NDK samples). By "not working" I mean window.getDecorView() from native activity it always return transparent view, not actual content view

APP_CMD_WINDOW_RESIZED is not called but native window is resized

这一生的挚爱 提交于 2019-12-05 21:24:13
I've native app, which is configured to not destroy activity on device orientation change. <activity android:name="android.app.NativeActivity" ... android:configChanges="orientation|screenSize" ... > When the devices orientation changes only following Native life-cycle command is triggered. /** * Command from main thread: the current device configuration has changed. */ APP_CMD_CONFIG_CHANGED In the command handler I can see that the window size has been changed with ANativeWindow_getHeight function. (I know that ANativeWindow_getHeight function is not the best idea to use in config change