mercredi 4 mars 2015

Sms app code not working take in account I'm a beginner



Hi i'm trying to make a messaging app in java but running into a few problems, please help!



@Override
public boolean onCreateOptionsMenu(Menu menu) {


Inflate the menu; this adds items to the action bar if it is present.



getMenuInflater().inflate(R.menu.menu_main_activity2, menu);

no=(EditText)findViewById(R.id.editText);
msg=(EditText)findViewById(R.id.editText2);
btnsendSms=(Button)findViewById(R.id.button1);

bntSendsms.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {

sendSms();
}
});
return true;
}
protected void sendSms(){
string number=no.gettext().toString();
string message=msg.getText().toString();

SmsManager manager= SmsManager.getDefault();
manager.sendTextMessage(number, null, message, null, null);
Toast.makeText(getApplicationContext(), "send succesfully", Toast.LENGTH_LONG).show();
}



Aucun commentaire:

Enregistrer un commentaire