Question

So I have an app that has a button where when you click it the sms app opens and a body populates which you can then send to whoever. I am using:

Intent shareIntent = new Intent(Intent.ACTION_VIEW);
shareIntent.putExtra("sms_body", getResources().getString(R.string.sharingSMS));
shareIntent.setType("vnd.android-dir/mms-sms");
startActivity(shareIntent);

This works on almost all phones I have tried it on but on the Motorola Razr (Which annoys me since I have had many problems with their code being different) the sms body is blank. Now, when I use:

shareIntent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.sharingSMS));

instead of sms_body it works fine but doesn't work with any other phones. After searching around for issues on this I found that since sms_body is not part of the android OS specifically it doesn't have to work with all phones. When I search around for how to send an sms also everything says to do it the first way I do it with sms_body. Another thing I tried was to add both extras, then it worked on all the phones I tested it on but other people have gotten a crash with the following: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW typ=vnd.android-dir/mms-sms (has extras) }

By searching for things what I found seems like this error occurs because I have both extras attached and it tries to find things to do with both and can't find the second when it already uses one, but I'm not sure about that. In the end what I am trying to do is find something that will work with all phones or a way to use both extras without the crash. I have been looking around for a while and have found similar questions on multiple places but none of them have been answered, so any help would be great.

Was it helpful?

Solution

After playing with it I found that you can just use things for different phones. I used this code to find out what phone it is:

String manuModel = Build.MANUFACTURER + " " + Build.MODEL;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top