Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中将图片转换为文本并将其作为短信发送_Android - Fatal编程技术网

如何在android中将图片转换为文本并将其作为短信发送

如何在android中将图片转换为文本并将其作为短信发送,android,Android,我开发了一个android应用程序,用户可以使用SmsManager Api向任何号码发送消息 SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage("phoneNo", null, "sms message", null, null); 现在我想用户将发送小图片到任何数字使用 smsManager.sendTextMessage("phoneNo", null, picture, null, n

我开发了一个android应用程序,用户可以使用SmsManager Api向任何号码发送消息

SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("phoneNo", null, "sms message", null, null);
现在我想用户将发送小图片到任何数字使用

smsManager.sendTextMessage("phoneNo", null, picture, null, null);
我不想通过彩信发送此图片。我知道这可以通过在发送端将图片转换为字符串并在接收端将字符串重新转换为图片来实现。但我不知道该怎么做。下面是完成此任务的android应用程序的快照。我想使用下面的代码按所示执行此操作

/** *将图像编码为Base64。 */

    private String encodeImage(String photoPath) {

        File imagefile = new File(photoPath);
        FileInputStream fis = null;
        try {
            fis = new FileInputStream(imagefile);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        Bitmap bm = BitmapFactory.decodeStream(fis);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        bm.compress(Bitmap.CompressFormat.JPEG, 80, baos);
        byte[] b = baos.toByteArray();
        return Base64.encodeToString(b, Base64.DEFAULT);

这是不可能的。因为如果将图像转换为base64,则字符数不超过300(最小图像为50x50),因此它将成为MMS。

我想转换30x30的小图像