无法将gif图像发送给Messanger

时间:2017-08-21 09:13:36

标签: android image android-intent gif mms

我想将存储在drawable中的gif图像发送给messenger。我尝试下面的代码显示文件没有附加方法。请任何人帮我解决这个问题。

          int[] imageId = {
         R.drawable.congrats,
         R.drawable.dog,
        R.drawable.giphy,
        R.drawable.good_night,
        R.drawable.pokeman,
        R.drawable.redrose,
        R.drawable.wibd
};

  Uri path = Uri.parse("android.resource://" + 
   ImageKeyboard.this.getPackageName() + "/" + imageId[position]);


 String defaultSmsPackageName = Telephony.Sms.getDefaultSmsPackage(ImageKeyboard.this); //Need to change the build to API 19
                   Intent intent = new Intent(Intent.ACTION_SEND,Uri.parse("mms://"));

                intent.setPackage(defaultSmsPackageName);
                   intent.putExtra("sms_body", "Hi how are you");
                   intent.putExtra(Intent.EXTRA_STREAM, path);
                   intent.setType("image/gif");
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
               startActivity(intent);

0 个答案:

没有答案