我有一个纯粹的原生Android NDK应用程序,需要检索诸如:android.os.Build.MODEL之类的值
不幸的是我找不到如何解决这个问题的好例子?
我有一个纯本机应用程序,因为我使用android_native_app_glue,因此我应用程序的入口是
android_main(..)
Run Code Online (Sandbox Code Playgroud)
我也有一个Java helper类型类:
package abc.def.ghi
public class MyJavaClass extends Activity
{
public void callback()
{
Log.v(TAG, "In MyJavaClass");
}
}
Run Code Online (Sandbox Code Playgroud)
我想从本地调用“回调”方法。我这样做是:
jclass myClass = env->FindClass("abc/def/ghi/MyJavaClass");
if( myClass == NULL )
LOGI("myClass null");
jmethodID mid = m_pEnv->GetMethodID(myClass, "callback", "()V");
if( mid == NULL )
LOGI("MID null");
m_pEnv->CallVoidMethod(myClass, mid);
Run Code Online (Sandbox Code Playgroud)
但是,这导致一条消息,提示myClass为null。我的“ env”指针应该可以,因为当我在FindClass中传递“ android / os / build”时,它找到了,但是找不到我的自定义类。
在LOGCAT中,我看到:“ JNI警告:无法调用Labc / def / ghi;对Ljava / Lang / Class的实例进行回调;”
我认为这意味着我的CallVoidMethod的第一个参数有问题。我在其他示例中注意到,大多数人使用javah生成的签名在函数内执行CallVoidMethod,并且他们obj在其参数中使用参数CallVoidMethod:
JNIEXPORT void JNICALL function(JNIEnv *env, jobject obj, jstring s)
Run Code Online (Sandbox Code Playgroud)
但是我不能使用它,因为我的应用程序的入口点是本地的。
我想让我当前的应用程序关闭并重新启动。我看过很多关于这个的帖子,但是这些似乎都不适合我。
我试过了
System.Diagnostics.Process.Start(System.Windows.Application.ResourceAssembly.Location);
System.Windows.Application.Current.Shutdown();
Run Code Online (Sandbox Code Playgroud)
但是,这只会重新启动应用程序一次。如果我再次按下“重新启动”按钮(在已经重新启动的应用程序上),它只会关闭。
我还尝试启动一个新的 System.Diagnostics.Process 并关闭当前进程,但同样不会重新启动,它只是关闭。
如何重新启动当前的 WPF 应用程序?
// In A.h
class A
{
public:
enum eMyEnum{ eOne, eTwo, eThree };
public:
A(eMyEnum e);
}
// In B.h
#include "A.h"
class B
{
B();
private:
A memberA;
}
// In B.cpp
#include "B.h"
B::B(void) : memberA(A::eOne)
{}
Run Code Online (Sandbox Code Playgroud)
'memberA'的声明使用g ++编译器给出了编译错误:错误:'A :: eOne'不是类型
我怎么能克服这个?我只需要创建一个不带参数的默认构造函数吗?
我已将“arial.ttf”文件(取自我的 /Windows/Fonts 文件夹)加载到内存中,但是将其传递给 FT_New_Memory_Face 时会崩溃(在 FT_Open_Face 中的某处)。我无法调试这个,任何关于我可能做错了什么的线索?
unsigned char *fontBuffer = LoadFile("arial.ttf");
zip_uint64_t fSize = GetFileSize("arial.ttf");
FT_Library library; /* handle to library */
FT_Face face;
int error = FT_Init_FreeType( &library );
if( error != 0 )
printf("FT_Init_FreeType failed");
error = FT_New_Memory_Face( library,
(FT_Byte*)fontBuffer,
fSize,
0,
&face );
Run Code Online (Sandbox Code Playgroud) android ×2
android-ndk ×2
c++ ×1
constructor ×1
declaration ×1
freetype ×1
g++ ×1
java ×1
restart ×1
wpf ×1