当前位置:首页 > 代码 > 正文

安卓客户端代码(安卓应用开发代码)

admin 发布:2022-12-19 20:03 143


今天给各位分享安卓客户端代码的知识,其中也会对安卓应用开发代码进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

怎样查看 Android APP 源代码

用压缩软件打开apk文件,解压出根目录中的classes.dex文件

使用cmd ,dex2jar.bat classes.dex命令将classes.dex转换为jar

再用jd-gui打开该jar就可以查看源码了,如果apk安全性好的话,有些代码是看不到的

android程序中 客户端如何用pull 读取远程服务器上的xml文件? 请给出代码。谢谢。

可以用 httpclient get到这个xml

然后把这个流交给pull解析器解析就完了

//获取xml文件流

URL url = new URL("");

HttpURLConnection conn = (HttpURLConnection) url.openConnection();

conn.setConnectTimeout(5* 1000);//设置连接超时

conn.setRequestMethod(“GET”);//以get方式发起请求

if (conn.getResponseCode() != 200) throw new RuntimeException("请求url失败");

InputStream is = conn.getInputStream();//得到网络返回的输入流

conn.disconnect();

//解析xml

ListPerson persons = readXML(is);

public static ListPerson readXML(InputStream inStream) {

XmlPullParser parser = Xml.newPullParser();

try {

parser.setInput(inStream, "UTF-8");

int eventType = parser.getEventType();

Person currentPerson = null;

ListPerson persons = null;

while (eventType != XmlPullParser.END_DOCUMENT) {

switch (eventType) {

case XmlPullParser.START_DOCUMENT://文档开始事件,可以进行数据初始化处理

persons = new ArrayListPerson();

break;

case XmlPullParser.START_TAG://开始元素事件

String name = parser.getName();

if (name.equalsIgnoreCase("person")) {

currentPerson = new Person();

currentPerson.setId(new Integer(parser.getAttributeValue(null, "id")));

} else if (currentPerson != null) {

if (name.equalsIgnoreCase("name")) {

currentPerson.setName(parser.nextText());// 如果后面是Text节点,即返回它的值

} else if (name.equalsIgnoreCase("age")) {

currentPerson.setAge(new Short(parser.nextText()));

}

}

break;

case XmlPullParser.END_TAG://结束元素事件

if (parser.getName().equalsIgnoreCase("person") currentPerson != null) {

persons.add(currentPerson);

currentPerson = null;

}

break;

}

eventType = parser.next();

}

inStream.close();

return persons;

} catch (Exception e) {

e.printStackTrace();

}

return null;

}

}

求助android客户端传回的汉字参数,在服务器端出现乱码

android,遇到从android客户端向服务器端发送汉字乱码问题。采用URLConnection的GET方式,在客户端和服

务端都需要进行转码,而采用POST方式则不需要转码。具体方法如下:

用URLConnection从android发送数据有两种方式:

第一种方式:采用get方式传值

  (1)客户端代码:

   URL url = new URL(mUrl);

  URLConnection urlConnection = url.openConnection();

   InputStream is = urlConnection.getInputStream();

  ByteArrayBuffer baf = new ByteArrayBuffer(50);

int current = 0;

while ((current = is.read()) != -1) {

    baf.append((byte) current);

}

requestInfo = new String(baf.toByteArray(), "UTF-8").trim();

  is.close();

 

  对汉字进行处理:

  URLEncoder.encode(URLEncoder.encode(channelName, "UTF-8"), "UTF-8")

(2)服务器端接收字段:

URLDecoder.decode(URLDecoder.decode(request.getParameter("nickname"), "UTF-8"), "UTF-8")

 

第二种方式:采用Post方式:

    客户端代码:

  public String sendRemoteRequest(String path,String param){

  Log.i("lisheng", param.toString());

  Log.i("lisheng", path);

String strRes="";

OutputStream os = null;

  DataOutputStream dos = null;

  InputStream is = null;

 BufferedReader br = null;

    try {

  URL url = new URL(path);

  URLConnection urlConn = url.openConnection();

 urlConn.setDoInput(true);

urlConn.setDoOutput(true);

   os = urlConn.getOutputStream();

   dos = new DataOutputStream(os);

    dos.write(param.getBytes());

 dos.flush();

 dos.close();

   os.close();

is = urlConn.getInputStream();

  br = new BufferedReader(new InputStreamReader(is,"UTF-8"));

for (String strLine = ""; (strLine = br.readLine()) != null;)

strRes = (new StringBuilder(String.valueOf(strRes))).append(strLine).toString();

  is.close();

 } catch (MalformedURLException e) {

  e.printStackTrace();

   } catch (UnsupportedEncodingException e) {

   e.printStackTrace();

 } catch (IOException e) {

e.printStackTrace();

}

  return strRes;

}

参数里直接写汉字

 

服务器端代码:

 

 request.setCharacterEncoding("UTF-8");

 request.getParameter("nickname")

 

 即可得到参数为汉字的值,不需要转码。

工行手机银行wap安卓客户端登陆不成功。 错误代码:96301025

我跟你的问题一模一样,我用的是HTC G13

上个月找工行客服,一个月后终于解决这个问题了,现在能正常用

HTC是可以用的,问题出在手机号上

如果没猜错,你的手机好应该是新号,或者是企业特殊号码

我的手机号是西安移动的保留号码,字段比较特殊,这个问题找客服,让他登记问题,然后上报

估计一个月内能解决

如果你不着急的话,就用95588将就用一下

安卓客户端代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于安卓应用开发代码、安卓客户端代码的信息别忘了在本站进行查找喔。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/21970.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载