Making a phonecall from a AlertDialog
<p>Hi I've got a AlertDialog that shows the users some information and two buttons "yes" or "no". If the user press "yes" the application should call a specific number, but the application crashes. My sourcecode:</p>

<pre><code>new AlertDialog.Builder( this )
    .setTitle( "" )
    .setMessage("")
    .setPositiveButton( "Yes", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Log.d( "AlertDialog", "Positive" );
            call();

        }
    })
    .setNegativeButton( "No", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            Log.d( "AlertDialog", "Negative" );
        }
    } )
    .show();
</code></pre>

<p>My call() function</p>

<pre><code> private void call() {
    try {
        Intent callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:123456"));
        startActivity(callIntent);
    } catch (ActivityNotFoundException e) {
        Log.e("Calc", "Call failed", e);
    }
}
</code></pre>

<p>Why, and how can I complete this task? Thanks :) </p>
