自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Pzxxc

QQ:962935348

  • 博客(72)
  • 资源 (1)
  • 问答 (5)
  • 收藏
  • 关注

原创 【Kotlin】let,also,run,apply与with的使用与区别

以弹出桌面程序选择框为例共同特性var intent = Intent(Intent.ACTION_MAIN)//我们将前置代码的返回值称为T,花括号及内容称为blockintent.let {//block: (T) -> R//Calls the specified function [block] with ‘this’ value as its argument and returns its result.//用’this’值作为 参数 调用指定的函数[block],并返回结果

2021-03-06 09:39:33 2881 4

原创 【快速使用】解决USB权限弹窗——无障碍

一、简介别人的设备与系统,自己无能力修改源码,只能寻求其他手段,在网上看到有人说道“无障碍”,便开始试一试,发现是可行的,比adb好用多了;二、使用新建类 MyAccessibilityServicepublic class MyAccessibilityService extends AccessibilityService { String TAG = "AliAccessibilityService"; /** * event: EventType: TYP

2020-08-03 09:02:16 2286 9

原创 AndroidStudio个人常用ADB与快捷键

netcfg 查看网络端口adb shell am start com.android.settings 进入设置界面com.android.settings.DevelopmentSettings 开发者设置com.android.settings.DeviceInfoSettings 关于手机com.android.settings.RadioInfo 手机信息com.an...

2019-05-30 14:04:34 1658

原创 【代码块】Android APP自动安装并重启

自动安装apk 或 静默安装

2022-03-01 11:02:43 1735

原创 Kotlin多维数组使用copyOf()的注意事项

多维数组直接使用copyOf() 会导致内元素地址覆盖,也就是改变其中一项数据会导致另一数据内数据也发生变化,即 === 判定为true

2021-06-03 16:08:03 742

原创 【简单封装】OkHttp(包含cookie)

PzOkHttp类public class PzOkHttp { private static final String TAG = "PzOkHttp"; private OkHttpClient client; public PzOkHttp() { client = new OkHttpClient.Builder() .connectTimeout(15, TimeUnit.SECONDS)//设置连接超时时间

2021-03-16 11:38:47 268

原创 【简单封装】Android实现USB转232通讯

封装类:PzHelpUSBclass PzHelpUSB implements SerialInputOutputManager.Listener { private static final String TAG = "PzHelpUSB"; Context context; UsbSerialPort usbSerialPort = null; SerialInputOutputManager usbIoMana

2021-03-10 16:47:56 1075 6

原创 【代码块】OkHttp下载文件

/** * 下载文件 * * @param url 文件网络路径 * @param filePath 文件下载本地路径 * @param fileName 文件名称(包含后缀) * @param callBack 回调 */public void okHttpDownloadFile(String url, String filePath, String fileName, final CallBackDownloadFile callBack) { final File

2021-02-24 11:56:48 696

原创 【代码块】字符串转时间戳

/** * 字符串转时间戳 * * @param dateString 待转字符串 * @param pattern 时间字符串格式 * @return 时间戳 */@SuppressLint("SimpleDateFormat")long stringToTimestamp(String dateString, String pattern) { SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);

2021-01-08 10:25:34 116

原创 【时间与记忆】二万访问量达成!

距离1万达成已经过去了6个月了,这6个月应该算是我初步正轨的过程,写的文章基本也都是些工作中遇到的东西。访问量最多的文章依旧是关于SIM800CLBS功能的转载更新文章,着实有点感叹。百度搜了一下SIM800c+LBS,居然是第一条,怪不得,文章较早也就搜索比重较大吧,要想自己后面写的文章访问量超过这篇,着实还挺难的。周排名也是进了3w+,总排名进了13w+,排名算法也是看了一下,要想叠积分,疯狂水文章数就是一个非常有用的方案,但依旧还是要不忘初心,文章主要是写给自己的,其次是帮助别人,最后才是为了名.

2021-01-05 10:57:56 151

原创 【代码块】跳至网络设置界面(WIFI与LAN)

跳转网络设置界面(包含wifi与lan)/*** 显示网络设置界面*/private void showNetworkActivity() { ComponentName componentName = new ComponentName("com.android.tv.settings", "com.android.tv.settings.connectivity.NetworkActivity"); Intent intent = new Intent(); intent.se

2020-11-23 11:28:27 477

原创 【代码块】固定长度的串口byte数据解析参考(modbus等)

@RequiresApi(api = Build.VERSION_CODES.N)@Overridepublic void onNewData(byte[] data) { /** * 例如:01 03 12 34 00 01 C0 BC * 01 03为固定数据 * 12 34为编号 * 00 01为数据,最大值FF FF(十进制65535) * C0 BC为CRC校验码,低位在前 */ //将收到的数据添加到缓冲区

2020-11-19 10:07:28 461

原创 【代码块】带标签的字符串数据解析参考

/** * 数据检查 * * @param response 数据源 * @param checkStar 数据头标签 * @param checkEnd 数据尾标签 * @return 数据 */String responseChecker(String response, String checkStar, String checkEnd) { int star = response.indexOf(checkStar); int end = response.ind

2020-11-05 17:28:44 204

原创 TextView文字对齐(不同空白间隔的效果)

typeface="monospace"模式下:1个中文 = 1个 3个中文 = 5个  ,另外  =   =   =  非typeface="monospace"模式下:1个中文 = 2个  = 4个  = 4个  = 5个 ...

2020-10-17 16:00:16 390

原创 【简释】RecyclerView——OnScrollListener

mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { /** * 滚动时回调 * @param recyclerView RecyclerView * @param newState 状态 * 0:SCROLL_STATE_IDLE: 结束,不处于滚动状态(The RecyclerV

2020-10-10 17:20:20 775 1

原创 【开发问题】Android——Fragment must be a public static class to be properly recreated from instanc

译文:Fragment 必须是公共静态类才能从实例状态正确地重新创建解决:public class SettingDialogFragment extends DialogFragment:添加 public 即可

2020-09-25 13:45:35 680

原创 【开发问题】Android——Adapter:IndexOutOfBoundsException: Inconsistency detected

数据源增删后应当随机刷新Adapter报错信息:IndexOutOfBoundsException: Inconsistency detected.原因和解决办法:在对绑定数据源,比如List进行增删操作后,应当随机进行一次刷新。尤其是删除或清空操作,否则会导致底层报错,程序崩溃。...

2020-09-15 16:03:41 371

原创 【简释】ViewPager——OnPageChangeListener

ViewPager.SimpleOnPageChangeListener mPageChangeListener = new ViewPager.SimpleOnPageChangeListener() { /** * 当页面滚动时触发 * @param position 切换过程中左侧页面的position * @param positionOffset 切换过程中左侧页面消失部分的比例 * @param positionOffsetPixels 切换过程中

2020-09-01 16:32:49 510

原创 【开发问题】HorizontalBarChart渐变色无效的问题

PS:渐变无效其实是BUG,直到2020年1月24号才解决,而目前的3.1.0版本是在19年打包的,所以需要手动下载源码并导入项目,导入module我就不阐述了源码地址:https://github.com/PhilJay/MPAndroidChart使用Fill:import com.github.mikephil.charting.utils.Fill;... ...List<Fill> mGradientColors = new ArrayList<>();...

2020-08-08 13:47:13 293

原创 【简单封装】Android——TCP服务端

使用tcp_server = new PZHelp_TCP_Server();tcp_server.creat(8000, new PZHelp_TCP_Server.ReceiveListener() { @Override public void Receive(String response) { Log.d(TAG, "Receive: " + respons...

2020-07-27 10:15:51 807

原创 Android刷新UI导致崩溃的探究——Only the original thread

结论:Only the original thread that created a view hierarchy can touch its views不能粗暴的理解为由于刷新UI导致的,而是由于刷新修改View大小导致的,如果你的View设定了固定的长宽是不会出现这个错误的。当大小设置为wrap_content后,每次setText都会重新计算View的长宽并刷新,这会导致执行requestLayout方法,而这个方法需要执行checkThread方法,导致报错也就是在长宽设定为非wrap_con

2020-07-25 13:33:21 624

原创 Android设置主屏幕应用(桌面程序)

在 AndroidManifest.xml 内 activity 的 intent-filter 标签内添加<category android:name="android.intent.category.HOME"/><category android:name="android.intent.category.DEFAULT" />

2020-07-24 09:22:13 12084

原创 TextView——行间距与字母间隔

一、设置行间距android:lineSpacingExtra设置行间距,尺寸值是一个浮点数,后跟一个单位,例如“ 14.5sp”Extra spacing between lines of text. Must be a dimension value, which is a floating point number appended with a unit such as “14.5sp”.Available units are: px (pixels), dp (density-inde

2020-07-22 13:34:19 288

原创 【自定义View】自动滚动的TextView(跑马灯)——可获取完成一次滚动后的监听

AutoRollTextViewByRunnable类class AutoRollTextViewByRunnable extends androidx.appcompat.widget.AppCompatTextView implements Runnable { String TAG = "MarqueeText"; private int currentScrollX = 0;// 当前滚动的位置 private int textWidth; private int

2020-07-18 01:24:07 767

原创 Android Studio使用Lambda

jdk 8或更高版本在build.gradle内添加即可android { compileOptions{ sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }

2020-07-13 16:29:51 171

原创 RecyclerView内布局使用weight无效的解决方案

问题:如果使用的是LinearLayout,并内部使用了weight属性,会导致RecyclerView最终效果与weight不一致。解决:在LinearLayout外部套一层其他布局即可

2020-07-07 09:57:57 1140

原创 【自定义控件】EditText实现自动焦点(输入法的自动显示与隐藏)

效果EdiText默认不获取焦点,点击后进入输入模式,输入法弹出,获取焦点。当输入完成后,输入法隐藏,EditText自动清除焦点。实现1、先解决EditText自动获取焦点的问题,在父布局内添加 android:focusable="true" android:focusableInTouchMode="true"2、编写自定义EditTextpublic class EditText_AutoFocus extends androidx.appcompat.widget.AppCo

2020-06-10 11:16:02 512

原创 【自定义控件】RecyclerView实现自动滚动效果

MyRecyclerViewpublic class MyRecyclerView extends RecyclerView { Handler mHandler = new Handler(); public MyRecyclerView(@NonNull Context context) { super(context); } public MyRecyclerView(@NonNull Context context, @Nullable Att

2020-05-30 09:08:50 787

原创 RecyclerView跳转指定Position后将其置顶

MyLinearSmoothScrollerpublic class MyLinearSmoothScroller extends LinearSmoothScroller { public MyLinearSmoothScroller(Context context) { super(context); } @Override protected int getHorizontalSnapPreference() { return SNA

2020-05-30 09:01:41 208

原创 SimpleDateFormat日期格式转换及时间戳转换

String 转 DateString string= "2020-5-27 13:57:45";SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") ;Date date = simpleDateFormat.parse(string);Date 转 StringDate date = new Date();SimpleDateFormat simpleDateFormat = new

2020-05-27 14:55:24 3659

原创 【快速使用】RecyclerView(LinearLayoutManager)

1、添加依赖implementation ‘androidx.recyclerview:recyclerview:1.2.0-alpha03’2、构建Item布局略3、构建ItemBeanpublic class ItemBean_List { private String id = ""; private String productModel = ""; ItemBean_List(String id, String productMode

2020-05-23 16:43:57 1738

原创 【简单封装】Android——TCP客户端

使用tcp_client = new PZHelp_TCP_Client();tcp_client.creat("192.168.0.41", 9000, new PZHelp_TCP_Client.ReceiveListener() { @Override public void connect() { Log.d("PZHelp_TCP_Client", "...

2020-05-14 09:50:45 305

原创 Android——RecyclerView宽高自适应填充

基础知识GridLayoutManager 继承于 LinearLayoutManager,是 RecyclerView 的布局管理器,主要为了实现宫格布局。GridLayoutManager.setOrientation(GridLayoutManager.VERTICAL) 或 HORIZONTAL 可以设置 RecyclerView 的延展方向,VERTICAL 便是指纵方向延展。n...

2020-04-28 14:46:37 4229

原创 自适应文字大小的TextView

Android8.0以上可以在TextView中添加autoSizeTextType实现Android8.0以下要想达到根据TextView大小自动调整文字大小(不适合使用多行文字),只能自定义了public class PZHelp_TextView_AutoTextSize extends androidx.appcompat.widget.AppCompatTextView { ...

2020-04-16 11:46:18 287

原创 【简单封装】UDP服务端

PZHelp_UDPServerpublic class PZHelp_UDPServer extends Thread { private static final String TAG = "PZHelp_UDPServer"; private DatagramSocket socket; private DatagramPacket packet; pri...

2020-04-11 12:06:07 231

原创 【代码块】Android代码执行ADB指令

【代码块】Android-kotlin执行ADB指令。

2020-04-10 11:30:00 4538

原创 【时间与记忆】一万访问量达成!

终于断断续续写了3年博客,终于到了1万访问量,虽然一篇内容核心是转载的SIM800C的文章贡献了3000+的访问,但也算是我亲自实际操作的过的,也贴了转载,系统算进来,我也没办法。也是19年干工作了才开始稳定更新博客,主要写博客还是为了自己,所以也没怎么写一些面向基础知识学习的文章,当然这也是我自己的初衷,写博客不能为了让别人看而去写,更多的应该是一个积累经验和备份知识的地方,在此基础上优化一...

2020-04-01 09:28:26 197

原创 【代码块】沉浸式界面

顶部状态栏与底部导航栏不会占据显示控件,并在界面获取焦点后隐藏/** * 沉浸式页面 * * @param hasFocus 焦点 */@Overridepublic void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); if (hasFocus &amp...

2020-03-28 14:39:05 224

原创 【开发问题】usb-serial-for-android

程序重启后无法再次读取USB设备插入USB设备,程序运行,一切正常。关闭程序再次打开,设备与端口皆可获取,直到Port.open(connection)出错使用的是RK3188 5.1系统传感器为体温传感器,使用此开源CH34转USB/MainActivity: connection: android.hardware.usb.UsbDeviceConnection@3b3b49f1...

2020-03-14 16:06:48 1840 2

原创 Android——USB转COM口(CH340)与传感器进行通讯

本人使用环境CH340转接头Android5.1,RK3188Android6.0,RK3288关于官方的jar包与使用存在的问题(官方地址)最大的问题是无法修改串口波特率,一直以19200运行,但我的传感器为9600初始化使用GitHub:https://github.com/mik3y/usb-serial-for-android在你的build.gradle(pro...

2020-03-12 10:18:28 2061 1

USB转CH34整合包

含有USB转CH34的示例APK、DEMO和驱动等文件,整合了官方文件,试验的结果是似乎无法修改波特率!默认是115200。

2020-05-06

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除