So, I'm building an application that would send an automatic SMS to another phone. Just like the "hello world!" SMS sample, it would send the same SMS as the button implies. However, when I press the button; it would pop-up the built-in SMS page that would allow the user to edit the text or Phone #.
Here's my code (MainActivity.java):
public class MainActivity extends Activity {
private EditText messageNumber;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
messageNumber=(EditText)findViewById(R.id.messageNumber);
}
/*LOCK BUTTON*/
public void Lock(View v) {
String _messageNumber=messageNumber.getText().toString();
String messageText = "F4";
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setData(Uri.parse("sms:"+_messageNumber));
sendIntent.putExtra("sms_body", messageText);
startActivity(sendIntent);
}
Aucun commentaire:
Enregistrer un commentaire