I'm trying to modify the Android source in the following way: When the user sends an SMS, a popup window (in the form of a new activity) is displayed from within SmSManager class asking if the user is sure that he wants to send the SMS. If he clicks OK the message is sent. Otherwise it's not. I have successfully displayed the popup window but now I'm stuck on the onClick event. How can I pass data from the activity to the SmSManager class?
Edit: Code as requested
In SmsManager.sendTextMessage()
:
Intent smsIntent = new Intent(Intent.ACTION_MAIN, null);
smsIntent.setComponent(new ComponentName("com.package", "com.package.MyActivity"));
smsIntent.addCategory(Intent.CATEGORY_LAUNCHER);
smsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ActivityThread.currentApplication().getApplicationContext().startActivity(smsIntent);
In MyActivity
final Button btn_ok = (Button) findViewById(R.id.btn_ok);
btn_ok.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// What do I need to write here?
finish();
}
});
I found a workaround myself. I'm storing a value in SharedPreferences in my activity and I retrieve it in the SmsManager class. It works for me, but I don't know if it's acceptable from a security point of view