Search code examples
javaandroidopenframeworks

Pass String from activity to library class


I trying to pass a string from mainActivity to the activity of a library i been trying using intent but is not recognizing this function has someone done this before?

I get this error:error


Solution

  • create the OFAndroid class like this

    public class OFAndroid {
    
     private String text ;
     public OFAndroid(String text) { 
      this.text = text ; 
     } 
    
    
     public void useText() {
       Log.e("TAG" , this.text);
     }
    }
    

    Inside your MainActivity instantiate OFAndroid:

    OFAndroid of = new OFAndroid("some string");
    

    now you can use the passed String

    of.useText();