问题在Android版本4.0.3彩信发送 [英] Issue on sending MMS in Android version 4.0.3

查看:166
本文介绍了问题在Android版本4.0.3彩信发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我想通过我的application.For发送彩信,我的code是

Hi I want to send an MMS through my application.For that my code is

void sendMMS()
    {
        try
        {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            Drawable drawable = imageView.getDrawable();
            Bitmap bitmapPicked = ((BitmapDrawable) drawable).getBitmap();
            bitmapPicked.compress(CompressFormat.JPEG, 75, bos);
            byte[] image = bos.toByteArray();
            File file = new File(Environment.getExternalStorageDirectory() + File.separator + "test.jpg");
            file.createNewFile();
            // write the bytes in file
            FileOutputStream fo = new FileOutputStream(file);
            fo.write(image);

            Log.i(TAG, "image = " + image);

            Intent intentEmail = new Intent(Intent.ACTION_SEND);
            intentEmail.setType("text/plain");
            String[] recipients = new String[] { "" };

            intentEmail.putExtra(Intent.EXTRA_EMAIL, recipients);
            intentEmail.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
            intentEmail.putExtra(Intent.EXTRA_TEXT, "body of email");
            intentEmail.putExtra("sms_body", "body of sms");

            intentEmail.setType("image/jpeg");
            intentEmail.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file.getAbsolutePath()));

            startActivity(intentEmail);
        } catch (android.content.ActivityNotFoundException ex)
        {
            Toast.makeText(this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
            ex.printStackTrace();
        } catch (Exception e)
        {
            e.printStackTrace();
        }
    }

当用户点击一个按钮,所以这种方法被称为放大器;它显示了可用的选项列表,用于发送MMS用户将不得不选择邮件选项执行此action.So。
 虽然这个工作正常为Android 2.3版本,但是当我运行4.0.3版的应用程序,然后在可用选项列表中不显示信息option.Which是必须用于发送彩信。

When users click on a button, so this method is called & it shows a list of available options to perform this action.So for sending MMS user will have to select "Messaging" option. Although this works fine for Android version 2.3 but when I run the app on version 4.0.3 then in the list of available options it does not show "Messaging" option.Which is must for sending MMS.

而当我删除线

intentEmail.setType("image/jpeg");
intentEmail.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file.getAbsolutePath()));

然后列表显示中的邮件选项,但我无法将其删除。

then the list shows the "Messaging" option but I can not remove it.

我真的没有得到什么是它的问题,或者我可能将不得不增加更多的东西了4.0.3版本。

I am really not getting what is the problem with it or may I will have to add something more for version 4.0.3 .

请帮忙。

推荐答案

好吧,我解决了这个问题。

Ok I solved the issue.

我的新code是

void sendMMS()
    {
        try
        {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            Drawable drawable = imageProduct.getDrawable();
            Bitmap bitmapPicked = ((BitmapDrawable) drawable).getBitmap();
            bitmapPicked.compress(CompressFormat.JPEG, 75, bos);
            byte[] image = bos.toByteArray();
            File file = new File(Environment.getExternalStorageDirectory() + File.separator + "test.jpg");
            file.createNewFile();
            // write the bytes in file
            FileOutputStream fo = new FileOutputStream(file);
            fo.write(image);

            Log.i(TAG, "image = " + image);

            Intent intentMMS = new Intent(Intent.ACTION_SEND);
            intentMMS.setType("image/jpg");
            intentMMS.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
            intentMMS.putExtra("sms_body", messageFacebook);
            intentMMS.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
            startActivity(intentMMS);
        } catch (android.content.ActivityNotFoundException ex)
        {
            Toast.makeText(this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
            ex.printStackTrace();
        } catch (Exception e)
        {
            e.printStackTrace();
        }
    }

这篇关于问题在Android版本4.0.3彩信发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆