Android——发送彩信

跳转到相册选择图片

java 复制代码
        btn_jump.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // 跳转到系统相册选择图片并返回
                Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
                // 设置图片类型为图片类型
                intent.setType("image/*");
                // 打开系统相册,并等待图片选择结果
                mResultLauncher.launch(intent);
            }
        });

发送带图片的彩信

java 复制代码
    private void sendMms(String phone, String title, String message) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        // 因为这次跳转带了Uri,Intent的接收者将被准许读取Intent携带的URI数据
        intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
        // 彩信发送的目标号码
        intent.putExtra("address", phone);
        // 彩信的标题
        intent.putExtra("subject", title);
        // 彩信的内容
        intent.putExtra("sms_body", message);
        // 彩信的图片附件
        intent.putExtra(Intent.EXTRA_STREAM, picUri);
        // 彩信的附件为图片
        intent.setType("image/*");
        // 因为未指定要打开哪个页面,所以系统底部会弹出选择窗口
        startActivity(intent);
    }
相关推荐
Whisper_Sy16 小时前
Flutter for OpenHarmony移动数据使用监管助手App实战 - 应用列表实现
android·开发语言·javascript·flutter·php
北海屿鹿18 小时前
【MySQL】内置函数
android·数据库·mysql
臻一18 小时前
rk3576+安卓14 ---上电时序调整
android
踢球的打工仔19 小时前
typescript-接口的基本使用(一)
android·javascript·typescript
2501_9159184120 小时前
如何在iPad上找到并打开文件夹的完整指南
android·ios·小程序·uni-app·iphone·webview·ipad
臻一1 天前
rk3576+安卓14---uboot
android
2501_944521591 天前
Flutter for OpenHarmony 微动漫App实战:主题配置实现
android·开发语言·前端·javascript·flutter·ecmascript
2501_944521591 天前
Flutter for OpenHarmony 微动漫App实战:动漫卡片组件实现
android·开发语言·javascript·flutter·ecmascript
知1而N1 天前
电脑上运行APK文件(Android应用程序包),需要借助特定的软件或功能,因为Windows/macOS/Linux系统无法原生直接运行安卓应用
android·macos·电脑
代码s贝多芬的音符1 天前
HttpURLConnection post多个参数和一个图片
android·httpurlconn