当前位置:网站首页>视频直播系统源码,保存平台视频内容到本地
视频直播系统源码,保存平台视频内容到本地
2022-07-22 18:13:00 【云豹网络科技】
视频直播系统源码,保存平台视频内容到本地
首先,动态获取权限,非常重要
//在进入主页面时动态获取(记得在清单文件中添加)
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(new String[]{
"android.permission.CAMERA",
"android.permission.READ_EXTERNAL_STORAGE",
"android.permission.WRITE_EXTERNAL_STORAGE"},101);
}
话不多说,直接上代码
//在自己手机本地选择一个路径用于存储
private String path = "/sdcard/下载/Photo/";
@OnClick(R.id.fra_person_iv_photo)
public void onViewClicked() {
//点击打开相机
Intent intent = new Intent();
intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
//设置输出路径
path = path+getNowTime()+".jpg";
Uri uri = FileProvider.getUriForFile(getActivity(), "com.example.android_mvp_dagger", new File(path));
intent.putExtra(MediaStore.EXTRA_OUTPUT,uri);
startActivityForResult(intent,102);
}
//提供一个方法获取当前时间
private String getNowTime() {
Date date = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd-HH:mm:ss");
return simpleDateFormat.format(date);
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
//判断是否调用成功
if(requestCode == 102 && resultCode == Activity.RESULT_OK) {
//这里使用Glide进行加载图片
GlideUtils.getInstance().CommonGlide(getActivity(),String.valueOf(path),fraPersonIvPhoto);
}
}
完成这些还是不够的,还需要在清单文件中再配置一下
<application
android:name=".MyApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
tools:ignore="GoogleAppIndexingWarning">
<meta-data android:name="design_width" android:value="1080" />
<meta-data android:name="design_height" android:value="1920" />android:name=".mvp.view.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
//这是一个权限,一定记得添加
android:grantUriPermissions="true"
//这是你项目的包路径
android:authorities="com.example.android_mvp_dagger"
//导入FileProvider的包路径
android:name="androidx.core.content.FileProvider">
//进入上面这条语句,可以获取到我们所需的下面这句话
<meta-data android:name="android.support.FILE_PROVIDER_PATHS"
//这是一个xml文件,里面配置了我们的根路径
android:resource="@xml/path" />
</provider>
</application>
这是上面所需的XML文件
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path
name="mypath"
//这个一定要是SD后的那部分,不可写上SD卡
path="下载/Photo/" />
</paths>
以上就是视频直播系统源码,保存平台视频内容到本地, 更多内容欢迎关注之后的文章
边栏推荐
- 51单片机的入门知识(献给初学者最易懂的文章)更新篇
- NLP学习路线图(思维导图),非常的全面和清晰!
- NLP language model
- MNIST数据集
- 暑期提前学大学物理C知识记录【更新】
- Unix programming project - the client based on raspberry pie regularly obtains the temperature and reports it to the server
- codeforce:D2. Remove the Substring (hard version)【贪心的字符串 + 子序列】
- 最简单的scull设备驱动
- 初学者备战蓝桥杯历程(大学编程学习历程记录,题目思路献给需要备考蓝桥杯的同学)
- 开放原子开源基金会副秘书长刘京娟:中国开源发展现状及趋势思考
猜你喜欢
随机推荐
视频直播源码,重置当前密码的相关改动
【NumPy】
30出头成为复旦博导,陈思明:敲代码和写诗,我两样都要
Transformer
视频知识点(17)- flv.js 实现播放本地视频文件的技巧
Understanding the application steps of machine learning development
中国科学院院士王怀民:推进中国开源创新联合体的思考与实践
堆基础练习题 —— 1
中国电子信息产业发展研究院院长张立:打造我国主导的开源价值链
初学者备战蓝桥杯历程(大学编程学习历程记录,题目思路献给需要备考蓝桥杯的同学)
Implementing IO multiplexing in UNIX using poll function to realize network socket server
机器学习理论基础
LC:剑指 Offer 10- I. 斐波那契数列
更新C语言笔记
7. 求100~300间能被3整除的数的和。
利用“HiFolw”快捷制作高校学生返校名单信息生成
Input a string of characters from the keyboard, output different characters and the number of times each character appears. (the output is not in order) use the common methods of string class to solve
Remember a way to connect raspberry pie wirelessly without a display screen and can't find IP
Encoder decoder (seq2seq)
2019_AAAI_ICCN





![[强网杯 2019]随便注](/img/a4/4c7f647f2dc8e535699e8e5fa25685.png)



