Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package thieu.mao;
- import thieu.mao.R.string;
- import android.net.Uri;
- import android.os.Bundle;
- import android.app.Activity;
- import android.content.Intent;
- import android.telephony.SmsManager;
- import android.view.Menu;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- public class MainActivity extends Activity {
- private EditText etNumber;
- private EditText etContent;
- private Button btSend;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.giaodien);
- etNumber = (EditText) findViewById(R.id.etNumber);
- etContent = (EditText) findViewById(R.id.etContent);
- btSend = (Button) findViewById(R.id.btSend);
- btSend.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- // TODO Auto-generated method stub
- String strNumber = etNumber.getText().toString();
- if ((strNumber.length() != 10) && (strNumber.length() != 11)) {
- strNumber = "0917735107";
- }
- Uri uri = Uri.parse("smsto:" + strNumber);
- Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
- String strContent = etContent.getText().toString();
- intent.putExtra("sms_body", strContent);
- startActivity(intent);
- }
- });
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.main, menu);
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment