How could I make a program that after entering a string and press a key, the string is stored in the phone (SharedPreferences), and then if I open the program to Send Sms(messages), 3 seconds later write in the Message EditText the string stored before.
so far I've done this:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText stringinput = (EditText) findViewById(R.id.string);
Button bu = (Button) findViewById(R.id.button1);
stringinput.setImeOptions(EditorInfo.IME_ACTION_DONE);
bu.setOnClickListener(this);
}
@Override
public void onClick(View v) {
EditText stringinput = (EditText) findViewById(R.id.string);
String name = stringinput.getText().toString();
if(v.getId()==(R.id.string)){
SavePreferences("STRING",name);
}
}
private void SavePreferences(String key, String value){
SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(key, value);
editor.commit();
}
private void LoadPreference(){
SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE);
String strSavedMem1 = sharedPreferences.getString("STRING", "");
/******************** stringoutput.append(strSavedMem1);*******************/
}
}
Ok Now I do not Know how to move forward---> I think that the hardest work is in this function LoadPreferences(); , Perhaps I should Build an Implicit Intent
Intent SEND = new Intent(Intent.ACTION_SEND);
I don't Know , help me plese