我正在尝试将一个安卓设备ID号从Java返回给C++:
目前我有以下内容:
在C++中:
jstring Java_com_incket_OnePlayRL_OnePlayRL_uniqueCode (JNIEnv *env, jobject obj, jstring passCode)
{
const char *ucstr;
ucstr = env->GetStringUTFChars(passCode, 0);
CCLog("String id is %s", ucstr);
env->ReleaseStringUTFChars(passCode, ucstr);
}在Java端:
public native String uniqueCode (String passCode);
static Context mContext;
private static Activity me = null;
String identifier = null;
TelephonyManager tm = (TelephonyManager)mContext.getSystemService(Context.TELEPHONY_SERVICE);
if (tm != null)
identifier = tm.getDeviceId();
if (identifier == null || identifier .length() == 0)
identifier = Secure.getString(me.getContentResolver(),Secure.ANDROID_ID);
uniqueCode (identifier);目前,java部分在启动时在另一个方法中被调用。以下是在日志中返回的内容:
String id is e384d223aab74897
Invalid indirect reference 0xfffffe5c in decodeIndirectRef
VM aborting
Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 25515任何帮助都将不胜感激。
发布于 2013-07-05 21:12:14
您的函数应该返回一些jstring值:
jstring Java_com_incket_OnePlayRL_OnePlayRL_uniqueCode(...)https://stackoverflow.com/questions/17236365
复制相似问题