I am doing one SMS App.. in which i am trying to validate edittext(i.e. if user will not enter the phone number then it will show please enter the number), but it is not executing those part.. Please check it and give me some suggestion....My code is here.. Thank you in advance..
public class MainActivity extends Activity {
    Button btnSend;
    EditText txtPhoneNo;
    EditText txtSMS; 
    String phoneNo, SMS;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btnSend=(Button) findViewById(R.id.buttonSend);
        txtPhoneNo=(EditText) findViewById(R.id.editTextPhoneNo);
        txtSMS=(EditText) findViewById(R.id.editTextSMS);
        btnSend.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                phoneNo=txtPhoneNo.getText().toString();
                SMS=txtSMS.getText().toString();
                if(phoneNo.equals(" ") || phoneNo == null) {
                    Toast.makeText(getBaseContext(), "Please Enter the number !", Toast.LENGTH_LONG).show();
                }
                else {
                MyAsync ma = new MyAsync();
                ma.execute();
                }
            }
        });
    }
    class MyAsync extends AsyncTask<Void,Void,Void> {
        ProgressDialog pd;
        @Override
        protected void onPreExecute() {
            // TODO Auto-generated method stub
            super.onPreExecute();
            pd = ProgressDialog.show(MainActivity.this, "Wait!", "Sending...");
        }
        @Override
        protected Void doInBackground(Void... arg0) {
            // TODO Auto-generated method stub
                try {
                    SmsManager smsManager=SmsManager.getDefault();
                    smsManager.sendTextMessage(phoneNo, null, SMS, null, null);
            } catch (Exception e) {             
                    Toast.makeText(getApplicationContext(), "SMS faild, please try again later!",Toast.LENGTH_LONG).show();
                    e.printStackTrace();
            }
            return null;
        }
        @Override
        protected void onPostExecute(Void result) {
            // TODO Auto-generated method stub
            super.onPostExecute(result);
            pd.cancel();
            Toast.makeText(getApplicationContext(),"Sent",Toast.LENGTH_LONG).show();
        }
    }
}
    
android:inputType="number". So you can enter only numbers and you useTextUtils.isEmpty(string)to validate.