Android 13(API 33)读写SD卡权限的调整适配
Android 13(API 33)读写SD卡权限的调整适配在Android13前读取SDcard 的内容只需要一个权限:
1android.permission.READ_EXTERNAL_STORAGE
但是在Android 13以后这个权限被细化成了三个:
123public static final String READ_MEDIA_AUDIO = "android.permission.READ_MEDIA_AUDIO";public static final String READ_MEDIA_IMAGES = "android.permission.READ_MEDIA_IMAGES";public static final String READ_MEDIA_VIDEO = "android.permission.READ_MEDIA_VIDEO";
如果是升级Android13之前就已经具有读写SDK的权限,那么升级到13之后,自己具有上述三个权限。
如果是升级Android13之后新装的应用,并且targ ...
context.getContentResolver().query()详细用法详解
这里不再多写,直接引用就好了,写的挺详尽的
引用自csdn qqq3670279
Android MediaPlayer
这是MediaPlayer的关键生命周期,这张图是关键,他可以帮你很好的理解如何使用MediaPlayer![](https://image.zfxt.top/hexo-blog/Android MediaPlayer-2023-12-23-24-02.png)
MediaPlayer的常用方法
| Public Methods || — | — || static MediaPlayer | create(Context context, Uri uri, SurfaceHolder holder)指定从资源ID对应的资源文件中来装载音乐文件,同时指定了SurfaceHolder对象并返回MediaPlyaer对象。 || static MediaPlayer | create(Context context, int resid)指定从资源ID对应的资源文件中来装载音乐文件,并返回新创建的MediaPlyaer对象。 || static MediaPlayer | create(Context context, Uri uri)从指定Uri装在音频文件,并返回新创建的MediaPl ...
Android 中 Bitmap 和 Drawable 相互转换的方法
drawable转为bitmap其中的appcontext可以是activity的context属性也可以是全局的appContext1val music_default_art = BitmapFactory.decodeResource(appContext.resources,R.drawable.music_default)
bitmap转为drawable1val drawable = BitmapDrawable(bmp)
Android音乐专辑图片获取
获取android音乐部分可用信息12345678910111213141516171819202122232425262728val cursor = appContext.contentResolver.query( MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, arrayOf( MediaStore.Audio.Media._ID, MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.DATA, MediaStore.Audio.Media.ALBUM_ID, MediaStore.Audio.Media.DURATION ), MediaStore.Audio.Media.DURATION+ ">'1000'", null, null ...
Compose 设置沉浸状态栏(不导入库一行代码解决)
旧(最初的版本,修改style.xml的文件来得到)在style.xml中修改代码如下即可
12345<style name="AppFullTheme" parent="AppTheme"> <item name="android:windowTranslucentNavigation">true</item> <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item> <item name="android:windowFullscreen">true</item> </style>
新在使用compose时,首先找到Theme.kt找到这段代码
1(view.context as Activity).window.statusBarColor = colorSch ...
安卓插件异常
问题:Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id ‘com.android.application’]解决办法:在gradle.properties添加android.overridePathCheck=true即可
出现原因:一般为挪动了文件夹的位置
jetpack compose 修改app字体
如果你使用的是xml来写UI的话,可以查看这个文章,里面有很详尽的关于app修改字体的方法。
这里主要说明的是使用jetpack compose进行开发时,你修改字体需要设置你的type.kt![](https://image.zfxt.top/hexo-blog/jetpack compose 修改app字体-2023-12-05-06-45.png)在其中将默认字体改为你自己定义的字体![](https://image.zfxt.top/hexo-blog/jetpack compose 修改app字体-2023-12-18-31-55.png)![](https://image.zfxt.top/hexo-blog/jetpack compose 修改app字体-2023-12-05-00-34.png)然后即可完成字体的修改
SpringCloud(13)
Seata处理分布式事务问题:(有多个库,如何保持一致,在物理上有多个数据库,但逻辑上保持一个数据库)单体应用被拆分成微服务应用,原来的三个模块被拆分成三个独立的应用,分别使用三个独立的数据源。业务操作需要调用三个服务来完成。此时每个服务内部的数据一致性由本地事务来保证,但是全局的数据一致性问题没法保证。
官网地址:https://seata.io/zh-cn/
Seata组成
全局唯一的事务ID
三组件TC,TM,RMTC事务协调者维护全局和分支事务的状态,驱动全局事务提交或回滚。TM事务管理器定义全局事务的范围:开始全局事务、提交或回滚全局事务。RM资源管理器管理分支事务处理的资源,与TC交谈以注册分支事务和报告分支事务的状态,并驱动分支事务提交或回滚。
处理过程
TM向TC申请开启一个全局事务,全局事务创建成功并性成一个全局唯一的ID;
XD在微服务调用链路的上下文中传播:
RM向TC注册分支事务,将其纳入ID对应全局事务的管辖;
TM向TC发起针对ID的全局提交或回滚决议;
TC调度XD下管辖的全部分支事务完成提交或回滚请求。
下载配置(只限于0.9版本以前)下载完成后,先 ...
SpringCloud(12)
Sentinel 分布式系统的流量防卫兵
下载安装https://github.com/alibaba/Sentinel/releases/tag/1.8.6启动后默认端口为8080
构建微服务:POM:123456789101112131415161718192021222324252627282930313233343536<dependencies> <!-- Springcloud ailibaba nacos --> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> </dependency> <!--Springcloud ailibaba sentinel-datasour ...