bcoder

4月 032018
 

  对于简单的key:value的json数据,我们把所有的key定义为类成员,然后gson.fromJson即可序列化为java对象。

  对于复杂的json数据,里面既有普通的key:value数据,也有二级的列表的数据,我们该如何处理呢?

  事实上,非常的简单,我们在该类里再定义一个内部类,和一个List组织该内部类的对象即可,比如下面的json数据:

  那么我们定义的解析类如下:

  解析的时候使用如下代码即可:

  是不是非常的简单!

4月 022018
 

  使用insert or replace into语句时,当要插入的数据对应的主键已存在,则删除原来那条,新建一条数据(类似更新)。

  使用时的注意事项:

  1. 此表必须有一个主键
  2. 此主键应该是一个字符串值,如果是整数型的id类的用这个语句好像没什么意义
 Posted by on 2018-04-02

adb remount 相关

 分类:Uncategorized 阅读 (2,444)  No Responses »
3月 302018
 

1.adb remount的作用就是重新挂载安卓的系统分区,使系统分区可读写

2.执行该功能其他的方法:

adb shell su #进入安卓命令行

mount -o rw,remount /system #将文件系统remount为读写权限

记得完事后remount回只读: mount -o ro,remount /system

3.另外一种方法

adb shell su #进入安卓命令行

mount -o rw,remount -t ext3 /dev/block/mmcblk1p21 /system

 Posted by on 2018-03-30
3月 222018
 

慢慢学习了很多Linux命令

感觉还是很方便的

但是参数语法太多

实在是记不住

还是多总结记录比较好

省的再去查man,浪费时间

  • cut
  • grep
  • sort
  • uniq
  • wc
  • tee
  • tr
  • col
  • join
  • paste
  • expand
  • xargs   
  • awk
 Posted by on 2018-03-22
3月 212018
 

查看当前目前总占用空间

du -sh ./

查看当前目录下的所有文件或者子目录的占用空间

du -sh *

将目录下的文件或者子目录按从大到小排序

du -s *|sort -nr

将目录下的文件或者子目录按从大到小排序,并取前5行

du -s *|sort -nr|head -5

 Posted by on 2018-03-21

Android中获取当前时间/毫秒数

 分类:Android, Java 阅读 (4,929)  Android中获取当前时间/毫秒数已关闭评论
3月 192018
 

获取当前时间对应的毫秒数

System.currentTimeMillis()

对于某些定制设备,在开机时机器的时间可能会发生变化,这个数据就会有比较大的跳跃,比如开机时对应的日期是0(1970-1-1),某些系统服务启动后会变成当前实际时间2018-03-01,这个函数返回的值就会有个大的变化

获取开机以来的毫秒数,是开机以来的绝对时间

SystemClock.elapsedRealtime()

获取开机以来非休眠状态的毫秒数

SystemClock.uptimeMillis()

 Posted by on 2018-03-19
3月 062018
 

本文运行环境,数据库:Mysql,操作系统:Linux
在命令行中查询sql语句后,一般情况下每行显示一条记录,一条记录有多个列,假如某一列的数据特别长,这种表格的方式就很难查看数据,如果想让所有的列都分行显示,每行显示一列的数据也很简单,就是在sql查询语句的末尾加一个 \G就可以了.

如下:select * from tbldates\G;

显示效果如下:

 

 Posted by on 2018-03-06
2月 202018
 

 具体请看下面的表格:

♠ frameworks/base/core/java/android/app/ActivityManagerNative.java

§ ActivityManagerNative.getDefault() 很简单,获取gDefault
§ gDefault 一个静态变量,是ActivityManagerService 的代理对象

♠ frameworks/base/services/java/com/android/server/am/ActivityManagerService.java

ActivityRecord.isInStackLocked(token); 查询当前Activity是否还在Activity栈中?
如果还在继续执行Binder.clearCallingIdentity();保存此Activity在Binder中的id,稍候就会使用overridePendingAppTransition执行恢复的操作。
如果当前Activity的状态是活动状态或者将要暂停状态,执行WindowManagerService的overridePendingAppTransition

♠ frameworks/base/services/java/com/android/server/wm/WindowManagerService.java

调用AppTransition的overridePendingAppTransition方法(将动画的设置信息都放在AppTransition中了)
然后WindowManagerService在进行Activity切换的时候就会根据AppTransition的动画设置来显示切换动画了。

 

总结:

1. 执行overridePendingTransition时的调用顺序ActivityManageService->WindowManageService

2. 最终设置的是WindowManagerService的overridePendingAppTransition

3. 和Windows编程中显示模式窗口不同,执行startActivity时并没有立即暂停当前Activity,而是通过Handler在下一个MessageQueue的处理中暂停的当前Activity

 Posted by on 2018-02-20

MonkeyDevice

 分类:Android, Java 阅读 (1,547)  No Responses »
1月 302018
 

  MonkeyDevice用于控制安卓设备或者安卓模拟器,发送UI事件、发送广播、获取设备信息、安装删除应用和运行应用等。

  一般情况下使用MonkeyRunner.waitForConnection()可获取此类的实例,如下:

  下面是MonkeyDevice提供的一些方法列表:

Methods 描述 描述
void broadcastIntent (string uri, string action, string data, string mimetype, iterable categories dictionary extras, component component, iterable flags)

Broadcasts an Intent to this device, as if the Intent were coming from an application.

描述
void drag (tuple start, tuple end, float duration, integer steps)

Simulates a drag gesture (touch, hold, and move) on this device’s screen.

描述
object getProperty (string key)

Given the name of a system environment variable, returns its value for this device. The available variable names are listed in the detailed description of this method.

描述
object getSystemProperty (string key)

. The API equivalent of adb shell getprop <key>. This is provided for use by platform developers.

描述
void installPackage (string path)

Installs the Android application or test package contained in packageFile onto this device. If the application or test package is already installed, it is replaced.

描述
dictionary instrument (string className, dictionary args)

Runs the specified component under Android instrumentation, and returns the results in a dictionary whose exact format is dictated by the component being run. The component must already be present on this device.

描述
void press (string name, dictionary type)

Sends the key event specified by type to the key specified by keycode.

描述
void reboot (string into)

Reboots this device into the bootloader specified by bootloadType.

void removePackage (string package)

Deletes the specified package from this device, including its data and cache.

描述
object shell (string cmd)

Executes an adb shell command and returns the result, if any.

描述
void startActivity (string uri, string action, string data, string mimetype, iterable categories dictionary extras, component component, flags)

Starts an Activity on this device by sending an Intent constructed from the supplied arguments.

描述
MonkeyImage takeSnapshot()

Captures the entire screen buffer of this device, yielding a MonkeyImage object containing a screen capture of the current display.
描述
void touch (integer x, integer y, integer type)

Sends a touch event specified by type to the screen location specified by x and y.

描述
void type (string message)

Sends the characters contained in message to this device, as if they had been typed on the device’s keyboard. This is equivalent to callingpress() for each keycode in message using the key event type DOWN_AND_UP.

描述
void wake ()

Wakes the screen of this device.

描述