MMS in android not working using Intent.ACTION_SEND

三世轮回 提交于 2019-12-22 00:03:47

问题


How can i send an MMS in android ?

My code using UI as follows :

Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("address", "5556");
intent.putExtra("sms_body", "Gudmng !!");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri = Uri.fromFile(new File("/sdcard/sky.png"));
intent.putExtra(Intent.EXTRA_STREAM, uri); // imageUri set
intent.setType("image/*")
startActivity(intent);

But still the exception in sending MMS

ERROR/HierarchicalStateMachine(68): TetherMaster - unhandledMessage: msg.what=3

Any Help?


回答1:


I'm not sure what the problem with your code is, but I have used this and it works:

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/jpg");
sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
sendIntent.putExtra("sms_body", "hello");
sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivityForResult(sendIntent, 0);

Maybe you can incorporate this and change it according to your needs.




回答2:


If you have to send mms with any image then this code.

Intent sendIntent = new Intent(Intent.ACTION_SEND); 
        sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
        sendIntent.putExtra("sms_body", "some text"); 
        sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/image_4.png"));
        sendIntent.setType("image/png");
        startActivity(sendIntent);



回答3:


Try this :

   Intent shareIntent = new Intent();
                shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
                shareIntent.setType("image/*");
                shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Chitza Share");
                // shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, data);
                shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, Activity_Home.sharefileUriList);
//            shareIntent.putExtra(Intent.EXTRA_STREAM, (Serializable) sharefileUriList);//pass uri here
                final List<ResolveInfo> activities = activity.getPackageManager().queryIntentActivities(shareIntent, 0);
                List<DialogItem> appNames = new ArrayList<DialogItem>();
                for (ResolveInfo info : activities) {
                    appNames.add(new DialogItem(info.loadLabel(activity.getPackageManager()).toString(),
                            info.loadIcon(activity.getPackageManager())));
                }


来源:https://stackoverflow.com/questions/5417261/mms-in-android-not-working-using-intent-action-send

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!