1.Base64加密:
具体的概念以及原理,网上连篇累牍,此处不再赘述,直接上代码:
DEFAULT 这个参数是默认,使用默认的方法来加密
NO_PADDING 这个参数是略去加密字符串最后的”=”
NO_WRAP 这个参数意思是略去所有的换行符(设置后CRLF就没用了)
CRLF 这个参数看起来比较眼熟,它就是Win风格的换行符,意思就是使用CR LF这一对作为一行的结尾而不是Unix风格的LF
URL_SAFE 这个参数意思是加密时不使用对URL和文件名有特殊意义的字符来作为加密字符,具体就是以-和_取代+和/
public class Base64Util {
public static String encode(String str){
// 在这里使用的是encode方式,返回的是byte类型加密数据,可使用new String转为String类型
String strBase64 = new String(Base64.encodeToString(str.getBytes(), Base64.NO_WRAP));//Base64的几种加密类型及效果各有不同需特别注意
return strBase64;
}
public static String decode(String str){
// 对base64加密后的数据进行解密
String str2 = new String(Base64.decode(str.getBytes(), Base64.NO_WRAP));
return str2;
}
}
2.百度地图在DialogActivity中变暗的问题
解决方法:
将xml布局中的com.baidu.map.MapView 替换为 com.baidu.map.TextureMapView 即可
使用上与原来的com.baidu.map.MapView并无二致
<com.baidu.mapapi.map.TextureMapView
android:id="@+id/bmapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true" />
3.沉浸式与输入框的冲突
(1)输入框弹出时会把标题栏上的文字向上顶 解决方法:在manifest的activity标签 配置
``` android:windowSoftInputMode="adjustPan" ```
即可
(2)输入框弹出时 提交按钮会被遮住 若希望按钮能被顶上去 方便用户操作 可以修改当前页面的沉浸式的实现方式:
具体的操作与配置,请参见此文章:
Android沉浸式状态栏SystemBarTint的使用方法