java.lang.NoSuchFieldError: no “Ljava/lang/String;” field JNI
up vote
0
down vote
favorite
Good day. Please tell me what I'm doing wrong. Implemented getting keys from android / provider / Settings $ System. Keys like ACCELEROMETER_ROTATION look no problem (those described https://developer.android.com/reference/android/provider/Settings.System) but such as sms_delivered_sound, he refuses to search. Writes an error.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.woodman.testlibsettingsv2, PID: 31133
java.lang.NoSuchFieldError: no "Ljava/lang/String;" field "sms_delivered_sound" in class "Landroid/provider/Settings$System;" or its superclasses
at com.example.woodman.testlibsettingsv2.frmMain.GetSystemKyesString(Native Method)
at com.example.woodman.testlibsettingsv2.frmMain.onCreate(frmMain.java:32)
at android.app.Activity.performCreate(Activity.java:7210)
at android.app.Activity.performCreate(Activity.java:7201)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2926)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3081)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6806)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
code
extern "C"
JNIEXPORT jstring JNICALL
Java_com_example_woodman_testlibsettingsv2_frmMain_GetSystemKyesString(JNIEnv *env,
jobject instance,
jstring key_Name_) {
const char *key_Name = env->GetStringUTFChars(key_Name_, 0);
// TODO
jclass activityThread = env->FindClass("android/app/ActivityThread");
jmethodID currentActivityThread = env->GetStaticMethodID(activityThread,
"currentActivityThread",
"()Landroid/app/ActivityThread;");
jobject at = env->CallStaticObjectMethod(activityThread, currentActivityThread);
jmethodID getApplication = env->GetMethodID(activityThread, "getApplication",
"()Landroid/app/Application;");
jobject context = env->CallObjectMethod(at, getApplication);
jclass c_settings_system = env->FindClass("android/provider/Settings$System");
jclass c_context = env->FindClass("android/content/Context");
if (c_settings_system == NULL || c_context == NULL) {
return NULL;
}
jmethodID m_get_content_resolver = env->GetMethodID(c_context, "getContentResolver",
"()Landroid/content/ContentResolver;");
if (m_get_content_resolver == NULL) {
return NULL;
}
jfieldID f_android_string_key = env->GetStaticFieldID(c_settings_system,
key_Name,
"Ljava/lang/String;");
if (f_android_string_key == NULL) {
return NULL;
}
jstring s_android_string_key = (jstring) env->GetStaticObjectField(c_settings_system,
f_android_string_key);
jobject o_content_resolver;
o_content_resolver = env->CallObjectMethod(context,
m_get_content_resolver);
if (o_content_resolver == NULL || s_android_string_key == NULL) {
return NULL;
}
jmethodID m_get_string = env->GetStaticMethodID(c_settings_system, "getString",
"(Landroid/content/ContentResolver;Ljava/lang/String;)Ljava/lang/String;");
if (m_get_string == NULL) {
return NULL;
}
jstring string_key = (jstring) env->CallStaticObjectMethod(c_settings_system,
m_get_string,
o_content_resolver,
s_android_string_key);
return string_key;
}
thank
android c++ android-ndk jni
add a comment |
up vote
0
down vote
favorite
Good day. Please tell me what I'm doing wrong. Implemented getting keys from android / provider / Settings $ System. Keys like ACCELEROMETER_ROTATION look no problem (those described https://developer.android.com/reference/android/provider/Settings.System) but such as sms_delivered_sound, he refuses to search. Writes an error.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.woodman.testlibsettingsv2, PID: 31133
java.lang.NoSuchFieldError: no "Ljava/lang/String;" field "sms_delivered_sound" in class "Landroid/provider/Settings$System;" or its superclasses
at com.example.woodman.testlibsettingsv2.frmMain.GetSystemKyesString(Native Method)
at com.example.woodman.testlibsettingsv2.frmMain.onCreate(frmMain.java:32)
at android.app.Activity.performCreate(Activity.java:7210)
at android.app.Activity.performCreate(Activity.java:7201)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2926)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3081)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6806)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
code
extern "C"
JNIEXPORT jstring JNICALL
Java_com_example_woodman_testlibsettingsv2_frmMain_GetSystemKyesString(JNIEnv *env,
jobject instance,
jstring key_Name_) {
const char *key_Name = env->GetStringUTFChars(key_Name_, 0);
// TODO
jclass activityThread = env->FindClass("android/app/ActivityThread");
jmethodID currentActivityThread = env->GetStaticMethodID(activityThread,
"currentActivityThread",
"()Landroid/app/ActivityThread;");
jobject at = env->CallStaticObjectMethod(activityThread, currentActivityThread);
jmethodID getApplication = env->GetMethodID(activityThread, "getApplication",
"()Landroid/app/Application;");
jobject context = env->CallObjectMethod(at, getApplication);
jclass c_settings_system = env->FindClass("android/provider/Settings$System");
jclass c_context = env->FindClass("android/content/Context");
if (c_settings_system == NULL || c_context == NULL) {
return NULL;
}
jmethodID m_get_content_resolver = env->GetMethodID(c_context, "getContentResolver",
"()Landroid/content/ContentResolver;");
if (m_get_content_resolver == NULL) {
return NULL;
}
jfieldID f_android_string_key = env->GetStaticFieldID(c_settings_system,
key_Name,
"Ljava/lang/String;");
if (f_android_string_key == NULL) {
return NULL;
}
jstring s_android_string_key = (jstring) env->GetStaticObjectField(c_settings_system,
f_android_string_key);
jobject o_content_resolver;
o_content_resolver = env->CallObjectMethod(context,
m_get_content_resolver);
if (o_content_resolver == NULL || s_android_string_key == NULL) {
return NULL;
}
jmethodID m_get_string = env->GetStaticMethodID(c_settings_system, "getString",
"(Landroid/content/ContentResolver;Ljava/lang/String;)Ljava/lang/String;");
if (m_get_string == NULL) {
return NULL;
}
jstring string_key = (jstring) env->CallStaticObjectMethod(c_settings_system,
m_get_string,
o_content_resolver,
s_android_string_key);
return string_key;
}
thank
android c++ android-ndk jni
2
The documentation you linked shows no evidence of such a field existing. Is it possible you wanted to call thegetString(ContentResolver, String)
method of settings.System instead?
– Botje
Nov 19 at 9:43
below answered.
– Алексей
Nov 19 at 10:59
Can you tell me how to do this?
– Алексей
Nov 20 at 11:14
I just noticed that you already implement this in the last block of your code. Split up this code in the case where you can get a static field or have to use getString. Alternatively, clear exceptions if the GetStaticFieldID fails and continue with the function.
– Botje
Nov 21 at 12:22
Everything. Understood. Thanks to all. The problem was in the crooked code.
– Алексей
Nov 22 at 7:55
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Good day. Please tell me what I'm doing wrong. Implemented getting keys from android / provider / Settings $ System. Keys like ACCELEROMETER_ROTATION look no problem (those described https://developer.android.com/reference/android/provider/Settings.System) but such as sms_delivered_sound, he refuses to search. Writes an error.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.woodman.testlibsettingsv2, PID: 31133
java.lang.NoSuchFieldError: no "Ljava/lang/String;" field "sms_delivered_sound" in class "Landroid/provider/Settings$System;" or its superclasses
at com.example.woodman.testlibsettingsv2.frmMain.GetSystemKyesString(Native Method)
at com.example.woodman.testlibsettingsv2.frmMain.onCreate(frmMain.java:32)
at android.app.Activity.performCreate(Activity.java:7210)
at android.app.Activity.performCreate(Activity.java:7201)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2926)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3081)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6806)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
code
extern "C"
JNIEXPORT jstring JNICALL
Java_com_example_woodman_testlibsettingsv2_frmMain_GetSystemKyesString(JNIEnv *env,
jobject instance,
jstring key_Name_) {
const char *key_Name = env->GetStringUTFChars(key_Name_, 0);
// TODO
jclass activityThread = env->FindClass("android/app/ActivityThread");
jmethodID currentActivityThread = env->GetStaticMethodID(activityThread,
"currentActivityThread",
"()Landroid/app/ActivityThread;");
jobject at = env->CallStaticObjectMethod(activityThread, currentActivityThread);
jmethodID getApplication = env->GetMethodID(activityThread, "getApplication",
"()Landroid/app/Application;");
jobject context = env->CallObjectMethod(at, getApplication);
jclass c_settings_system = env->FindClass("android/provider/Settings$System");
jclass c_context = env->FindClass("android/content/Context");
if (c_settings_system == NULL || c_context == NULL) {
return NULL;
}
jmethodID m_get_content_resolver = env->GetMethodID(c_context, "getContentResolver",
"()Landroid/content/ContentResolver;");
if (m_get_content_resolver == NULL) {
return NULL;
}
jfieldID f_android_string_key = env->GetStaticFieldID(c_settings_system,
key_Name,
"Ljava/lang/String;");
if (f_android_string_key == NULL) {
return NULL;
}
jstring s_android_string_key = (jstring) env->GetStaticObjectField(c_settings_system,
f_android_string_key);
jobject o_content_resolver;
o_content_resolver = env->CallObjectMethod(context,
m_get_content_resolver);
if (o_content_resolver == NULL || s_android_string_key == NULL) {
return NULL;
}
jmethodID m_get_string = env->GetStaticMethodID(c_settings_system, "getString",
"(Landroid/content/ContentResolver;Ljava/lang/String;)Ljava/lang/String;");
if (m_get_string == NULL) {
return NULL;
}
jstring string_key = (jstring) env->CallStaticObjectMethod(c_settings_system,
m_get_string,
o_content_resolver,
s_android_string_key);
return string_key;
}
thank
android c++ android-ndk jni
Good day. Please tell me what I'm doing wrong. Implemented getting keys from android / provider / Settings $ System. Keys like ACCELEROMETER_ROTATION look no problem (those described https://developer.android.com/reference/android/provider/Settings.System) but such as sms_delivered_sound, he refuses to search. Writes an error.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.woodman.testlibsettingsv2, PID: 31133
java.lang.NoSuchFieldError: no "Ljava/lang/String;" field "sms_delivered_sound" in class "Landroid/provider/Settings$System;" or its superclasses
at com.example.woodman.testlibsettingsv2.frmMain.GetSystemKyesString(Native Method)
at com.example.woodman.testlibsettingsv2.frmMain.onCreate(frmMain.java:32)
at android.app.Activity.performCreate(Activity.java:7210)
at android.app.Activity.performCreate(Activity.java:7201)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2926)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3081)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6806)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
code
extern "C"
JNIEXPORT jstring JNICALL
Java_com_example_woodman_testlibsettingsv2_frmMain_GetSystemKyesString(JNIEnv *env,
jobject instance,
jstring key_Name_) {
const char *key_Name = env->GetStringUTFChars(key_Name_, 0);
// TODO
jclass activityThread = env->FindClass("android/app/ActivityThread");
jmethodID currentActivityThread = env->GetStaticMethodID(activityThread,
"currentActivityThread",
"()Landroid/app/ActivityThread;");
jobject at = env->CallStaticObjectMethod(activityThread, currentActivityThread);
jmethodID getApplication = env->GetMethodID(activityThread, "getApplication",
"()Landroid/app/Application;");
jobject context = env->CallObjectMethod(at, getApplication);
jclass c_settings_system = env->FindClass("android/provider/Settings$System");
jclass c_context = env->FindClass("android/content/Context");
if (c_settings_system == NULL || c_context == NULL) {
return NULL;
}
jmethodID m_get_content_resolver = env->GetMethodID(c_context, "getContentResolver",
"()Landroid/content/ContentResolver;");
if (m_get_content_resolver == NULL) {
return NULL;
}
jfieldID f_android_string_key = env->GetStaticFieldID(c_settings_system,
key_Name,
"Ljava/lang/String;");
if (f_android_string_key == NULL) {
return NULL;
}
jstring s_android_string_key = (jstring) env->GetStaticObjectField(c_settings_system,
f_android_string_key);
jobject o_content_resolver;
o_content_resolver = env->CallObjectMethod(context,
m_get_content_resolver);
if (o_content_resolver == NULL || s_android_string_key == NULL) {
return NULL;
}
jmethodID m_get_string = env->GetStaticMethodID(c_settings_system, "getString",
"(Landroid/content/ContentResolver;Ljava/lang/String;)Ljava/lang/String;");
if (m_get_string == NULL) {
return NULL;
}
jstring string_key = (jstring) env->CallStaticObjectMethod(c_settings_system,
m_get_string,
o_content_resolver,
s_android_string_key);
return string_key;
}
thank
android c++ android-ndk jni
android c++ android-ndk jni
asked Nov 19 at 9:14
Алексей
84
84
2
The documentation you linked shows no evidence of such a field existing. Is it possible you wanted to call thegetString(ContentResolver, String)
method of settings.System instead?
– Botje
Nov 19 at 9:43
below answered.
– Алексей
Nov 19 at 10:59
Can you tell me how to do this?
– Алексей
Nov 20 at 11:14
I just noticed that you already implement this in the last block of your code. Split up this code in the case where you can get a static field or have to use getString. Alternatively, clear exceptions if the GetStaticFieldID fails and continue with the function.
– Botje
Nov 21 at 12:22
Everything. Understood. Thanks to all. The problem was in the crooked code.
– Алексей
Nov 22 at 7:55
add a comment |
2
The documentation you linked shows no evidence of such a field existing. Is it possible you wanted to call thegetString(ContentResolver, String)
method of settings.System instead?
– Botje
Nov 19 at 9:43
below answered.
– Алексей
Nov 19 at 10:59
Can you tell me how to do this?
– Алексей
Nov 20 at 11:14
I just noticed that you already implement this in the last block of your code. Split up this code in the case where you can get a static field or have to use getString. Alternatively, clear exceptions if the GetStaticFieldID fails and continue with the function.
– Botje
Nov 21 at 12:22
Everything. Understood. Thanks to all. The problem was in the crooked code.
– Алексей
Nov 22 at 7:55
2
2
The documentation you linked shows no evidence of such a field existing. Is it possible you wanted to call the
getString(ContentResolver, String)
method of settings.System instead?– Botje
Nov 19 at 9:43
The documentation you linked shows no evidence of such a field existing. Is it possible you wanted to call the
getString(ContentResolver, String)
method of settings.System instead?– Botje
Nov 19 at 9:43
below answered.
– Алексей
Nov 19 at 10:59
below answered.
– Алексей
Nov 19 at 10:59
Can you tell me how to do this?
– Алексей
Nov 20 at 11:14
Can you tell me how to do this?
– Алексей
Nov 20 at 11:14
I just noticed that you already implement this in the last block of your code. Split up this code in the case where you can get a static field or have to use getString. Alternatively, clear exceptions if the GetStaticFieldID fails and continue with the function.
– Botje
Nov 21 at 12:22
I just noticed that you already implement this in the last block of your code. Split up this code in the case where you can get a static field or have to use getString. Alternatively, clear exceptions if the GetStaticFieldID fails and continue with the function.
– Botje
Nov 21 at 12:22
Everything. Understood. Thanks to all. The problem was in the crooked code.
– Алексей
Nov 22 at 7:55
Everything. Understood. Thanks to all. The problem was in the crooked code.
– Алексей
Nov 22 at 7:55
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
This value is not part of system settings. Actually, it can be found on miui framework but not in other Android systems.
There is no public API to read this setting, neither in C++ not in Java. But we know that this value is written in system/build.prop file in simple key=value format.
This file is readable for everybody. You don't need JNI to read it, usual C++ or even C file APIs will work perfectly.
A more flexible approach would be to run the settings
command from your code.
I do not see the connection between the repositories in the android and the shell. in the terminal, run the settings list system command and see a bunch of keys and their values. here I also need to receive them.
– Алексей
Nov 20 at 5:39
Fair enough, you can callsystem("settings get system sms_delivered_sound")
and parse the output, just as you can runRuntime.getRuntime.exec("settings get system sms_delivered_sound")
from Java.
– Alex Cohn
Nov 20 at 7:10
1
thanks for the advice. but I don’t know where to look. Already reread everything. No where is nothing documented.
– Алексей
Nov 20 at 8:08
execution of the settings list system command. It shows the number of keys. if you run the settings get system sms_delivered_sound command, it returns file: ///system/media/audio/notifications/MessageSent.ogg. but if I try to get the value of this key through getString, I get an error
– Алексей
Nov 20 at 14:49
"if I try to get the value of this key through getString, I get an error" I cannot verify this, because on my device this setting does not exist, and I don't see your latest code. But I believe that runningsettings get
command is easier than fighting theSettings$System
service with JNI.
– Alex Cohn
Nov 20 at 15:51
|
show 2 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
This value is not part of system settings. Actually, it can be found on miui framework but not in other Android systems.
There is no public API to read this setting, neither in C++ not in Java. But we know that this value is written in system/build.prop file in simple key=value format.
This file is readable for everybody. You don't need JNI to read it, usual C++ or even C file APIs will work perfectly.
A more flexible approach would be to run the settings
command from your code.
I do not see the connection between the repositories in the android and the shell. in the terminal, run the settings list system command and see a bunch of keys and their values. here I also need to receive them.
– Алексей
Nov 20 at 5:39
Fair enough, you can callsystem("settings get system sms_delivered_sound")
and parse the output, just as you can runRuntime.getRuntime.exec("settings get system sms_delivered_sound")
from Java.
– Alex Cohn
Nov 20 at 7:10
1
thanks for the advice. but I don’t know where to look. Already reread everything. No where is nothing documented.
– Алексей
Nov 20 at 8:08
execution of the settings list system command. It shows the number of keys. if you run the settings get system sms_delivered_sound command, it returns file: ///system/media/audio/notifications/MessageSent.ogg. but if I try to get the value of this key through getString, I get an error
– Алексей
Nov 20 at 14:49
"if I try to get the value of this key through getString, I get an error" I cannot verify this, because on my device this setting does not exist, and I don't see your latest code. But I believe that runningsettings get
command is easier than fighting theSettings$System
service with JNI.
– Alex Cohn
Nov 20 at 15:51
|
show 2 more comments
up vote
1
down vote
This value is not part of system settings. Actually, it can be found on miui framework but not in other Android systems.
There is no public API to read this setting, neither in C++ not in Java. But we know that this value is written in system/build.prop file in simple key=value format.
This file is readable for everybody. You don't need JNI to read it, usual C++ or even C file APIs will work perfectly.
A more flexible approach would be to run the settings
command from your code.
I do not see the connection between the repositories in the android and the shell. in the terminal, run the settings list system command and see a bunch of keys and their values. here I also need to receive them.
– Алексей
Nov 20 at 5:39
Fair enough, you can callsystem("settings get system sms_delivered_sound")
and parse the output, just as you can runRuntime.getRuntime.exec("settings get system sms_delivered_sound")
from Java.
– Alex Cohn
Nov 20 at 7:10
1
thanks for the advice. but I don’t know where to look. Already reread everything. No where is nothing documented.
– Алексей
Nov 20 at 8:08
execution of the settings list system command. It shows the number of keys. if you run the settings get system sms_delivered_sound command, it returns file: ///system/media/audio/notifications/MessageSent.ogg. but if I try to get the value of this key through getString, I get an error
– Алексей
Nov 20 at 14:49
"if I try to get the value of this key through getString, I get an error" I cannot verify this, because on my device this setting does not exist, and I don't see your latest code. But I believe that runningsettings get
command is easier than fighting theSettings$System
service with JNI.
– Alex Cohn
Nov 20 at 15:51
|
show 2 more comments
up vote
1
down vote
up vote
1
down vote
This value is not part of system settings. Actually, it can be found on miui framework but not in other Android systems.
There is no public API to read this setting, neither in C++ not in Java. But we know that this value is written in system/build.prop file in simple key=value format.
This file is readable for everybody. You don't need JNI to read it, usual C++ or even C file APIs will work perfectly.
A more flexible approach would be to run the settings
command from your code.
This value is not part of system settings. Actually, it can be found on miui framework but not in other Android systems.
There is no public API to read this setting, neither in C++ not in Java. But we know that this value is written in system/build.prop file in simple key=value format.
This file is readable for everybody. You don't need JNI to read it, usual C++ or even C file APIs will work perfectly.
A more flexible approach would be to run the settings
command from your code.
edited Nov 20 at 7:40
answered Nov 19 at 18:29
Alex Cohn
40.4k551183
40.4k551183
I do not see the connection between the repositories in the android and the shell. in the terminal, run the settings list system command and see a bunch of keys and their values. here I also need to receive them.
– Алексей
Nov 20 at 5:39
Fair enough, you can callsystem("settings get system sms_delivered_sound")
and parse the output, just as you can runRuntime.getRuntime.exec("settings get system sms_delivered_sound")
from Java.
– Alex Cohn
Nov 20 at 7:10
1
thanks for the advice. but I don’t know where to look. Already reread everything. No where is nothing documented.
– Алексей
Nov 20 at 8:08
execution of the settings list system command. It shows the number of keys. if you run the settings get system sms_delivered_sound command, it returns file: ///system/media/audio/notifications/MessageSent.ogg. but if I try to get the value of this key through getString, I get an error
– Алексей
Nov 20 at 14:49
"if I try to get the value of this key through getString, I get an error" I cannot verify this, because on my device this setting does not exist, and I don't see your latest code. But I believe that runningsettings get
command is easier than fighting theSettings$System
service with JNI.
– Alex Cohn
Nov 20 at 15:51
|
show 2 more comments
I do not see the connection between the repositories in the android and the shell. in the terminal, run the settings list system command and see a bunch of keys and their values. here I also need to receive them.
– Алексей
Nov 20 at 5:39
Fair enough, you can callsystem("settings get system sms_delivered_sound")
and parse the output, just as you can runRuntime.getRuntime.exec("settings get system sms_delivered_sound")
from Java.
– Alex Cohn
Nov 20 at 7:10
1
thanks for the advice. but I don’t know where to look. Already reread everything. No where is nothing documented.
– Алексей
Nov 20 at 8:08
execution of the settings list system command. It shows the number of keys. if you run the settings get system sms_delivered_sound command, it returns file: ///system/media/audio/notifications/MessageSent.ogg. but if I try to get the value of this key through getString, I get an error
– Алексей
Nov 20 at 14:49
"if I try to get the value of this key through getString, I get an error" I cannot verify this, because on my device this setting does not exist, and I don't see your latest code. But I believe that runningsettings get
command is easier than fighting theSettings$System
service with JNI.
– Alex Cohn
Nov 20 at 15:51
I do not see the connection between the repositories in the android and the shell. in the terminal, run the settings list system command and see a bunch of keys and their values. here I also need to receive them.
– Алексей
Nov 20 at 5:39
I do not see the connection between the repositories in the android and the shell. in the terminal, run the settings list system command and see a bunch of keys and their values. here I also need to receive them.
– Алексей
Nov 20 at 5:39
Fair enough, you can call
system("settings get system sms_delivered_sound")
and parse the output, just as you can run Runtime.getRuntime.exec("settings get system sms_delivered_sound")
from Java.– Alex Cohn
Nov 20 at 7:10
Fair enough, you can call
system("settings get system sms_delivered_sound")
and parse the output, just as you can run Runtime.getRuntime.exec("settings get system sms_delivered_sound")
from Java.– Alex Cohn
Nov 20 at 7:10
1
1
thanks for the advice. but I don’t know where to look. Already reread everything. No where is nothing documented.
– Алексей
Nov 20 at 8:08
thanks for the advice. but I don’t know where to look. Already reread everything. No where is nothing documented.
– Алексей
Nov 20 at 8:08
execution of the settings list system command. It shows the number of keys. if you run the settings get system sms_delivered_sound command, it returns file: ///system/media/audio/notifications/MessageSent.ogg. but if I try to get the value of this key through getString, I get an error
– Алексей
Nov 20 at 14:49
execution of the settings list system command. It shows the number of keys. if you run the settings get system sms_delivered_sound command, it returns file: ///system/media/audio/notifications/MessageSent.ogg. but if I try to get the value of this key through getString, I get an error
– Алексей
Nov 20 at 14:49
"if I try to get the value of this key through getString, I get an error" I cannot verify this, because on my device this setting does not exist, and I don't see your latest code. But I believe that running
settings get
command is easier than fighting the Settings$System
service with JNI.– Alex Cohn
Nov 20 at 15:51
"if I try to get the value of this key through getString, I get an error" I cannot verify this, because on my device this setting does not exist, and I don't see your latest code. But I believe that running
settings get
command is easier than fighting the Settings$System
service with JNI.– Alex Cohn
Nov 20 at 15:51
|
show 2 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371439%2fjava-lang-nosuchfielderror-no-ljava-lang-string-field-jni%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
The documentation you linked shows no evidence of such a field existing. Is it possible you wanted to call the
getString(ContentResolver, String)
method of settings.System instead?– Botje
Nov 19 at 9:43
below answered.
– Алексей
Nov 19 at 10:59
Can you tell me how to do this?
– Алексей
Nov 20 at 11:14
I just noticed that you already implement this in the last block of your code. Split up this code in the case where you can get a static field or have to use getString. Alternatively, clear exceptions if the GetStaticFieldID fails and continue with the function.
– Botje
Nov 21 at 12:22
Everything. Understood. Thanks to all. The problem was in the crooked code.
– Алексей
Nov 22 at 7:55