wildfirechat / android-chat

即时通讯,聊天,野火IMAndroid客户端,支持Android 4.x —— 最新
http://docs.wildfirechat.cn
Other
2.54k stars 889 forks source link

api高于30时,使用外部程序打开文件可能出错 #721

Closed RadiumCao closed 1 year ago

RadiumCao commented 1 year ago

https://github.com/wildfirechat/android-chat/blob/4c610f533452e9ed0f406417a155592801167a35/uikit/src/main/java/cn/wildfire/chat/kit/conversation/message/viewholder/FileMessageContentViewHolder.java#L69-L74

在api30及以上版本运行时,可能ComponentName始终返回null,可以考虑修改为: Intent intent = FileUtils.getViewIntent(fragment.getContext(), file); try { fragment.startActivity(intent); }catch (Exception e){ Toast.makeText(fragment.getContext(), "找不到能打开此文件的应用", Toast.LENGTH_SHORT).show(); }

See: https://stackoverflow.com/questions/72183885/intent-resolveactivity-returns-null-on-android-intent-action-open-document-in-ap

also https://developer.android.com/training/package-visibility