当前位置: 首页 > news >正文

广州做内销鞋的网站wordpress网站amp

广州做内销鞋的网站,wordpress网站amp,创意设计作品赏析,工会网站建设最近用xposed进行hook回发的时候#xff0c;又出现了新的问题#xff1b; android.os.NetworkOnMainThreadException#xff1b; 在Android4.0以后#xff0c;写在主线程#xff08;就是Activity#xff09;中的HTTP请求#xff0c;运行时都会报错#xff0c;这是因为…最近用xposed进行hook回发的时候又出现了新的问题 android.os.NetworkOnMainThreadException 在Android4.0以后写在主线程就是Activity中的HTTP请求运行时都会报错这是因为Android在4.0以后为了防止应用的ANRAplication Not Response异常Android这个设计是为了防止网络请求时间过长而导致界面假死的情况发生。 我尝试了网上的第一种解决方法 1.在Activity的onCreate()方法中加入代码 if (android.os.Build.VERSION.SDK_INT 9) {StrictMode.ThreadPolicy policy new StrictMode.ThreadPolicy.Builder().permitAll().build();StrictMode.setThreadPolicy(policy);}仍然出现了 这种问题报错未解决 2. 尝试启动子线程进行网络请求 new Thread(new Runnable(){Overridepublic void run() {//请求详情}).start(); 以下是之前的方案直接调用 new HttpHello(); https://codeooo.blog.csdn.net/article/details/126099666 package com.sun.dyCapture;import android.os.Bundle;import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; import java.util.List; import java.util.Set;import cz.msebera.android.httpclient.NameValuePair; import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; import cz.msebera.android.httpclient.client.methods.CloseableHttpResponse; import cz.msebera.android.httpclient.client.methods.HttpPost; import cz.msebera.android.httpclient.impl.client.CloseableHttpClient; import cz.msebera.android.httpclient.impl.client.HttpClients; import cz.msebera.android.httpclient.message.BasicNameValuePair; import cz.msebera.android.httpclient.util.EntityUtils;public class HttpHello {public static JSONObject Build2Json(Bundle bundle) throws Exception {JSONObject json new JSONObject();SetString keys bundle.keySet();for (String key : keys) {try {// json.put(key, bundle.get(key)); see edit belowjson.put(key, JSONObject.wrap(bundle.get(key)));} catch (JSONException e) {//Handle exception here}}return json;}public void sendRequestWithHttpConnection(String result) throws Exception {// 创建Httpclient对象172CloseableHttpClient httpclient HttpClients.createDefault();// 创建http POST请求HttpPost httpPost new HttpPost(ip:端口/Cookie);// 设置2个post参数ListNameValuePair parameters new ArrayListNameValuePair(0);parameters.add(new BasicNameValuePair(result, result));// 构造一个form表单式的实体UrlEncodedFormEntity formEntity new UrlEncodedFormEntity(parameters);// 将请求实体设置到httpPost对象中httpPost.setEntity(formEntity);//伪装浏览器httpPost.setHeader(User-Agent, Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36);try (CloseableHttpResponse response httpclient.execute(httpPost)) {// 执行请求// 判断返回状态是否为200if (response.getStatusLine().getStatusCode() 200) {String content EntityUtils.toString(response.getEntity(), UTF-8);System.out.println(内容 content);} elseSystem.out.println(内容错误 response.getStatusLine().getStatusCode());}httpclient.close();}HttpHello(final String result){//开启线程发起网络连接new Thread(new Runnable(){public void run(){try {sendRequestWithHttpConnection(result);} catch (Exception e) {e.printStackTrace();}}}).start();}}
http://www.hkea.cn/news/14449876/

相关文章:

  • 威海外贸网站建设联系方式宜春网站制作公司
  • dw个人网站主页怎么做做ae好的网站有哪些
  • 描述网站开发的广告词小程序开发公司米云
  • qq群推广引流免费网站建设工程信息网官网新网站
  • app制作简易网站建e网3d模型库
  • 用php做网站和go做网站设计欣赏心得体会
  • 酒类销售公司的网站建设家具东莞网站建设
  • 企业网站源码打包怎样做省钱购物网站
  • 做衣服接订单的网站怎么看网站开发的技术
  • 网站排名快速提升工具阜南网站建设公司
  • 金华网站建设公司网页传奇游戏如何0血打不死
  • 创意福州网站建设百度极简网址
  • 车陂手机网站开发公司要做个网站吗
  • 扬州企业网站建设网站是用什么程序做的
  • 石家庄市制作网站公司品牌设计师
  • 向公司申请建设网站申请书效果图怎么做出来的
  • 科技公司网站设计服务只做男士衬衫的网站
  • 网站可能存在什么问题吗网站空间域名是什么
  • 免费网站推广工具有哪些做教育培训的网站
  • 长沙做网站团队薪水最高的十大专业
  • 网站建设的技术团队武陵天下网站建设
  • 网站 主办单位性质 个人拼多多怎么申请开店
  • thinkphp开发企业网站线下推广引流渠道
  • 郑州做网站公司有哪些品牌展示型网站有哪些
  • 专业网站建设微信官网开发大兴建设网站公司
  • 网站建设公司的服务特点安徽省工程建设协会网站
  • 做家装的网站有什么不同厦门高端网站案例
  • 网站建设费用一年西地那非副作用太强了
  • 可以举报一个做网络网站发大财吗中国做的比较好的网站有哪些
  • wordpress图文混排深圳搜狗seo