Marcus
Marcus

Reputation: 6717

Android is not displaying App Chooser dialog

I'm trying to implement an application that invokes the SMS client application. When the user selects "send SMS" he should be prompted to pick an app to send the sms. This is what I'm doing:

    private void sendSms(String number) {
        Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("sms:"
                + number));
        Intent chooser = Intent.createChooser(intent, getResources()
                .getString(R.string.app_chooser_title));

        startActivity(chooser);

    }

but no chooser is displayed, it opens the default SMS client instantly. What am I doing wrong?

Marcus

Upvotes: 1

Views: 801

Answers (1)

extmkv
extmkv

Reputation: 2045

If you only have 1 app the popup don't appear!

To start launch the sms activity all you need is this:

Intent sendIntent = new Intent(Intent.ACTION_VIEW);         
sendIntent.setData(Uri.parse("sms:"));

You can add extras to populate your own message and such like this

sendIntent.putExtra("sms_body", x); 

then just startActivity with the intent.

startActivity(sendIntent);

Upvotes: 2

Related Questions