分类 技术相关 下的文章

以Chrome浏览器为例,实际上chrome内核都可以。
1.用Cordova 打包一个debug版的App(注意是debug版本的哦)
2.用USB线连接手机和电脑(电脑必须安装有手机驱动和Chrome浏览器)
3.打开手机的USB调试开关(找不到的百度自己的机型查找)
4.打开电脑上Chrome在地址栏输入"chrome://inspect"进入,如图
debuger cordova App

5.打开手机上的Cordova App,浏览器出现手机相关页面信息,点击进入
96607-lgog5zdcubf.png
6.这样就可方便的调试
 debugger cordova App

异常信息如下:

java.lang.SecurityException: getDeviceId: Neither user 10065 nor current process has android.permission.READ_PHONE_STATE.

原因:动态权限的问题
Android 6.0 (API Level 23) 及以后引入了运行时权限,安装 APP 时不再授予所有需要的权限,而是在运行的时候根据需要向用户请求权限,而且用户可以随时取消已经授予的权限。

推荐开源库:

GitHub 上有个对开源库 https://github.com/googlesamples/easypermissions 进行二次封装的开源库 https://github.com/forJrking/HeiPermission 还不错,可以尝试下。

参考链接:
http://blog.csdn.net/github_33304260/article/details/53328297
https://developer.android.com/training/permissions/requesting.html

sqlserver百分比运算

select ltrim(Convert(numeric(9,2),25*100.0/30))+'%' As 百分比
- 得到百分比小数
select Cast(Convert(numeric(9,2),25*100.0/30) as decimal(18,2)) As 百分比小数

说明

NUMERIC(P,S) P的默认值是:38 S的默认值是:-84~127
numeric(a,b)函数有两个参数,前面一个为总的位数,后面一个参数是小数点后的位数,例如numeric(5,2)是总位数为5,小数点后为2位的数,也就是说这个字段的整数位最大是3位。

java1.8可以使用stream()流的方法,如下

List<Integer> numbers = Arrays.asList(1,2,3,4,5,6,7,8,9,10);
int chunkSize = 20;   //3 ok
AtomicInteger counter = new AtomicInteger();

Collection<List<Integer>> resultList = numbers.stream()
      .collect(Collectors.groupingBy(it -> counter.getAndIncrement() / chunkSize))
      .values();

System.out.println(resultList);

使用第三方工具类的方法:

  • Google Guava has Lists.partition(List list, int size) method (docs)
  • Apache Commons Collections has ListUtils.partition(List list, int size) method (docs)

举例说明:
Check out Lists.partition(java.util.List, int) from Google Guava:
Returns consecutive sublists of a list, each of the same size (the final list may be smaller). For example, partitioning a list containing [a, b, c, d, e] with a partition size of 3 yields [[a, b, c], [d, e]] -- an outer list containing two inner lists of three and two elements, all in the original order.

免责声明
本博客部分内容来自于互联网,不代表作者的观点和立场,如若侵犯到您的权益,请联系[email protected]。我们会在24小时内进行删除。