我在 MainActivity 中有一个像这样的字段
public class MainActivity extends AppCompatActivity {
private static String field = "abc";
private void setField(Intent intent) {
String field2;
if (intent != null && (field2 = intent.getStringExtra("field")) != null) {
field = field2;
}
}
/* access modifiers changed from: protected */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView((int) R.layout.activity_main);
setField(getIntent());
....
我用这段代码从 Dex 文件加载方法
Class<?> classToLoad = new DexClassLoader(codeFile.getAbsolutePath(), tmpDir.getAbsolutePath(), (String) null, ClassLoader.getSystemClassLoader()).loadClass("com.example.MyClass");
Method method = classToLoad.getDeclaredMethod("run", new Class[0]);
method.invoke(classToLoad, new Object[0]);
那么,在run()方法中,如何获取字段的当前值?谢谢!
public static void run() {
// How?
}