我试图将一个字符串从 mainActivity 传递到 a 的 Activity 我一直在尝试使用 Intent 库,但无法识别此功能,以前有人这样做过吗?
我收到此错误:error
最佳答案
像这样创建OFAndroid
类
public class OFAndroid {
private String text ;
public OFAndroid(String text) {
this.text = text ;
}
public void useText() {
Log.e("TAG" , this.text);
}
}
在您的 MainActivity
中实例化 OFAndroid
:
OFAndroid of = new OFAndroid("some string");
现在您可以使用传递的字符串
of.useText();
关于java - 将字符串从 Activity 传递到库类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57048540/