Question

First thing first; I understand that it is not possible to call a non-static method from a static method as detailed here.

Q: I was wondering if I can set the string (non-static) as static with a constructor method so that I can pass the string staticly across java classes and to 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

and will every time the non-static string changes a new static value be changing as well?

Was it helpful?

Solution

First thing first; I understand that it is not possible to call a static method from a non-static method

First things first, you can call a static method from a non-static method. You can't call a non-static method from a static method.

You can set a static variable from a non-static method if that is your intention:

static String foo;

void myNonStaticMethod() {
    foo = "bar";
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top