wait a little before finish my activity
<p>What's the best way to wait before my activity is finished?</p>

<p>In fact I launch a new activity named MasterNumber from MainActivity with "startActivityForResult". MasterNumber send a SMS and shows a Toast to say "SMS Sent",  but MasterNumber activity is closed so quickly that the Toast is showed in MainActivity.</p>

<p>Here is the content of MainActivity:</p>

<pre><code>//Lorsqu'on clique sur le bouton "Send"
Button button1 = (Button) findViewById(R.id.masterbutton1);
button1.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        try {
            SmsManager smsManager = SmsManager.getDefault();
            smsManager.sendTextMessage(automatikRN, null, "#00#", null, null);
            Toast.makeText(getApplicationContext(), "SMS Sent!",
            Toast.LENGTH_LONG).show();
        }
        catch (Exception e) {
            Toast.makeText(getApplicationContext(),
                "SMS failed, please try again later!",
                Toast.LENGTH_LONG).show();
                e.printStackTrace();
        }
        finish();
    }
});
</code></pre>

<p>and here is the content of MasterNumber (activity)</p>

<pre><code>//Lorsqu'on clique sur le bouton Add Master Number
Button button2 = (Button) findViewById(R.id.mainbutton2);
button2.setOnClickListener(new View.OnClickListener() { 
    @Override
    public void onClick(View v) {
        //On va appeler l'activité MasterNumber (#RECIPIENTNUMBERAUTOMATIK-1)
        Intent setMasterNumber = new Intent(MainActivity.this, MasterNumber.class);
        setMasterNumber.putExtra("MN", recipientNumber);    //on lui fournit le n° du dest. afin qu'il soit saisit automatiquement
        startActivityForResult(setMasterNumber, 1);
    }
});
</code></pre>
