我是新手,不知道怎么开始这个,
我创建了一个使用Android.mk链接到C++的项目
因此,当我从java调用一个方法时,它应该将存储的布尔值存储到我的共享首选项对象中.
这是我的JNI方法
extern "C"
JNIEXPORT void JNICALL
Java_com_example_sample_storeBoolean(JNIEnv *env,jobject instance){
//TODO
const char *name ="hello";
__android_log_print(ANDROID_LOG_ERROR, "TRACKERS", "***** %s *****", name);
}
Run Code Online (Sandbox Code Playgroud)
普通日志我已打印它现在正在工作只需要创建sharepreference对象并设置布尔值
SharedPreferences prefs = context.getSharedPreferences("myprefdata", Context.MODE_PRIVATE);
prefs.edit().putBoolean("settingnootification", true).commit();
Run Code Online (Sandbox Code Playgroud)
请指导我怎么做.谢谢
public abstract SharedPreferences getSharedPreferences(String name, int mode);
Run Code Online (Sandbox Code Playgroud)
需要在c ++中使用此方法
我有我设备的当前时间(以 毫秒为单位)。
现在我需要将其转换为 MILLISECONDS OF UTC 时区
所以我试过这个,但它没有以毫秒为单位进行转换。
public static long localToUTC(long time) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("MMM dd, yyyy hh:mm:ss a");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
Log.e("* UTC : " + time, " - " + sdf.format(new Date(time)));
Date date = sdf.parse(sdf.format(new Date(time)));
long timeInMilliseconds = date.getTime();
Log.e("Millis in UTC", timeInMilliseconds + "" + new SimpleDateFormat("MMM dd, yyyy hh:mm:ss a").format(date));
return timeInMilliseconds;
} catch (Exception e) {
Log.e("Exception", "" + e.getMessage());
}
return time;
}
Run Code Online (Sandbox Code Playgroud)
UTC MILLISECOND …