-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatom.xml
528 lines (281 loc) · 102 KB
/
atom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>RH</title>
<link href="/atom.xml" rel="self"/>
<link href="http://example.com/"/>
<updated>2021-05-14T05:55:38.978Z</updated>
<id>http://example.com/</id>
<author>
<name>RH</name>
</author>
<generator uri="http://hexo.io/">Hexo</generator>
<entry>
<title>Arcgis定位及图标更换</title>
<link href="http://example.com/2021/05/14/Arcgis%E5%AE%9A%E4%BD%8D%E5%8F%8A%E5%9B%BE%E6%A0%87%E6%9B%B4%E6%8D%A2/"/>
<id>http://example.com/2021/05/14/Arcgis定位及图标更换/</id>
<published>2021-05-14T08:10:00.000Z</published>
<updated>2021-05-14T05:55:38.978Z</updated>
<content type="html"><![CDATA[<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">private</span> PictureMarkerSymbol symbol;</span><br><span class="line"></span><br><span class="line"> <span class="comment">//定位当前位置</span></span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">startLocation</span><span class="params">()</span> </span>{</span><br><span class="line"> <span class="keyword">if</span> (mMapView == <span class="keyword">null</span>) {</span><br><span class="line"> <span class="keyword">return</span>;</span><br><span class="line"> }</span><br><span class="line"> mLocationDisplay = mMapView.getLocationDisplay();</span><br><span class="line"> <span class="comment">//mLocationDisplay.setShowLocation(true);</span></span><br><span class="line"> <span class="comment">//mLocationDisplay.setShowPingAnimation(true);</span></span><br><span class="line"> <span class="comment">//步行导航</span></span><br><span class="line"> mLocationDisplay.setAutoPanMode(LocationDisplay.AutoPanMode.COMPASS_NAVIGATION);</span><br><span class="line"></span><br><span class="line"> MyLocationDataSource dataSource = MyLocationDataSource.getInstance();</span><br><span class="line"> <span class="comment">//MyLocationDataSource.getInstance().UpdateLocation(new LocationDataSource.Location(new Point(SouthLocation.GetInstance().getLongitude(), SouthLocation.GetInstance().getLatitude(), SpatialReferences.getWgs84())));</span></span><br><span class="line"> mLocationDisplay.setLocationDataSource(dataSource);</span><br><span class="line"></span><br><span class="line"> <span class="comment">//显示自定义的定位符号</span></span><br><span class="line"> Drawable drawable = context.getResources().getDrawable(R.mipmap.direction);</span><br><span class="line"> symbol = <span class="keyword">new</span> PictureMarkerSymbol((BitmapDrawable) drawable);</span><br><span class="line"> symbol.loadAsync();</span><br><span class="line"> symbol.addDoneLoadingListener(<span class="keyword">new</span> Runnable() {</span><br><span class="line"> <span class="meta">@Override</span></span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">run</span><span class="params">()</span> </span>{</span><br><span class="line"> mLocationDisplay.setDefaultSymbol(symbol);</span><br><span class="line"> <span class="comment">//mLocationDisplay.setShowAccuracy(false);//隐藏符号的缓存区域</span></span><br><span class="line"> mLocationDisplay.setHeadingSymbol(symbol);<span class="comment">//设置当前位置设备面对方向的符号</span></span><br><span class="line"> }</span><br><span class="line"> });</span><br><span class="line"></span><br><span class="line"> <span class="comment">//当我们执行LocationDisplay.startAsync()方法时候,会在地图上显示出我们当前位置</span></span><br><span class="line"> dataSource.startAsync();</span><br><span class="line"> mLocationDisplay.startAsync();</span><br><span class="line"></span><br><span class="line"> <span class="comment">//如果要在LocationDisplay里进行位置信息的自动监听,方法也很简单,只需要LocationDisplay.addLocationChangedListener即可</span></span><br><span class="line"> mLocationDisplay.addLocationChangedListener(<span class="keyword">new</span> LocationDisplay.LocationChangedListener() {</span><br><span class="line"> <span class="meta">@Override</span></span><br><span class="line"> <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onLocationChanged</span><span class="params">(LocationDisplay.LocationChangedEvent locationChangedEvent)</span> </span>{</span><br><span class="line"> location = locationChangedEvent.getLocation();</span><br><span class="line"> scaleView.refreshScaleView();</span><br><span class="line"> }</span><br><span class="line"> });</span><br><span class="line"></span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"><span class="comment">//获取手机传感器数据,更新定位图标方向</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">updateRotation</span><span class="params">(<span class="keyword">float</span> rotation)</span> </span>{</span><br><span class="line"> <span class="keyword">if</span> (symbol != <span class="keyword">null</span>) {</span><br><span class="line"> symbol.setAngle(rotation);</span><br><span class="line"> }</span><br><span class="line"> }</span><br></pre></td></tr></table></figure>]]></content>
<summary type="html">
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class=
</summary>
<category term="前端" scheme="http://example.com/categories/%E5%89%8D%E7%AB%AF/"/>
<category term="Android" scheme="http://example.com/tags/Android/"/>
</entry>
<entry>
<title>SQLite表升级和导入</title>
<link href="http://example.com/2021/04/15/SQLite%E8%A1%A8%E5%8D%87%E7%BA%A7%E5%92%8C%E5%AF%BC%E5%85%A5/"/>
<id>http://example.com/2021/04/15/SQLite表升级和导入/</id>
<published>2021-04-15T06:31:00.000Z</published>
<updated>2021-05-21T03:39:53.953Z</updated>
<content type="html"><![CDATA[<h5 id="数据库升级增加表和删除表都不涉及数据迁移,但是修改表涉及到对原有数据进行迁移。"><a href="#数据库升级增加表和删除表都不涉及数据迁移,但是修改表涉及到对原有数据进行迁移。" class="headerlink" title="数据库升级增加表和删除表都不涉及数据迁移,但是修改表涉及到对原有数据进行迁移。"></a>数据库升级增加表和删除表都不涉及数据迁移,但是修改表涉及到对原有数据进行迁移。</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line">public class DBservice extends SQLiteOpenHelper {</span><br><span class="line"> private String CREATE_BOOK = "create table book(bookId integer</span><br><span class="line"> primarykey,</span><br><span class="line"> bookName text);";</span><br><span class="line"> private String CREATE_TEMP_BOOK = "alter table book rename to _temp_book";</span><br><span class="line"> private String INSERT_DATA = "insert into book select *,'' from _temp_book";</span><br><span class="line"> private String DROP_BOOK = "drop table _temp_book";</span><br><span class="line"></span><br><span class="line"> public DBservice(Context context, String name, CursorFactory factory, int</span><br><span class="line"> version) {</span><br><span class="line"> super(context, name, factory, version);</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> @Override</span><br><span class="line"> public void onCreate(SQLiteDatabase db) {</span><br><span class="line"> db.execSQL(CREATE_BOOK);</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> @Override</span><br><span class="line"> public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {</span><br><span class="line"> switch (newVersion) {</span><br><span class="line"> case 2:</span><br><span class="line"> db.beginTransaction();</span><br><span class="line"> db.execSQL(CREATE_TEMP_BOOK);</span><br><span class="line"> db.execSQL(CREATE_BOOK);</span><br><span class="line"> db.execSQL(INSERT_DATA);</span><br><span class="line"> db.execSQL(DROP_BOOK);</span><br><span class="line"> db.setTransactionSuccessful();</span><br><span class="line"> db.endTransaction();</span><br><span class="line"> break;</span><br><span class="line"> }</span><br><span class="line"> }</span><br></pre></td></tr></table></figure><h5 id="打开外部数据库"><a href="#打开外部数据库" class="headerlink" title="打开外部数据库"></a>打开外部数据库</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line">public class DatabaseManager {</span><br><span class="line"> private DaoMaster mDaoMaster = null;</span><br><span class="line"> private DaoSession otherDaoSession = null;</span><br><span class="line"></span><br><span class="line"> private DatabaseManager() {</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> private static final class Holder {</span><br><span class="line"> private static final DatabaseManager INSTANCE = new DatabaseManager();</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> public static DatabaseManager getInstance() {</span><br><span class="line"> return Holder.INSTANCE;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> //获取外部其它数据库DaoSession</span><br><span class="line"> DaoSession getOtherDaoSession(String dbName) {</span><br><span class="line"> //if (otherDaoSession == null) {</span><br><span class="line"> otherDaoSession = getDaoMaster(dbName).newSession();</span><br><span class="line"> //}</span><br><span class="line"> return otherDaoSession;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> private DaoMaster getDaoMaster(String dbName) {</span><br><span class="line"> if (dbName == null || TextUtils.isEmpty(dbName)) {</span><br><span class="line"> return null;</span><br><span class="line"> }</span><br><span class="line"> //if (mDaoMaster == null) {</span><br><span class="line"> //mDaoMaster = new DaoMaster(new DaoMaster.DevOpenHelper(context, dbName).getWritableDb());</span><br><span class="line"> mDaoMaster = new DaoMaster(SQLiteDatabase.openDatabase(dbName, null, SQLiteDatabase.OPEN_READWRITE));</span><br><span class="line"> //}</span><br><span class="line"> return mDaoMaster;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line">}</span><br></pre></td></tr></table></figure>]]></content>
<summary type="html">
<h5 id="数据库升级增加表和删除表都不涉及数据迁移,但是修改表涉及到对原有数据进行迁移。"><a href="#数据库升级增加表和删除表都不涉及数据迁移,但是修改表涉及到对原有数据进行迁移。" class="headerlink" title="数据库升级增加表和删除表都不
</summary>
<category term="移动端" scheme="http://example.com/categories/%E7%A7%BB%E5%8A%A8%E7%AB%AF/"/>
<category term="Android" scheme="http://example.com/tags/Android/"/>
</entry>
<entry>
<title>坐标、投影及坐标转换</title>
<link href="http://example.com/2021/04/15/%E5%9D%90%E6%A0%87%E3%80%81%E6%8A%95%E5%BD%B1%E5%8F%8A%E5%9D%90%E6%A0%87%E8%BD%AC%E6%8D%A2/"/>
<id>http://example.com/2021/04/15/坐标、投影及坐标转换/</id>
<published>2021-04-15T06:31:00.000Z</published>
<updated>2021-05-21T03:39:53.953Z</updated>
<content type="html"><![CDATA[<p>1.坐标、投影及坐标转换<br><a href="https://pic1.zhimg.com/80/v2-8d3fb5483f96fa4b1c30f921aa23cbbc_720w.jpg" target="_blank" rel="noopener">坐标转换图</a></p><p>参考博客:<a href="https://zhuanlan.zhihu.com/p/34662114" target="_blank" rel="noopener">https://zhuanlan.zhihu.com/p/34662114</a></p><p>2.<a href="https://epsg.io/" target="_blank" rel="noopener">epsg转换</a></p><p>3.飞控系统 dronekit ,dronekit-android</p><ol start="4"><li><a href="https://baike.baidu.com/item/%E5%B7%AE%E5%88%86GPS/10862498?fromtitle=GPS%E5%B7%AE%E5%88%86&fromid=417300" target="_blank" rel="noopener">基准站使用原理(差分)</a></li></ol><p>以地球角度看,移动站和基站准加载20公里以内都可以看做是同一位置。<br>同一时间 同一位置对同一组卫星进行观测,大家都是穿过相同的大气、云层等这些‘固定’误差的地方(可以当作常数考虑),常数在方程中是可以抵消,所以你差分后得到的结果是已经抵消掉理论上所有环境上的误差</p><p>载波相位测量(英语:Carrier phase measurement) 利用卫星与接收器之间相对运动的关系,先取得卫星发射讯号时所产生的相位与接收器接收时所产生的参考相位,并求出两者之间的相位差值,即为载波观测量[1]。测量方法与虚拟距离相似,但虚拟距离是利用电码观测。</p><p><a href="https://blog.csdn.net/zhangbijun1230/article/details/80958036" target="_blank" rel="noopener">手机定位,GPS定位</a></p>]]></content>
<summary type="html">
<p>1.坐标、投影及坐标转换<br><a href="https://pic1.zhimg.com/80/v2-8d3fb5483f96fa4b1c30f921aa23cbbc_720w.jpg" target="_blank" rel="noopener">坐标转换图</a>
</summary>
<category term="其它" scheme="http://example.com/categories/%E5%85%B6%E5%AE%83/"/>
<category term="Android" scheme="http://example.com/tags/Android/"/>
</entry>
<entry>
<title>Retrofit与Postman的对应关系</title>
<link href="http://example.com/2021/04/12/Retrofit%E7%BD%91%E7%BB%9C%E8%AF%B7%E6%B1%82%20%E4%B8%8E%20Postman/"/>
<id>http://example.com/2021/04/12/Retrofit网络请求 与 Postman/</id>
<published>2021-04-12T07:42:00.000Z</published>
<updated>2021-05-21T03:39:53.953Z</updated>
<content type="html"><![CDATA[<p>1.postman里面的form-data<br>对应 @Part 标签,上传数据。<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">@Multipart</span><br><span class="line">@POST</span><br><span class="line">Call<JsonObject> post1(@Url String url, @PartMap Map<String, RequestBody> params, @PartMap Map<String, MultipartBody.Part> parts);</span><br><span class="line"></span><br><span class="line">实现:</span><br><span class="line">参数一:RequestBody name = RequestBody.create(MediaType.parse("application/form-data"), name);</span><br><span class="line"></span><br><span class="line">参数二:RequestBody fileRQ = RequestBody.create(MediaType.parse("image/*"), file);</span><br><span class="line">MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), fileRQ);</span><br></pre></td></tr></table></figure></p><p>2.postman里面的x-www-form-urlencoded<br>对应 @Field,以表单形式提交数据<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">@FormUrlEncoded</span><br><span class="line">@POST</span><br><span class="line">Call<JsonObject> post(@Url String url, @FieldMap Map<String, Object> params);</span><br></pre></td></tr></table></figure></p><p>3.postman里面的raw<br>对应@Body ,在body中以json或text字符串的形式提交数据<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">@POST</span><br><span class="line">Call<JsonObject> post2(@Url String url, @Body RequestBody test);</span><br><span class="line">例子:RequestBody type = RequestBody.create(MediaType.parse("application/json"), string);</span><br><span class="line"></span><br><span class="line">//或者不传RequestBody,直接传对象</span><br><span class="line">@POST</span><br><span class="line">Call<JsonObject> post2(@Url String url, @Body Object o);</span><br><span class="line"></span><br><span class="line">例子:post(url,User),post(url,hashmap)</span><br></pre></td></tr></table></figure></p><hr><p>示例:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">//将json数据打包成字符串一次性传输</span><br><span class="line">Gson gson = new GsonBuilder().disableHtmlEscaping().create();</span><br><span class="line">JSONObject object = new JSONObject(gson.toJson(entity));</span><br><span class="line">object.put("","");</span><br><span class="line">HashMap<String, Object> hashMap = new HashMap<>();</span><br><span class="line">hashMap.put("requestText", object.toString());</span><br><span class="line">service.post(url,hashmap);</span><br><span class="line"></span><br><span class="line">[JSONObject 和 JsonObject 的区别](https://blog.csdn.net/ceovip/article/details/77980832)</span><br></pre></td></tr></table></figure></p>]]></content>
<summary type="html">
<p>1.postman里面的form-data<br>对应 @Part 标签,上传数据。<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</sp
</summary>
<category term="移动端" scheme="http://example.com/categories/%E7%A7%BB%E5%8A%A8%E7%AB%AF/"/>
<category term="Android" scheme="http://example.com/tags/Android/"/>
</entry>
<entry>
<title>Handler机制</title>
<link href="http://example.com/2021/04/08/Handler%E6%9C%BA%E5%88%B6/"/>
<id>http://example.com/2021/04/08/Handler机制/</id>
<published>2021-04-08T03:15:00.000Z</published>
<updated>2021-05-14T09:01:00.574Z</updated>
<content type="html"><![CDATA[<p>整个消息的循环流程:</p><ul><li>1.Handler 通 过 sendMessage() 发 送 消 息 Message 到 消 息 队 列 MessageQueue。</li><li>2.Looper 通过 loop()不断提取触发条件的 Message,并将 Message 交 给对应的 target handler 来处理。</li><li>3.target handler 调用自身的handleMessage()方法来处理 Message。</li></ul><p>结论:</p><ul><li>主线程创建的时候会创建一个MainLooper,并且进入循环。</li><li>线程的 Looper 不允许退出,ActivityThread的main方法主要就是做消息循环,一旦退出消息循环,那么你的应用也就退出了。</li><li>loop死循环只是简单地处理轻量的消息操作,和ANR并没有关系。<br>looper.loop() 不断地接收事件、处理事件,每一个点击触摸或者说Activity的生命周期都是运行在 Looper.loop() 的控制之下,如果它停止了,应用也就停止了。只能是某一个消息或者说对消息的处理阻塞了 Looper.loop(),而不是 Looper.loop() 阻塞它。也就说我们的代码其实就是在这个循环里面去执行的,当然不会阻塞了。</li></ul><p><a href="Looper.loop和主线程的关系">参考链接1</a></p><p><a href="https://www.cnblogs.com/l2rf/p/6055218.html" target="_blank" rel="noopener">参考链接2</a></p>]]></content>
<summary type="html">
<p>整个消息的循环流程:</p>
<ul>
<li>1.Handler 通 过 sendMessage() 发 送 消 息 Message 到 消 息 队 列 MessageQueue。</li>
<li>2.Looper 通过 loop()不断提取触发条件的 Message,
</summary>
<category term="移动端" scheme="http://example.com/categories/%E7%A7%BB%E5%8A%A8%E7%AB%AF/"/>
<category term="Android" scheme="http://example.com/tags/Android/"/>
</entry>
<entry>
<title>天地图</title>
<link href="http://example.com/2021/04/07/%E5%A4%A9%E5%9C%B0%E5%9B%BE/"/>
<id>http://example.com/2021/04/07/天地图/</id>
<published>2021-04-07T08:41:00.000Z</published>
<updated>2021-05-14T09:11:12.208Z</updated>
<content type="html"><![CDATA[<h5 id="坐标系:"><a href="#坐标系:" class="headerlink" title="坐标系:"></a>坐标系:</h5><p>CGCS2000</p><h5 id="常用图层:"><a href="#常用图层:" class="headerlink" title="常用图层:"></a>常用图层:</h5><p>1.矢量底图<br>2.影像底图</p><h5 id="投影类型:"><a href="#投影类型:" class="headerlink" title="投影类型:"></a>投影类型:</h5><ul><li>经纬度投影</li><li>球面墨卡托投影</li></ul><p>注:不同投影类型的区别在于请求链接不同</p><p>》<a href="http://lbs.tianditu.gov.cn/server/MapService.html" target="_blank" rel="noopener">官网链接</a></p>]]></content>
<summary type="html">
<h5 id="坐标系:"><a href="#坐标系:" class="headerlink" title="坐标系:"></a>坐标系:</h5><p>CGCS2000</p>
<h5 id="常用图层:"><a href="#常用图层:" class="headerlink
</summary>
<category term="移动端" scheme="http://example.com/categories/%E7%A7%BB%E5%8A%A8%E7%AB%AF/"/>
<category term="Android" scheme="http://example.com/tags/Android/"/>
</entry>
<entry>
<title>AES加密、解密</title>
<link href="http://example.com/2021/03/30/AES%E5%8A%A0%E5%AF%86%E3%80%81%E8%A7%A3%E5%AF%86/"/>
<id>http://example.com/2021/03/30/AES加密、解密/</id>
<published>2021-03-30T10:26:00.000Z</published>
<updated>2021-05-14T07:56:12.162Z</updated>
<content type="html"><![CDATA[<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br></pre></td><td class="code"><pre><span class="line">package com.southgnss.lj;</span><br><span class="line"></span><br><span class="line">import android.text.TextUtils;</span><br><span class="line">import android.util.Base64;</span><br><span class="line"></span><br><span class="line">import javax.crypto.Cipher;</span><br><span class="line">import javax.crypto.spec.IvParameterSpec;</span><br><span class="line">import javax.crypto.spec.SecretKeySpec;</span><br><span class="line"></span><br><span class="line">public class AESEncrypt {</span><br><span class="line"> //偏移量</span><br><span class="line"> public static final String VIPARA = "1234567812345678"; //AES 为16位. DES 为8bytes</span><br><span class="line"> //AES是加密方式 CBC是工作模式 PKCS5Padding是填充模式</span><br><span class="line"> private static final String CBC_PKCS5_PADDING = "AES/CBC/PKCS5Padding";</span><br><span class="line"> //AES 加密</span><br><span class="line"> private static final String AES = "AES";</span><br><span class="line"> // SHA1PRNG 强随机种子算法, 要区别4.2以上版本的调用方法</span><br><span class="line"> private static final String SHA1PRNG = "SHA1PRNG";</span><br><span class="line"> //编码方式</span><br><span class="line"> public static final String CODE_TYPE = "UTF-8";</span><br><span class="line"></span><br><span class="line"> //AES加密需要密钥长度为16位,不够时默认可以用 \0 补齐</span><br><span class="line"> public static final String key = "123456789\0\0\0\0\0\0\0";</span><br><span class="line"></span><br><span class="line"> /**</span><br><span class="line"> * 加密</span><br><span class="line"> * @param cleartext</span><br><span class="line"> * @return</span><br><span class="line"> */</span><br><span class="line"> public static String encrypt(String cleartext) {</span><br><span class="line"> return encrypt(key, cleartext);</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> public static String encrypt(String key, String cleartext) {</span><br><span class="line"> if (TextUtils.isEmpty(cleartext)) {</span><br><span class="line"> return cleartext;</span><br><span class="line"> }</span><br><span class="line"> try {</span><br><span class="line"> byte[] result = encrypt(key, cleartext.getBytes(CODE_TYPE));</span><br><span class="line"> return new String(Base64.encode(result, Base64.NO_WRAP), CODE_TYPE);</span><br><span class="line"> } catch (Exception e) {</span><br><span class="line"> e.printStackTrace();</span><br><span class="line"> }</span><br><span class="line"> return null;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> public static byte[] encrypt(String key, byte[] clear) throws Exception {</span><br><span class="line"> IvParameterSpec zeroIv = new IvParameterSpec(VIPARA.getBytes(CODE_TYPE));</span><br><span class="line"> /*byte[] raw = getRawKey(key.getBytes("utf-8"));</span><br><span class="line"> SecretKeySpec skeySpec = new SecretKeySpec(raw, AES);*/</span><br><span class="line"> byte[] raw = key.getBytes(CODE_TYPE);</span><br><span class="line"> SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");</span><br><span class="line"> Cipher cipher = Cipher.getInstance(CBC_PKCS5_PADDING);</span><br><span class="line"> cipher.init(Cipher.ENCRYPT_MODE, skeySpec, zeroIv);</span><br><span class="line"> byte[] encrypted = cipher.doFinal(clear);</span><br><span class="line"> return encrypted;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> /**</span><br><span class="line"> * 解密</span><br><span class="line"> *</span><br><span class="line"> * @param key</span><br><span class="line"> * @param encrypted</span><br><span class="line"> * @return</span><br><span class="line"> */</span><br><span class="line"> public static String decrypt(String key, String encrypted) {</span><br><span class="line"> if (TextUtils.isEmpty(encrypted)) {</span><br><span class="line"> return encrypted;</span><br><span class="line"> }</span><br><span class="line"> try {</span><br><span class="line"> byte[] enc = Base64.decode(encrypted.getBytes(CODE_TYPE), Base64.NO_WRAP);</span><br><span class="line"> byte[] result = decrypt(key, enc);</span><br><span class="line"> return new String(result);</span><br><span class="line"> } catch (Exception e) {</span><br><span class="line"> e.printStackTrace();</span><br><span class="line"> }</span><br><span class="line"> return null;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> public static byte[] decrypt(String key, byte[] encrypted) throws Exception {</span><br><span class="line"> IvParameterSpec zeroIv = new IvParameterSpec(VIPARA.getBytes(CODE_TYPE));</span><br><span class="line"> /* byte[] raw = getRawKey(key.getBytes());</span><br><span class="line"> SecretKeySpec skeySpec = new SecretKeySpec(raw, AES);*/</span><br><span class="line"> byte[] raw = key.getBytes(CODE_TYPE);</span><br><span class="line"> SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");</span><br><span class="line"> Cipher cipher = Cipher.getInstance(CBC_PKCS5_PADDING);</span><br><span class="line"> cipher.init(Cipher.DECRYPT_MODE, skeySpec, zeroIv);</span><br><span class="line"> byte[] decrypted = cipher.doFinal(encrypted);</span><br><span class="line"> return decrypted;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">}</span><br></pre></td></tr></table></figure>]]></content>
<summary type="html">
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class
</summary>
<category term="其它" scheme="http://example.com/categories/%E5%85%B6%E5%AE%83/"/>
<category term="Android" scheme="http://example.com/tags/Android/"/>
</entry>
<entry>
<title>使用Gson出现转译字符</title>
<link href="http://example.com/2021/03/30/%E4%BD%BF%E7%94%A8Gson%E5%87%BA%E7%8E%B0%E8%BD%AC%E8%AF%91%E5%AD%97%E7%AC%A6/"/>
<id>http://example.com/2021/03/30/使用Gson出现转译字符/</id>
<published>2021-03-30T05:10:05.000Z</published>
<updated>2021-05-14T09:10:53.805Z</updated>
<content type="html"><![CDATA[<h4 id="1-出现转译字符"><a href="#1-出现转译字符" class="headerlink" title="1.出现转译字符"></a>1.出现转译字符</h4><pre><code>String s = new Gson().toJson(encodedText);出现转译字符原因:Gson会把html标签,转换为Unicode转义字符。正确的使用方法是:Gson gson = new GsonBuilder().disableHtmlEscaping().create();</code></pre><h6 id="注意:用AES加密后的字符串转义后会变"><a href="#注意:用AES加密后的字符串转义后会变" class="headerlink" title="注意:用AES加密后的字符串转义后会变"></a>注意:用AES加密后的字符串转义后会变</h6><h4 id="2-pache工具包common-lang进行html-xml-java等的转义与反转义"><a href="#2-pache工具包common-lang进行html-xml-java等的转义与反转义" class="headerlink" title="2.pache工具包common-lang进行html,xml,java等的转义与反转义"></a>2.pache工具包common-lang进行html,xml,java等的转义与反转义</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">String str1 = StringEscapeUtils.unescapeJava(str);</span><br><span class="line">原始 str = {\"name\":\"spy\",\"id\":\"123456\"}</span><br><span class="line">目标 str1 = {"name":"spy","id":"123456"}</span><br></pre></td></tr></table></figure><p>下载地址:<a href="https://commons.apache.org/proper/commons-lang/download_lang.cgi" target="_blank" rel="noopener">https://commons.apache.org/proper/commons-lang/download_lang.cgi</a></p>]]></content>
<summary type="html">
<h4 id="1-出现转译字符"><a href="#1-出现转译字符" class="headerlink" title="1.出现转译字符"></a>1.出现转译字符</h4><pre><code>String s = new Gson().toJson(encodedTe
</summary>
<category term="移动端" scheme="http://example.com/categories/%E7%A7%BB%E5%8A%A8%E7%AB%AF/"/>
<category term="json" scheme="http://example.com/tags/json/"/>
</entry>
<entry>
<title>博客发布后自定义域名失效</title>
<link href="http://example.com/2021/03/29/%E5%8D%9A%E5%AE%A2%E5%8F%91%E5%B8%83%E5%90%8E%E8%87%AA%E5%AE%9A%E4%B9%89%E5%9F%9F%E5%90%8D%E5%A4%B1%E6%95%88/"/>
<id>http://example.com/2021/03/29/博客发布后自定义域名失效/</id>
<published>2021-03-29T03:19:01.000Z</published>
<updated>2021-03-29T03:20:03.906Z</updated>
<content type="html"><![CDATA[<p>1.博客发布后自定义域名失效<br><a href="https://blog.csdn.net/xs20691718/article/details/81873921" target="_blank" rel="noopener">https://blog.csdn.net/xs20691718/article/details/81873921</a></p><p>2.title标题中,冒号后面不能接空格,否则会报错</p>]]></content>
<summary type="html">
<p>1.博客发布后自定义域名失效<br><a href="https://blog.csdn.net/xs20691718/article/details/81873921" target="_blank" rel="noopener">https://blog.csdn.ne
</summary>
<category term="其它" scheme="http://example.com/categories/%E5%85%B6%E5%AE%83/"/>
<category term="博客" scheme="http://example.com/tags/%E5%8D%9A%E5%AE%A2/"/>
</entry>
<entry>
<title>NFC触碰连接蓝牙</title>
<link href="http://example.com/2021/03/25/NFC%E8%A7%A6%E7%A2%B0%E8%BF%9E%E6%8E%A5%E8%93%9D%E7%89%99/"/>
<id>http://example.com/2021/03/25/NFC触碰连接蓝牙/</id>
<published>2021-03-25T10:38:00.000Z</published>
<updated>2021-05-14T09:06:34.192Z</updated>
<content type="html"><![CDATA[<p>工具类<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br></pre></td><td class="code"><pre><span class="line">package com.southgnss.survx.device.nfc;</span><br><span class="line"></span><br><span class="line">import android.app.Activity;</span><br><span class="line">import android.app.PendingIntent;</span><br><span class="line">import android.content.Intent;</span><br><span class="line">import android.content.IntentFilter;</span><br><span class="line">import android.nfc.NdefMessage;</span><br><span class="line">import android.nfc.NdefRecord;</span><br><span class="line">import android.nfc.NfcAdapter;</span><br><span class="line">import android.nfc.tech.MifareClassic;</span><br><span class="line">import android.nfc.tech.NfcA;</span><br><span class="line">import android.os.Parcelable;</span><br><span class="line">import android.os.SystemClock;</span><br><span class="line">import android.text.TextUtils;</span><br><span class="line">import android.util.Log;</span><br><span class="line"></span><br><span class="line">import com.southgnss.library.device.ConnectListener;</span><br><span class="line">import com.southgnss.library.device.DeviceParManage;</span><br><span class="line">import com.southgnss.library.device.DeviceType;</span><br><span class="line">import com.southgnss.library.device.TopDataIOFactory;</span><br><span class="line">import com.southgnss.library.device.TopDeviceManage;</span><br><span class="line">import com.southgnss.library.device.message.FunctionEnablePar;</span><br><span class="line">import com.southgnss.library.util.ProgramConfigWrapper;</span><br><span class="line">import com.southgnss.survx.device.setting.StringManage;</span><br><span class="line"></span><br><span class="line">public class NfcUtils {</span><br><span class="line"> private NfcAdapter mNfcAdapter;</span><br><span class="line"> private IntentFilter[] mIntentFilter = null;</span><br><span class="line"> private PendingIntent mPendingIntent = null;</span><br><span class="line"> private String[][] mTechList = null;</span><br><span class="line"> private long lSetLocationSysTime = 0L;</span><br><span class="line"></span><br><span class="line"> private static NfcUtils nfcUtils;</span><br><span class="line"></span><br><span class="line"> public static NfcUtils getInstance(Activity activity) {</span><br><span class="line"> if (nfcUtils == null) {</span><br><span class="line"> synchronized (NfcUtils.class) {</span><br><span class="line"> if (nfcUtils == null) {</span><br><span class="line"> nfcUtils = new NfcUtils(activity);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> return nfcUtils;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> public NfcUtils(Activity activity) {</span><br><span class="line"> NfcInit(activity);</span><br><span class="line"> mNfcAdapter = NfcAdapter.getDefaultAdapter(activity);</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> /**</span><br><span class="line"> * 首先,检查NFC是否打开</span><br><span class="line"> */</span><br><span class="line"> public boolean isEnabled() {</span><br><span class="line"> return mNfcAdapter != null && mNfcAdapter.isEnabled();</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> /**</span><br><span class="line"> * 初始化nfc设置</span><br><span class="line"> */</span><br><span class="line"> private void NfcInit(Activity activity) {</span><br><span class="line"> Intent intent = new Intent(activity, activity.getClass());</span><br><span class="line"> intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);</span><br><span class="line"> mPendingIntent = PendingIntent.getActivity(activity, 0, intent, 0);</span><br><span class="line"> //做一个IntentFilter过滤你想要的action 这里过滤的是ndef</span><br><span class="line"> IntentFilter filter = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);</span><br><span class="line"> try {</span><br><span class="line"> filter.addDataType("*/*");</span><br><span class="line"> } catch (IntentFilter.MalformedMimeTypeException e) {</span><br><span class="line"> e.printStackTrace();</span><br><span class="line"> }</span><br><span class="line"> mTechList = new String[][]{{MifareClassic.class.getName()}, {NfcA.class.getName()}};</span><br><span class="line"> //生成intentFilter</span><br><span class="line"> mIntentFilter = new IntentFilter[]{filter};</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> /**</span><br><span class="line"> * 开启前台调度系统</span><br><span class="line"> */</span><br><span class="line"> public void enableForegroundDispatch(Activity activity) {</span><br><span class="line"> if (mNfcAdapter != null && mIntentFilter != null) {</span><br><span class="line"> mNfcAdapter.enableForegroundDispatch(activity, mPendingIntent, mIntentFilter, mTechList);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> /**</span><br><span class="line"> * 关闭前台调度系统</span><br><span class="line"> */</span><br><span class="line"> public void disableForegroundDispatch(Activity activity) {</span><br><span class="line"> if (mNfcAdapter != null && mIntentFilter != null) {</span><br><span class="line"> mNfcAdapter.disableForegroundDispatch(activity);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> /**</span><br><span class="line"> * 读取到的NFC数据</span><br><span class="line"> */</span><br><span class="line"> public void resolveIntent(Intent intent) {</span><br><span class="line"> if (SystemClock.elapsedRealtime() - lSetLocationSysTime < 8000L) {</span><br><span class="line"> return;</span><br><span class="line"> }</span><br><span class="line"> lSetLocationSysTime = SystemClock.elapsedRealtime();</span><br><span class="line"> String action = intent.getAction();</span><br><span class="line"> if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action) || NfcAdapter.ACTION_TECH_DISCOVERED.equals(action) || NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) {</span><br><span class="line"> Parcelable[] rawArray = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);</span><br><span class="line"> NdefMessage[] msgs;</span><br><span class="line"> //处理扫描蓝牙地址的</span><br><span class="line"> if (rawArray != null) {</span><br><span class="line"> msgs = new NdefMessage[rawArray.length];</span><br><span class="line"> for (int i = 0; i < rawArray.length; i++) {</span><br><span class="line"> msgs[i] = (NdefMessage) rawArray[i];</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> for (final NdefRecord record : msgs[0].getRecords()) {</span><br><span class="line"> byte[] src = record.getPayload();</span><br><span class="line"> if (record.getPayload().length < 36) {</span><br><span class="line"> return;</span><br><span class="line"> }</span><br><span class="line"> StringBuilder macBuilder = new StringBuilder();</span><br><span class="line"> //解析蓝牙mac地址,倒过来放的</span><br><span class="line"> char[] buffer = new char[2];</span><br><span class="line"> for (int i = 7; i > 1; i--) {</span><br><span class="line"> buffer[0] = Character.toUpperCase(Character.forDigit((src[i] >>> 4) & 0x0F, 16));</span><br><span class="line"> buffer[1] = Character.toUpperCase(Character.forDigit(src[i] & 0x0F, 16));</span><br><span class="line"> macBuilder.append(buffer);</span><br><span class="line"> if (i == 2) {</span><br><span class="line"> break;</span><br><span class="line"> }</span><br><span class="line"> macBuilder.append(":");</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> StringBuilder boothBuilder = new StringBuilder();</span><br><span class="line"> for (int i = 21; i < src.length; i++) {</span><br><span class="line"> buffer[0] = Character.toUpperCase(Character.forDigit((src[i] >>> 4) & 0x0F, 16));</span><br><span class="line"> buffer[1] = Character.toUpperCase(Character.forDigit(src[i] & 0x0F, 16));</span><br><span class="line"> boothBuilder.append(buffer);</span><br><span class="line"> }</span><br><span class="line"> String strDeviceName = StringManage.decode(boothBuilder.toString());</span><br><span class="line"> String strDevice = strDeviceName + "|" + macBuilder.toString();</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> </span><br><span class="line"> /**</span><br><span class="line"> * 程序退出,释放</span><br><span class="line"> */</span><br><span class="line"> public void nfcRelease() {</span><br><span class="line"> if (mNfcAdapter != null) {</span><br><span class="line"> mNfcAdapter = null;</span><br><span class="line"> }</span><br><span class="line"> if (nfcUtils != null) {</span><br><span class="line"> nfcUtils = null;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> public NfcAdapter getNfcAdapter() {</span><br><span class="line"> return mNfcAdapter;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"> public IntentFilter[] getIntentFilter() {</span><br><span class="line"> return mIntentFilter;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> public PendingIntent getPendingIntent() {</span><br><span class="line"> return mPendingIntent;</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line"> public String[][] getTechList() {</span><br><span class="line"> return mTechList;</span><br><span class="line"> }</span><br><span class="line"> </span><br><span class="line">}</span><br></pre></td></tr></table></figure></p><p>使用<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br></pre></td><td class="code"><pre><span class="line">public class MainActivity extends BaseActivity{</span><br><span class="line">private NfcUtils nfcUtils;</span><br><span class="line"></span><br><span class="line"> @Override</span><br><span class="line"> public void initData() {</span><br><span class="line"> //nfc初始化设置</span><br><span class="line"> nfcUtils = NfcUtils.getInstance(this);</span><br><span class="line"> }</span><br><span class="line"> </span><br><span class="line"> @Override</span><br><span class="line"> protected void onNewIntent(Intent intent) {</span><br><span class="line"> super.onNewIntent(intent);</span><br><span class="line"> //当该Activity接收到NFC标签时,运行该方法</span><br><span class="line"> //调用工具方法,读取到的NFC数据</span><br><span class="line"> if (intent.getAction() != null && intent.getAction().equalsIgnoreCase("android.nfc.action.NDEF_DISCOVERED")) {</span><br><span class="line"> setIntent(intent);</span><br><span class="line"> if (nfcUtils != null) {</span><br><span class="line"> nfcUtils.resolveIntent(intent);</span><br><span class="line"> }</span><br><span class="line"> return;</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> </span><br><span class="line"> @Override</span><br><span class="line"> protected void onResume() {</span><br><span class="line"> super.onResume();</span><br><span class="line"> if (nfcUtils != null && nfcUtils.isEnabled()) {</span><br><span class="line"> nfcUtils.enableForegroundDispatch(this);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> </span><br><span class="line"> @Override</span><br><span class="line"> protected void onPause() {</span><br><span class="line"> super.onPause();</span><br><span class="line"> if (nfcUtils != null && nfcUtils.isEnabled()) {</span><br><span class="line"> nfcUtils.disableForegroundDispatch(this);</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> </span><br><span class="line"> @Override</span><br><span class="line"> protected void onDestroy() {</span><br><span class="line"> if (nfcUtils != null ) {</span><br><span class="line"> nfcUtils.nfcRelease();</span><br><span class="line"> }</span><br><span class="line"> super.onDestroy();</span><br><span class="line"> }</span><br><span class="line"> </span><br><span class="line"></span><br><span class="line">}</span><br></pre></td></tr></table></figure></p>]]></content>
<summary type="html">
<p>工具类<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><
</summary>
<category term="移动端" scheme="http://example.com/categories/%E7%A7%BB%E5%8A%A8%E7%AB%AF/"/>
<category term="Android" scheme="http://example.com/tags/Android/"/>
</entry>
<entry>
<title>synchronized与线程中断问题</title>
<link href="http://example.com/2021/03/25/synchronized%E4%B8%8E%E7%BA%BF%E7%A8%8B%E4%B8%AD%E6%96%AD%E9%97%AE%E9%A2%98/"/>
<id>http://example.com/2021/03/25/synchronized与线程中断问题/</id>
<published>2021-03-25T03:30:00.000Z</published>
<updated>2021-05-14T09:08:37.985Z</updated>
<content type="html"><![CDATA[<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br></pre></td><td class="code"><pre><span class="line">public class Uninterruptible {</span><br><span class="line"> private static final Object o1 = new Object();</span><br><span class="line"></span><br><span class="line"> public static void main(String[] args) throws InterruptedException {</span><br><span class="line"> </span><br><span class="line"> Thread thread1 = new Thread(() -> {</span><br><span class="line"> synchronized (o1) {</span><br><span class="line"> try {</span><br><span class="line"> System.out.println("start lock t1");</span><br><span class="line"> Thread.sleep(20000);</span><br><span class="line"> System.out.println("end lock t1");</span><br><span class="line"> } catch (InterruptedException e) {</span><br><span class="line"> e.printStackTrace();</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> });</span><br><span class="line"> </span><br><span class="line"> Thread thread2 = new Thread(() -> {</span><br><span class="line"> synchronized (o1) {</span><br><span class="line"> while (!isInterrupted()) {</span><br><span class="line"> try {</span><br><span class="line"> System.out.println("start lock t2");</span><br><span class="line"> Thread.sleep(20000);</span><br><span class="line"> System.out.println("end lock t2");</span><br><span class="line"> } catch (InterruptedException e) {</span><br><span class="line"> e.printStackTrace();</span><br><span class="line"> //重新设置中断标示,因为抛出异常后中断标示会被清除。要想线程停止需要加上这一句</span><br><span class="line"> Thread.currentThread().interrupt();</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> });</span><br><span class="line"> </span><br><span class="line"></span><br><span class="line"> thread1.start();</span><br><span class="line"> // 中断线程的执行</span><br><span class="line"> thread1.interrupt();</span><br><span class="line"> //中断线程2</span><br><span class="line"> thread2.interrupt();</span><br><span class="line"> //锁死情况下,interrupt无效。</span><br><span class="line"> }</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">总结:</span><br><span class="line">1.要想中断线程需要在catch子句中,调用Thread.currentThread.interrupt()来设置中断状态(因为抛出异常后中断标示会被清除),让外界通过判断Thread.currentThread().isInterrupted()标示来决定是否终止线程还是继续下去,否者线程阻塞状态下是不会中断的。</span><br><span class="line">2.synchronized在获锁的过程中是不能被中断的,意思是说如果产生了死锁,则不可能被中断。与synchronized功能相似的reentrantLock.lock()方法也是一样,它也不可中断的,即如果发生死锁,那么reentrantLock.lock()方法无法终止,如果调用时被阻塞,则它一直阻塞到它获取到锁为止。</span><br><span class="line">3.线程管理推荐使用线程池,不直接使用 new Thread()。</span><br></pre></td></tr></table></figure>]]></content>
<summary type="html">
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class
</summary>
<category term="后端" scheme="http://example.com/categories/%E5%90%8E%E7%AB%AF/"/>
<category term="Java" scheme="http://example.com/tags/Java/"/>
</entry>
<entry>
<title>Replugin插件化</title>
<link href="http://example.com/2021/03/24/Replugin%E6%8F%92%E4%BB%B6%E5%8C%96/"/>
<id>http://example.com/2021/03/24/Replugin插件化/</id>
<published>2021-03-24T03:37:00.000Z</published>
<updated>2021-05-14T09:07:25.070Z</updated>
<content type="html"><![CDATA[<h3 id="1-概念及技术分析"><a href="#1-概念及技术分析" class="headerlink" title="1.概念及技术分析"></a>1.概念及技术分析</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">Atlas:功能强大,完善。学习成本,接入成本比较高,适合门户型大型应用。</span><br><span class="line"></span><br><span class="line">Replugin:轻量级可快速使用的插件化框架,适合中小型应用。</span><br><span class="line">优点:API接近原生应用,只有一个hook点,兼容性好,不需要随着Android系统的升级进行后续的兼容。</span><br></pre></td></tr></table></figure><h3 id="2-学习总结"><a href="#2-学习总结" class="headerlink" title="2.学习总结"></a>2.学习总结</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line">1.getMergeAssetTask()不到</span><br><span class="line">解决: android-gradle-plugin:3.5.3</span><br><span class="line"> replugin-host-gradle:2.3.3</span><br><span class="line"></span><br><span class="line">2.插件生成步骤:</span><br><span class="line"> 1.正确配置repluginPluginConfig{}</span><br><span class="line"> 2.Activity的正确继承</span><br><span class="line"> 3../gradlew :rh_login:assembleDebug</span><br><span class="line"> 4.改名为rh_login.jar</span><br><span class="line"> 5.放到宿主工程中正确的位置</span><br><span class="line"></span><br><span class="line">3.宿主跳转插件activity</span><br><span class="line"> Intent intent = RePlugin.createIntent("rh_login","com.example.LoginActivity");</span><br><span class="line"> intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);</span><br><span class="line"> RePlugin.startActivity(this,intent);</span><br><span class="line"></span><br><span class="line">4.插件化开发广播发送和接收:与普通app开发完全一样,唯一要注意的是数据的传递</span><br><span class="line"></span><br><span class="line">5.插件间AIDL接口通讯:</span><br><span class="line"> 1.AIDL接口中本身注意的一些事项</span><br><span class="line"> 2.AIDL接口实现在对应的插件application中注册</span><br><span class="line"> 3.通过RePlugin.fetchBinde获取对象去使用</span><br><span class="line"></span><br><span class="line">6.插件中启动前台services?RePlugin2.3.3版本还不支持,后台service正常,未来会提供</span><br><span class="line"></span><br><span class="line">7.插件间activity跳转不支持转场动画</span><br><span class="line"></span><br><span class="line">8.插件间fragment调用,直接通过RePlugin查找会报ClassCastException</span><br><span class="line">原因:不同classloader加载同一份类字节码,还是不同的class,所以他们的实例无法强转</span><br><span class="line">解决:通过compileOnly欺骗编译器,最总都使用宿主工程引入的类</span><br><span class="line"></span><br><span class="line">9.插件间无法去直接对外暴露View</span><br></pre></td></tr></table></figure>]]></content>
<summary type="html">
<h3 id="1-概念及技术分析"><a href="#1-概念及技术分析" class="headerlink" title="1.概念及技术分析"></a>1.概念及技术分析</h3><figure class="highlight plain"><table><tr><t
</summary>
<category term="移动端" scheme="http://example.com/categories/%E7%A7%BB%E5%8A%A8%E7%AB%AF/"/>
<category term="Android" scheme="http://example.com/tags/Android/"/>
</entry>
<entry>
<title>Moudle library中添加aar</title>
<link href="http://example.com/2021/03/13/Moudle%20library%E4%B8%AD%E6%B7%BB%E5%8A%A0aar/"/>
<id>http://example.com/2021/03/13/Moudle library中添加aar/</id>
<published>2021-03-13T06:29:00.000Z</published>
<updated>2021-05-14T09:06:25.696Z</updated>
<content type="html"><![CDATA[<p>1.所在模块的build.gradle文件中<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">android {</span><br><span class="line"> repositories {</span><br><span class="line"> flatDir {</span><br><span class="line"> dirs 'libs'</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">dependencies {</span><br><span class="line"> implementation(name: 'lfilepickerlibrary-release', ext: 'aar')</span><br><span class="line">}</span><br></pre></td></tr></table></figure></p><p>2.多个模块引用时,项目的根build.gradle中统一添加<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">allprojects {</span><br><span class="line"> repositories {</span><br><span class="line"> google()</span><br><span class="line"> jcenter()</span><br><span class="line"> maven { url "https://jitpack.io" }</span><br><span class="line"> flatDir {</span><br><span class="line"> dirs '../dr_home/libs'</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure></p>]]></content>
<summary type="html">
<p>1.所在模块的build.gradle文件中<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="
</summary>
<category term="移动端" scheme="http://example.com/categories/%E7%A7%BB%E5%8A%A8%E7%AB%AF/"/>
<category term="Android" scheme="http://example.com/tags/Android/"/>
</entry>
<entry>
<title>ButterKnife在lib中R2方式使用及配置</title>
<link href="http://example.com/2021/03/08/ButterKnife%E5%9C%A8lib%E4%B8%ADR2%E6%96%B9%E5%BC%8F%E4%BD%BF%E7%94%A8%E5%8F%8A%E9%85%8D%E7%BD%AE/"/>
<id>http://example.com/2021/03/08/ButterKnife在lib中R2方式使用及配置/</id>
<published>2021-03-08T11:02:00.000Z</published>
<updated>2021-05-14T09:03:53.903Z</updated>
<content type="html"><![CDATA[<p>配置ButterKnife</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">1.在全局的build.gradle中dependencies配置如下代码</span><br><span class="line"> classpath 'com.jakewharton:butterknife-gradle-plugin:*.*.*'</span><br><span class="line"></span><br><span class="line">2.在lib build.gradle头部中添加如下代码:</span><br><span class="line">apply plugin: 'com.jakewharton.butterknife'</span><br><span class="line"></span><br><span class="line">3.在lib build.gradle 中添加如下依赖,版本根据自己依赖而定,不是唯一</span><br><span class="line"> compile 'com.jakewharton:butterknife:*.*.*'</span><br><span class="line"> annotationProcessor 'com.jakewharton:butterknife-compiler:*.*.*'</span><br><span class="line"></span><br><span class="line">4.在lib中是使用ButterKnife ,手动把@bind中的R改成R2,这时候会报红,我们进行rebuild即 可。</span><br></pre></td></tr></table></figure><p>注意点:library中switch-case的使用,在library中是不能使用switch- case 找id的,解决方法就是用if-else代替。</p><p><img src="https://upload-images.jianshu.io/upload_images/6335486-8d2edabe194ba552.png?imageMogr2/auto-orient/strip|imageView2/2/w/378/format/webp" alt="image"></p><p>使用switch-case会报错。<br>使用if-else还有一点注意。如图</p><p><img src="https://upload-images.jianshu.io/upload_images/6335486-6b52caacc75d79ee.png?imageMogr2/auto-orient/strip|imageView2/2/w/425/format/webp" alt="image"></p><p>使用体验:不推荐使用butterknife</p>]]></content>
<summary type="html">
<p>配置ButterKnife</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2<
</summary>
<category term="移动端" scheme="http://example.com/categories/%E7%A7%BB%E5%8A%A8%E7%AB%AF/"/>
<category term="Android" scheme="http://example.com/tags/Android/"/>
</entry>
<entry>
<title>Android特殊文字,形式</title>
<link href="http://example.com/2021/03/08/Android%E7%89%B9%E6%AE%8A%E6%96%87%E5%AD%97%EF%BC%8C%E5%BD%A2%E5%BC%8F/"/>
<id>http://example.com/2021/03/08/Android特殊文字,形式/</id>
<published>2021-03-08T07:00:00.000Z</published>
<updated>2021-05-14T09:03:44.559Z</updated>
<content type="html"><![CDATA[<p>1.同一个字符串不同字体、颜色,SpannableString</p><p>2.自适应字体大小和文本宽度<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">android:autoSizeMaxTextSize="80dp"</span><br><span class="line">android:autoSizeMinTextSize="2dp"</span><br><span class="line">android:autoSizeTextType="uniform"</span><br></pre></td></tr></table></figure></p>]]></content>
<summary type="html">
<p>1.同一个字符串不同字体、颜色,SpannableString</p>
<p>2.自适应字体大小和文本宽度<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="
</summary>
<category term="移动端" scheme="http://example.com/categories/%E7%A7%BB%E5%8A%A8%E7%AB%AF/"/>
<category term="Android" scheme="http://example.com/tags/Android/"/>
</entry>
<entry>
<title>String特殊引用类型</title>
<link href="http://example.com/2021/03/05/String%20%E7%89%B9%E6%AE%8A%E5%BC%95%E7%94%A8%E7%B1%BB%E5%9E%8B/"/>
<id>http://example.com/2021/03/05/String 特殊引用类型/</id>
<published>2021-03-05T03:25:00.000Z</published>
<updated>2021-05-14T09:07:45.264Z</updated>
<content type="html"><![CDATA[<p>String为值类型还是引用类型?</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">//值类型</span><br><span class="line">int a = 1;</span><br><span class="line">int b = a;</span><br><span class="line">a = 2;</span><br><span class="line">Console.WriteLine("a is {0},b is {1}", a, b);</span><br><span class="line"></span><br><span class="line">//字符串</span><br><span class="line">string str1 = "ab";</span><br><span class="line">string str2 = str1;</span><br><span class="line">str1 = "abc";</span><br><span class="line">Console.WriteLine("str1 is {0},str2 is {1}", str1, str2);</span><br><span class="line"></span><br><span class="line">输出结果:</span><br><span class="line">//a is 2,b is 1</span><br><span class="line">//str1 is abc,str2 is ab</span><br><span class="line">str2依然是ab,并没有随str1的改变而改变。</span><br><span class="line"></span><br><span class="line">如果string是引用类型,按理Str1和Str指针都指向同一内存地址,如果Str的内容发生改变,Str1应该也会相应变化。</span><br><span class="line"></span><br><span class="line">此例子,看着string更像是值类型。</span><br></pre></td></tr></table></figure><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">引用类型例子:</span><br><span class="line"></span><br><span class="line">String aa = new String("AA");这样定义,aa就是一个引用</span><br><span class="line">StringBuilder strb2 = new StringBuilder("BB");</span><br></pre></td></tr></table></figure><p>结论:</p><p>String是引用类型,只是编译器对其做了特殊处理。</p>]]></content>
<summary type="html">
<p>String为值类型还是引用类型?</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line
</summary>
<category term="移动端" scheme="http://example.com/categories/%E7%A7%BB%E5%8A%A8%E7%AB%AF/"/>
<category term="Java" scheme="http://example.com/tags/Java/"/>
</entry>
<entry>
<title>Android生成aar包时,引用的其它aar无法打包问题</title>
<link href="http://example.com/2021/03/03/aar%E5%86%8D%E6%89%93%E5%8C%85aar/"/>
<id>http://example.com/2021/03/03/aar再打包aar/</id>
<published>2021-03-03T08:50:00.000Z</published>
<updated>2021-05-14T09:02:46.767Z</updated>
<content type="html"><![CDATA[<p>Add snippet below to your root build script file:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">buildscript {</span><br><span class="line"> repositories {</span><br><span class="line"> jcenter()</span><br><span class="line"> }</span><br><span class="line"> dependencies {</span><br><span class="line"> classpath 'com.kezong:fat-aar:1.3.4'</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure></p><p>Add snippet below to the build.gradle of your android library:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">apply plugin: 'com.kezong.fat-aar'</span><br></pre></td></tr></table></figure></p><p>Step 2: Embed dependencies<br>Declare embed for the dependencies you want to merge in build.gradle.</p><p>The usage is similar to implementation, like this:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">dependencies {</span><br><span class="line"> implementation fileTree(dir: 'libs', include: '*.jar')</span><br><span class="line"> // java dependency</span><br><span class="line"> embed project(':lib-java')</span><br><span class="line"> // aar dependency</span><br><span class="line"> embed project(':lib-aar')</span><br><span class="line"> // aar dependency</span><br><span class="line"> embed project(':lib-aar2')</span><br><span class="line"> // local full aar dependency, just build in flavor1</span><br><span class="line"> flavor1Embed project(':lib-aar-local')</span><br><span class="line"> // local full aar dependency, just build in debug</span><br><span class="line"> debugEmbed (name:'lib-aar-local2', ext:'aar')</span><br><span class="line"> // remote jar dependency</span><br><span class="line"> embed 'com.google.guava:guava:20.0'</span><br><span class="line"> // remote aar dependency</span><br><span class="line"> embed 'com.facebook.fresco:fresco:1.11.0'</span><br><span class="line"> // don't want to embed in</span><br><span class="line"> implementation('androidx.appcompat:appcompat:1.2.0')</span><br><span class="line">}</span><br></pre></td></tr></table></figure></p><p>地址:<a href="https://github.com/kezong/fat-aar-android" target="_blank" rel="noopener">https://github.com/kezong/fat-aar-android</a></p>]]></content>
<summary type="html">
<p>Add snippet below to your root build script file:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line
</summary>
<category term="移动端" scheme="http://example.com/categories/%E7%A7%BB%E5%8A%A8%E7%AB%AF/"/>
<category term="Android" scheme="http://example.com/tags/Android/"/>
</entry>
<entry>
<title>Android共享文件(FileProvider)</title>
<link href="http://example.com/2021/01/18/Android%E5%85%B1%E4%BA%AB%E6%96%87%E4%BB%B6%EF%BC%88FileProvider%EF%BC%89/"/>
<id>http://example.com/2021/01/18/Android共享文件(FileProvider)/</id>
<published>2021-01-18T08:04:08.000Z</published>
<updated>2021-05-14T09:03:36.623Z</updated>
<content type="html"><![CDATA[<p>说明:android 7.0以后需要使用FileProvider配置访问路径</p><p>1.添加 FileProvider 到 AndroidManifest.xml<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"> <!-- FileProvider配置访问路径,适配7.0及其以上 --></span><br><span class="line"> <provider</span><br><span class="line"> android:name="androidx.core.content.FileProvider"</span><br><span class="line"> android:authorities="${applicationId}.provider"</span><br><span class="line"> android:grantUriPermissions="true"</span><br><span class="line"> android:exported="false"></span><br><span class="line"> <meta-data</span><br><span class="line"> android:name="android.support.FILE_PROVIDER_PATHS"</span><br><span class="line"> android:resource="@xml/file_path"/></span><br><span class="line"> </provider></span><br><span class="line"></span><br><span class="line"></application></span><br></pre></td></tr></table></figure></p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><!--@xml/file_path--></span><br><span class="line"><resources></span><br><span class="line"> <paths></span><br><span class="line"> <external-path</span><br><span class="line"> path=""</span><br><span class="line"> name="Export"/></span><br><span class="line"> </paths></span><br><span class="line"></resources></span><br></pre></td></tr></table></figure><p>2.分享<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * 文件分享</span><br><span class="line"> */</span><br><span class="line"> protected void fileShare(String filePath) {</span><br><span class="line"> Intent shareIntent = new Intent(Intent.ACTION_SEND);</span><br><span class="line"> shareIntent.setType("*/*");</span><br><span class="line"> File file = new File(filePath);</span><br><span class="line"> if (file.exists()) {</span><br><span class="line"> shareIntent.putExtra(Intent.EXTRA_STREAM, getFileUri(this, file));</span><br><span class="line"> }</span><br><span class="line"> shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);</span><br><span class="line"> //设置分享列表的标题,并且每次都显示分享列表</span><br><span class="line"> startActivity(Intent.createChooser(shareIntent, "分享到"));</span><br><span class="line"> }</span><br><span class="line"></span><br><span class="line">/*根据不同android版本使用不同的方式*/</span><br><span class="line"> private Uri getFileUri(Context context, File file) {</span><br><span class="line"> Uri uri;</span><br><span class="line"> // 低版本直接用 Uri.fromFile</span><br><span class="line"> if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {</span><br><span class="line"> uri = Uri.fromFile(file);</span><br><span class="line"> } else {</span><br><span class="line"> //使用 FileProvider 会在某些 app 下不支持(在使用FileProvider 方式情况下QQ不能支持图片、视频分享,微信不支持视频分享)</span><br><span class="line"> uri = FileProvider.getUriForFile(context, context.getPackageName() + ".provider", file);</span><br><span class="line"> }</span><br><span class="line"> return uri;</span><br><span class="line"> }</span><br></pre></td></tr></table></figure></p><p>注意: android:authorities和FileProvider.getUriForFile的content是一致的。</p>]]></content>
<summary type="html">
<p>说明:android 7.0以后需要使用FileProvider配置访问路径</p>
<p>1.添加 FileProvider 到 AndroidManifest.xml<br><figure class="highlight plain"><table><tr><td c
</summary>
<category term="移动端" scheme="http://example.com/categories/%E7%A7%BB%E5%8A%A8%E7%AB%AF/"/>
<category term="Android" scheme="http://example.com/tags/Android/"/>
</entry>
<entry>
<title>ADB 网络调试(可解决逍遥模拟器连接问题)</title>
<link href="http://example.com/2020/11/11/ADB%20%E7%BD%91%E7%BB%9C%E8%B0%83%E8%AF%95%EF%BC%88%E5%8F%AF%E8%A7%A3%E5%86%B3%E9%80%8D%E9%81%A5%E6%A8%A1%E6%8B%9F%E5%99%A8%E8%BF%9E%E6%8E%A5%E9%97%AE%E9%A2%98)/"/>
<id>http://example.com/2020/11/11/ADB 网络调试(可解决逍遥模拟器连接问题)/</id>
<published>2020-11-11T02:56:08.000Z</published>
<updated>2021-04-14T08:41:17.141Z</updated>
<content type="html"><![CDATA[<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">1.数据线连接手机到电脑(确保手机打开了USB调试功能,逍遥模拟器需要连接成功一次)</span><br><span class="line"></span><br><span class="line">2.AS Terminal中输入命令 adb tcpip 5555 ,执行成功后可以断开数据线(确保命令行中可以调用到adb,可能需要配置环境变量)</span><br><span class="line"></span><br><span class="line">3.AS Terminal中输入命 adb connect 手机ip:5555 , 例如我的是:adb connect 172.16.55.24:5555</span><br><span class="line"></span><br><span class="line">关机开启时仍然有效(IP未变的前提下)</span><br></pre></td></tr></table></figure>]]></content>
<summary type="html">
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class
</summary>
<category term="其它" scheme="http://example.com/categories/%E5%85%B6%E5%AE%83/"/>
<category term="Android" scheme="http://example.com/tags/Android/"/>
</entry>
<entry>
<title>Retrofit + okhttp 下载问题</title>
<link href="http://example.com/2020/08/05/Retrofit%20%20%20okhttp%20%E4%B8%8B%E8%BD%BD%E9%97%AE%E9%A2%98/"/>
<id>http://example.com/2020/08/05/Retrofit okhttp 下载问题/</id>
<published>2020-08-05T09:45:00.000Z</published>
<updated>2021-05-14T09:07:34.417Z</updated>
<content type="html"><![CDATA[<h4 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h4><p> 使用retrofit,添加okhttp拦截器,平常的json返回正常,但下载文件时,文件不准确。</p><h4 id="解决"><a href="#解决" class="headerlink" title="解决"></a>解决</h4><p> 原先:return response.newBuilder()<br> .body(okhttp3.ResponseBody.create(mediaType, content))<br> .build();</p><p> 建议:直接返回chain.request()不做其它操作没有问题,不能更改return,后续会出问题。建议不打印response.body()或者暂时取消拦截器。</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">private static Interceptor MY_LOGGING_INTERCEPTOR = new Interceptor() {</span><br><span class="line"> private String TAG = "MY_LOGGING_INTERCEPTOR";</span><br><span class="line"></span><br><span class="line"> @Override</span><br><span class="line"> public okhttp3.Response intercept(Chain chain) throws IOException {</span><br><span class="line"> Request request = chain.request();</span><br><span class="line"> long t1 = System.nanoTime();</span><br><span class="line"> okhttp3.Response response = chain.proceed(chain.request());</span><br><span class="line"> long t2 = System.nanoTime();</span><br><span class="line"> okhttp3.MediaType mediaType = response.body().contentType();</span><br><span class="line"> Log.d(TAG, "intercept:返回的类型为: " + mediaType);</span><br><span class="line"> String content = response.body().string();</span><br><span class="line"> //printParams(request.body());</span><br><span class="line"> Log.d(TAG, "-----LoggingInterceptor----- :\nrequest url:" + request.url() + "\ntime:" + (t2 - t1) / 1e6d + "\nbody:" + content + "\n");</span><br><span class="line"> </span><br><span class="line"> //下载文件会有问题</span><br><span class="line"> /*return response.newBuilder()</span><br><span class="line"> .body(okhttp3.ResponseBody.create(mediaType, content))</span><br><span class="line"> .build();*/</span><br><span class="line"> }</span><br><span class="line"> </span><br><span class="line">}</span><br></pre></td></tr></table></figure>]]></content>
<summary type="html">
<h4 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h4><p> 使用retrofit,添加okhttp拦截器,平常的json返回正常,但下载文件时,文件不准确。</p>
<h4 id="解决"><a h
</summary>
<category term="移动端" scheme="http://example.com/categories/%E7%A7%BB%E5%8A%A8%E7%AB%AF/"/>
<category term="Android" scheme="http://example.com/tags/Android/"/>
</entry>
</feed>