Android 将gif图像发送到消息传递应用程序

Android 将gif图像发送到消息传递应用程序,android,gif,mms,Android,Gif,Mms,我想用彩信图像发送gif。我写了代码,它在安卓6版本上运行,但在下面它不工作,消息应用程序崩溃了 这是我的密码 mGifFile = getFileForResource(ImageKeyboard.this, imageId[position], imagesDir, "image_new.gif" ); Uri newFile = FileProvider.getUriForFile(ImageKeyboard.this, AUTHORITY, mGifFile);

我想用彩信图像发送gif。我写了代码,它在安卓6版本上运行,但在下面它不工作,消息应用程序崩溃了

这是我的密码

     mGifFile = getFileForResource(ImageKeyboard.this, imageId[position], imagesDir, "image_new.gif" );
     Uri newFile =   FileProvider.getUriForFile(ImageKeyboard.this, AUTHORITY, mGifFile);


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

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

请帮助我解决此问题

您可以在API中获取默认sms软件包名称您检查了日志了吗?你能提供一下吗?崩溃日志中的崩溃错误是什么?我没有得到任何日志。它显示消息不幸消息已停止。@H.BrooksOn您的控制台(在您正在使用的程序中)不在您的设备上。。
public static final String getDefaultSmsPackage(Context context){
    String defApp = Settings.Secure.getString(context.getContentResolver(), "sms_default_application");
    PackageManager pm = context.getApplicationContext().getPackageManager();
    Intent iIntent = pm.getLaunchIntentForPackage(defApp);
    ResolveInfo mInfo = pm.resolveActivity(iIntent,0);
    return mInfo.activityInfo.packageName; 
}
Telephony.Sms.getDefaultSmsPackage(...)