0

Have written below code to share text in android. Issue i am facing is to prefill the phone number in the sms app.

public static void shareText(final String extraText, final String extraEmail, final String phoneNumber) {
    Intent textShareIntent = new Intent(android.content.Intent.ACTION_SEND);
    textShareIntent.setType("text/plain");
    if (null != extraText) {
        textShareIntent.putExtra(android.content.Intent.EXTRA_TEXT, extraText);
    }
    if (null != extraEmail) {
        textShareIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{extraEmail});
    }
    if (null != phoneNumber) {
        textShareIntent.putExtra(Intent.EXTRA_PHONE_NUMBER, new String[]{phoneNumber});
    }
    startActivity(Intent.createChooser(textShareIntent, "Share via"));
}
ColdFire
  • 6,764
  • 6
  • 35
  • 51
Ankur
  • 677
  • 1
  • 7
  • 21
  • Did you check this? https://stackoverflow.com/questions/17672634/i-want-to-send-sms-from-android-application-using-sms-manager – Vikas B L Apr 09 '18 at 08:38
  • No i dont want to send an sms. I want to provide options to user to share text. He/She will select the option. If sms app is selected -> i want to prefill the mobile number – Ankur Apr 09 '18 at 10:49

1 Answers1

1

If I am not wrong, the scenario you are looking for is that you give option on screen to send message(from WhatsApp or SMS) and if it is SMS, it has to prefill the number. As far as I know and researched, you cannot integrate both functionality in one till date as SMS is a standard protocol in mobile and other messaging services like WhatsApp are not(what I mean is they do not support look for SMS protocol An example of messaging app) . What all you can give to give option for SMS where you can open SMS supporting app where in it prefills the number(which is what you require) and messaging which will option other options where in it will open other messaging application(WhatsApp, Telegram). check this

Vikas B L
  • 397
  • 1
  • 10
  • yeah but need mailing apps too in that. Anyways figured out a custom way to do it. Have shown the required apps in the custom ui and will send the required intent on click – Ankur Apr 10 '18 at 07:19