老版本2个activity之间传递反回数据,实例如:https://www.cnblogs.com/xiaobaibailongma/p/16440432.html
新版本如下:https://blog.youkuaiyun.com/freezingxu/article/details/124953918?spm=1001.2101.3001.6650.2&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-2-124953918-blog-133701756.235%5Ev40%5Epc_relevant_3m_sort_dl_base3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-2-124953918-blog-133701756.235%5Ev40%5Epc_relevant_3m_sort_dl_base3&utm_relevant_index=3
在需要调用系统Intent之前,我们需要定义所需的Launcher:
1、protected ActivityResultLauncher activityResultLauncher;
2、protected ActivityResultLauncher takePhotoLauncher;
3、protected ActivityResultLauncher selectImageLauncher;
4、protected ActivityResultLauncher selectFileLauncher;
此处我定义了4个不同的Launcher,分别用来处理普通的Intent跳转、拍照、选择相册中已有的图片和选择手机中的文件。
activityResultLauncher:处理普通的Intent跳转,并携带参数往返;
takePhotoLauncher:打开照相机进行拍照,并获得照片;
selectImageLauncher:打开系统Intent选择手机上的图片;
selectFileLauncher:打开系统Intent选择手机里的文件。
原文链接:https://blog.youkuaiyun.com/freezingxu/article/details/124953918

=============================================================================
第一个布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"

最低0.47元/天 解锁文章
1821

被折叠的 条评论
为什么被折叠?



