KeepSafe / ReLinker

A robust native library loader for Android.
Apache License 2.0
3.21k stars 367 forks source link

help #109

Open chuangdi opened 1 day ago

chuangdi commented 1 day ago

Can I call the relinker.loadlibrary method from a class? I have an Xposed module, but I can't get the context of the MainActivity. Please help. before this, i use system.loadlibray. no context, I have tried many methods but none of them work.

chuangdi commented 1 day ago

code: MainActivity import android.app.Activity; import android.content.Context; import java.lang.reflect.Method; import android.content.Intent; import android.os.Bundle; public class MainActivity extends Activity { private File mLibDir; private File mWorkaroundDir; private EditText version; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } protected void onResume() { super.onResume(); mLibDir = new File(getApplicationInfo().nativeLibraryDir); mWorkaroundDir = getDir("lib", Context.MODE_PRIVATE); updateTree(); findViewById(R.id.call).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String number = "**" call(number); } }); private void call(String num) { ReLinker.loadLibrary(MainActivity.this, "phoneloc-jni");
((TextView) findViewById(R.id.tree)).setText(builder.toString()); } }

other class public class SmartDialXposed implements IXposedHookLoadPackage { String result = ""; String location = ""; String wife = "761"; String number = ""; public String compare(String num) { ReLinker.loader(context, "phoneloc-jni"); // i want loadlibrary in here, need context, how to write code?
} }