不知道为什么保存文件后之前打开一直都OK,就突然打开看到变成乱码了,最后解决了关键:outStream.write(finalContent.getBytes("gbk"));write的时候设置一下:转换格式(UFT-8在android不能用,只能用gbk)!!!我之前试过utf-8,还是乱码,没什么用,就是gbk!从项目里面抽取了这个把String保存为txt到本地的方法:String sdCardDir =Environment.getExternalStorageDirectory().getAbsolutePath();File saveFile = new File(sd...
Android中进度条控件有3个(不算ProgressDialog),分别是ProgressBar,SeekBar和RatingBar,对于自定义样式来说又得按照需求分为2中情况,第一种是刻度型,第二种是循环类型。第一种是“刻度型”,也就是他有起点和终点,起点值小于终点值这种样式的修改,要修改三个属性即可分别是:背景(主要是进度的轨道样式),第一级别滚动条progressDrawable,第二级别progressDrawable遗憾的是Android提供的api很难设置,不过可以通过Laye...
一些需求需要获取运营商和网络类型,下面对运营商和网络类型做分析。先抛出一些废话的定义:GSM:全球移动通讯系统Global System of Mobile communication就是众所周知的GSM,是当前应用最为广泛的移动电话标准。CDMA:码分多址(CDMA)是在数字技术的分支--扩频通信技术上发展起来的一种崭新而成熟的无线通信技术。可见,这两者是技术标准,和网络类型及制式无关。进入正题。1.获取话机类型这个可以通过方法TelephonyManager#getPho...
今天弄了个全局变量AppContext ,但一直出现例如以下错误,原来继承 Application的得在清单文件声明。
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.langteng.shiliao/com.langteng.shiliao.activity.MainActivity}: java.lang.ClassCastException: android.app.Application cannot be cast to com.langteng.shiliao.until.AppContext
public class AppContext extends Application {
public stat...
/** TextUtils.isEmpty() 方法的实现
* Returns true if the string is null or 0-length.
* @param str the string to be examined
* @return true if str is null or zero length
*/publicstaticboolean isEmpty(@Nullable CharSequence str) {if (str == null || str.length() == 0)returntrue;elsereturnfalse;}int的默认值为0, Integer的默认值为null:Java为每个原始类型提供了封装类,Integer是java为int提供的封装类。int的...
//实体beanpackage org.mo.common.util.entity;import java.util.Date;import android.os.Parcel;
import android.os.Parcelable;/**
*
* @author moziqi
*
*/
public class BeanDemo implements Parcelable {private Integer id;private String name;private Date createTime;public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getName() {return name;}public void setName...
在Android系统中,进程间传递的数据包括Java语言支持的基本数据类型和用户自定义的数据类型,为了使数据能够穿越进程边界,所有数据都必须是“可打包”。对于Java语言的基本数据类型,打包过程是自动完成的。但对于自定义的数据类型,用户需要实现Parcelable接口,使自定义的数据类型能够转换为系统级原语保存在Parcel对象中,穿越进程边界后可再转换为初始格式。AIDL支持的数据类型如下表:类型说明需要引入基本数据类型boolean、...
使用device.js检测设备并实现不同设备展示不同网页html代码:<!doctype html><html><head><meta charset="utf-8"><title></title><script src="device.js"></script></head><body style="margin: auto; position: absolute; width:100%; height: 100%"><script>var isMobile = device.mobile(), isIos = device.ios(),isAndroid = device.android();if(isMobile){alert("手机");}else{alert("pc");}if(isIos){alert("ios");}if(is...
1、ConnectionConfiguration作为用于与XMPP服务建立连接的配置。它能配置;连接是否使用TLS,SASL加密。包含内嵌类:ConnectionConfiguration.SecurityMode2、XMPPConnectionXMPPConnection这个类用来连接XMPP服务.可以使用connect()方法建立与服务器的连接。disconnect()方法断开与服务器的连接. 在创建连接前可以使用XMPPConnection.DEBUG_ENABLED = true; 使开发过程中可以弹出一个GUI窗口,用于显示我们的连接与发送Packet的信...
曾经老用findViewById,每次使用还得add cast一下今天看到一个视频(依据视频中使用的IDE判断,应该是几年前的视频了..),使用了一个方法,能够不用每次使用findViewById都去add cast.我依据视频中的写法进行优化,详细做法:创建一个BaseActivity,让它继承Activity,在当中加入例如以下方法:// 由于是findView所以泛型类型应该继承Viewprotected <T extends View> T genericFindViewById(int id) {//return返回view时,加上泛型Tre...
Android For JNI(二)——C语言中的数据类型,输出,输入函数以及操作内存地址,内存修改器当我们把Hello World写完之后,我们就可以迈入C的大门了,今天就来讲讲基本的一些数据类型,函数之内的我们先来看一张传播久远的图片‘一.各种数据类型介绍整型整形包括短整型、整形和长整形。短整形short a=1;整形一般占4个字节(32位),最高位代表符号,0表示正数,1表示负数,取值范围是-2147483648~2147483647,在内存中的存储顺序是地...
Java代码 /** * 打开文件 * @param file */ private void openFile(File file){ Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //设置intent的Action属性 intent.setAction(Intent.ACTION_VIEW); //获取文件file的MIME类型 String type = getMIMEType(file); //设置intent的data和Type属性。 intent.setDataAndType(/*uri*/Uri.fromFile(file), type); ...
我已经使用jax-ws创建了简单的Web服务.我需要在android中使用该webservice.当我使用该Web服务时,出现此错误 org.xmlpull.v1.XmlPullParserException:意外类型(位置:END_DOCUMENT null @ 1:1,在java.io.InputStreamReader@40d310f0中)
我的wsdl代码:<definitions targetNamespace="http://sample.jaxws.ws.blog.accrd.com/" name="SimpleWebServiceService">
<types>
<xsd:schema>
<xsd:import namespace="http://sample.jaxws....
我使用Picasso作为我的App项目和聊天库的依赖项
这是编译代码时我遇到的错误:Program type already present: org.apache.http.auth.AuthSchemeFactoryMessage{kind=ERROR, text=Program type already present:
org.apache.http.auth.AuthSchemeFactory, sources=[Unknown source file], tool name=Optional.of(D8)}那么如何对两个项目使用相同的依赖?---- Root project---- ||---app|---chat library编辑周六 – 2018年4月14日...
强制转换 和 变量类型判断<?php/*** 强制转换 和 变量类型判断*/$int = 1000;echo gettype($int); // 打印结果:integerecho "<br>";$str = (String)$int; // 整形转字符串echo gettype($int); // 打印结果:integerecho "<br>";echo gettype($str); // 打印结果:stringecho "<br>";$int2 = intval($str); // 字符串转整形echo gettype($int2); // 打印结果:stringecho "<br>";$int3 = (int)($str); // 字符串转整形echo gettype...