首先要做的事情;据我所知,不可能从静态方法调用非静态方法,如此处详述。
问:我想知道是否可以使用构造函数方法将字符串(非静态)设置为静态,以便我可以跨 Java 类静态地将字符串传递到 JNI:
Intent myIntent = new Intent(Intent.ACTION_VIEW);
String argument = "iqsrc://"+ arguments.getText().toString();
Uri myUri = Uri.parse(argument);
myIntent.setData(myUri);
startActivity(myIntent);
String arguments = new argument
//Used to pass static string to /from java
每次非静态字符串更改时,新的静态值也会更改吗?
最佳答案
First thing first; I understand that it is not possible to call a static method from a non-static method
首先,您可以从非静态方法调用静态方法。您不能从静态方法调用非静态方法。
如果您愿意,您可以从非静态方法设置静态变量:
static String foo;
void myNonStaticMethod() {
foo = "bar";
}
关于java - 获取/设置非静态字符串为静态字符串以通过Java传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20532010/