Sending and Receiving SMS and MMS in Android (pre Kit Kat Android 4.4)

前端 未结 6 706
悲&欢浪女
悲&欢浪女 2020-11-21 22:51

I have figured out how to send and receive SMS messages. To send SMS messages I had to call the sendTextMessage() and sendMultipartTextMessage() m

6条回答
  •  萌比男神i
    2020-11-21 23:16

    There is not official api support which means that it is not documented for the public and the libraries may change at any time. I realize you don't want to leave the application but here's how you do it with an intent for anyone else wondering.

    public void sendData(int num){
        String fileString = "..."; //put the location of the file here
        Intent mmsIntent = new Intent(Intent.ACTION_SEND);
        mmsIntent.putExtra("sms_body", "text");
        mmsIntent.putExtra("address", num);
        mmsIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(fileString)));
        mmsIntent.setType("image/jpeg");
        startActivity(Intent.createChooser(mmsIntent, "Send"));
    
    }
    

    I haven't completely figured out how to do things like track the delivery of the message but this should get it sent.

    You can be alerted to the receipt of mms the same way as sms. The intent filter on the receiver should look like this.

    
        
        
    
    

提交回复
热议问题