I have an apk that contains classes.dex. I dont't have apk source code. I have loaded an activity from dex file(LoginActivity) and implemented onClicklistener for button1 in LoginActivity. I succeeded to load dex file and started activity from dex file via this code:
DexClassLoader dex = new DexClassLoader(dexInternalStoragePath.getAbsolutePath(), mAppContext.getCacheDir().getPath(), null, loader);
toasterClass = dex.loadClass("com.example.myapplication.ui.login.LoginActivity");
Intent intent = new Intent();
intent.setClass(getApplicationContext(),toasterClass);
setContentView(View.inflate(getApplicationContext(), R.layout.activity_login, null));
Button mAddTaskButton = (Button) findViewById(R.id.button2);
mAddTaskButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog aldlg = new AlertDialog.Builder(gLoginActivity.this).create();
aldlg.setTitle("Login");
aldlg.setMessage("You pressed Login Button");
aldlg.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
aldlg.show();
}
});
startActivity(intent);
but when I clicked button2, it didn't show alertdialog. I think android is preventing to change onClicklistener outside from activity. Is it correct? Any help how to implement this?