My app contains an activity, named sendMms, where information concerning recipient number, subject, message and image attachment are specified. The image is always a jpg-file and the code that runs, when the send button, in the activity sendMms, is pressed, is presented below:

public void sendMms(View view){

    // The information concerning recipient number, subject and message are retrieved.
    String recipient = mmsRecipientEditText.getText().toString().trim();
    String subject = mmsSubjectEditText.getText().toString().trim();
    String message = mmsMessageEditText.getText().toString().trim();

    try{
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.putExtra("address", recipient);
        intent.putExtra("subject", subject);

        // The variable mmsAttachmentImageView is the ImageView for the picture of the activity.
        if(mmsAttachmentImageView.getDrawable() != null){
            // The variable mmsAttachmentUrl contains the path to the jpg-file containing the picture.
            intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile( new File(mmsAttachmentUrl.trim())));
        }

        intent.setType("image/jpg");            
        intent.putExtra("sms_body", message);
        startActivity(Intent.createChooser(intent, "Send MMS with..."));

    } catch(Exception e) {
        Log.e(getString(R.string.log_tag), e.getMessage());
    }
}

The code above works very well when it comes to my own "Samsung galaxy S4 mini", api 19, and the "Nexus One" emulator devices, api 19, 21 and 22. The result from the "Nexus One" emulator device with api 22 can be viewed by using the link below:

Messaging app result api 22

However when I try to run my app on the "Nexus One" emulator device with api 23 the result looks like this when all the information was specified, in the activity sendMms, and passed on to the messaging app:

Messaging app result api 23

And as you can see the neither the subject or the image is showing up. Even after I granted the permission for the messaging app to access photos, media and files on the device the result is the same. Also, the result varies depending on what information I choose to pass on. The result of the different combinations are presented below:

  • Information passed on = Information presented in result
  • Recipient number, Subject, Message and Image = Recipient number and Message
  • Recipient number, Subject and Message = Recipient number and Message
  • Recipient number, Subject and Image = Recipient number
  • Recipient number, Message and Image = Recipient number and Message
  • Subject, Message and Image = Image
  • Recipient number and Subject = Recipient number
  • Recipient number and Message = Recipient number and Message
  • Recipient number and Image = Recipient number and Image
  • Subject and Message = Nothing
  • Subject and Image = Image
  • Message and Image = Image
  • Recipient number = Recipient number
  • Subject = Nothing
  • Message = Nothing
  • Image = Image
  • Nothing = Nothing

As you can see the recipient number is always presented in the result whereas the message and image are presented depending on combination. The subject however is never presented in the result.

Worth to mention is that I have read the documentation for ACTION_SEND and I have tried to use extras, such as Intent.EXTRA_TEXT, Intent.EXTRA_SUBJECT and Intent.EXTRA_PHONE_NUMBER, but no luck there. I'm also aware of that there is no requirement for any app to handle arbitrary undocumented extras. But as mentioned above the extra ”sms_body” did work occasionally and the extra Intent.EXTRA_STREAM did also work occasionally so it seems that the messaging app recognizes these extras but for some reason does not always handle these.

So with this in mind and with the knowledge of that there is no requirement for any app to handle arbitrary undocumented extras, what should I do? How can I successfully pass on all information to the messaging app that runs on my "Nexus One" emulator device with api 23?

0

There are 0 answers