GetSet non-static String to static string to pass through Java

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

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?

Answers

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";
}

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/20532010/get-set-non-static-string-to-static-string-to-pass-through-java

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils