Reputation: 11
I have an SMS application.Here i wish to use the send button to send sms in that activity as well as move on to new activity.I have written code to send sms.But dono how to go to another activity at the same time.Kindly help.This is the code.
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
String mobileno=pno.getText().toString();
String text=msg.getText().toString();
sentsms(mobileno,text);
}
});
Upvotes: 1
Views: 36
Reputation: 4217
Try this..
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
String mobileno=pno.getText().toString().trim();
String text=msg.getText().toString().trim();
sentsms(mobileno,text);
Intent intent = new Intent(this, YourActivityName.class);
startActivity(intent);
}
});
Upvotes: 0
Reputation: 6044
Please look at the code below:
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
String mobileno=pno.getText().toString();
String text=msg.getText().toString();
sentsms(mobileno,text);
// start other activity here
Intent intent = new Intent(CurrentActivity.this,
YourOtherActivity.class);
startActivity(intent);
}
});
Upvotes: 1
Reputation: 12919
Use something like this:
Intent intent = new Intent(this, YourSecondActivity.class);
startActivity(intent);
In your onClick, this would be:
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
String mobileno=pno.getText().toString();
String text=msg.getText().toString();
sentsms(mobileno,text);
Intent intent = new Intent(this, YourSecondActivity.class);
startActivity(intent);
}
});
Upvotes: 1