<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <Button android:text="GET" android:id="@+id/Button01" android:layout_width="fill_parent" android:layout_height="wrap_content"> </Button> <Button android:text="POST" android:id="@+id/Button02" android:layout_width="fill_parent" android:layout_height="wrap_content"> </Button> <TextView android:id="@+id/TextView" android:layout_width="fill_parent" android:layout_height="wrap_content"/> </LinearLayout>
package com.Aina.Android; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.List; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.NameValuePair; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.View; import android.widget.Button; import android.widget.TextView; public class Test extends Activity implements Runnable{ /** Called when the activity is first created. */ private Button btn_get = null; private Button btn_post = null; private TextView tv_rp = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); btn_get = (Button) this.findViewById(R.id.Button01); btn_post = (Button) this.findViewById(R.id.Button02); tv_rp = (TextView) this.findViewById(R.id.TextView); btn_get.setOnClickListener(new Button.OnClickListener(){ public void onClick(View v) { // TODO Auto-generated method stub String httpUrl = "http://192.168.0.132:8080/Android/httpreq.jsp?par=request-get"; HttpGet request = new HttpGet(httpUrl); HttpClient httpClient = new DefaultHttpClient(); try { HttpResponse response = httpClient.execute(request); if(response.getStatusLine().getStatusCode()==HttpStatus.SC_OK){ String str = EntityUtils.toString(response.getEntity()); tv_rp.setText(str); }else{ tv_rp.setText("請求錯誤"); } } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); btn_post.setOnClickListener(new Button.OnClickListener(){ public void onClick(View v) { // TODO Auto-generated method stub String httpUrl = "http://192.168.0.132:8080/Android/httpreq.jsp"; HttpPost request = new HttpPost(httpUrl); List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("par","request-post")); try { HttpEntity entity = new UrlEncodedFormEntity(params, "UTF-8"); request.setEntity(entity); HttpClient client = new DefaultHttpClient(); HttpResponse response = client.execute(request); if(response.getStatusLine().getStatusCode()==HttpStatus.SC_OK){ String str = EntityUtils.toString(response.getEntity()); tv_rp.setText(str); }else{ tv_rp.setText("請求錯誤"); } } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); new Thread(this).start(); } public void refresh(){ String httpUrl = "http://192.168.0.132:8080/Android/httpreq.jsp"; try { URL url = new URL(httpUrl); HttpURLConnection urlConn = (HttpURLConnection) url.openConnection(); urlConn.connect(); InputStream input = urlConn.getInputStream(); InputStreamReader inputreader = new InputStreamReader(input); BufferedReader reader = new BufferedReader(inputreader); String str = null; StringBuffer sb = new StringBuffer(); while((str = reader.readLine())!= null){ sb.append(str).append("/n"); } if(sb != null){ tv_rp.setText(sb.toString()); }else{ tv_rp.setText("NULL"); } reader.close(); inputreader.close(); input.close(); reader = null; inputreader = null; input = null; } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public Handler handler = new Handler(){ public void handleMessage(Message msg){ super.handleMessage(msg); refresh(); } }; public void run() { // TODO Auto-generated method stub while(true){ try { Thread.sleep(1000); handler.sendMessage(handler.obtainMessage()); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.Aina.Android" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".Test" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-permission android:name="android.permission.INTERNET" /> </manifest>
轉: http://aina-hk55hk.javaeye.com/blog/711544
方案概述 在汽車發展和用戶需求的推動下,汽車鑰匙開始從傳統的機械鑰匙向數字化、智能化方向發展。目前常見的數字鑰匙集成了藍牙、NFC、UWB等技術實現了移動設備與車端的通信,可以幫助用戶便捷的實現車輛功能控制。隨着數字鑰匙的廣泛
前言 在無線網絡技術不斷髮展的今天,Wi-Fi已經成爲了我們日常生活中不可或缺的一部分。無論是家庭娛樂、辦公還是在線遊戲,Wi-Fi都在提供着便捷的互聯網接入服務。然而,在安卓8.1後,爲了進一步延長安卓設備的待機時間。原生安卓(AO
DevExpress .NET MAUI UI組件庫提供了用於Android和iOS移動開發的高性能UI組件,該庫包括數據網格、圖表、日程、數據編輯器、CollectionView和選項卡組件。 獲取DevExpress .NET MAUI
作者:vivo 互聯網大前端團隊 - Ma Lian 本文主要描述了FileProvider,startAnyWhere實現,Parcel不對稱漏洞以及這三者結合產生的漏洞利用實戰,另外闡述了漏洞利用的影響和修復預防措施,這個漏洞波及了
Taro 團隊再再再招人啦!我們正在尋找多位有經驗的「前端開發工程師」加入我們的團隊。如果您具備以下技能和經驗,我們期待您的加入: 工作職責 參與 Taro 框架開發,同時在跨端和全棧等技術方向攻克難題; 參與跨團隊合作,完成整體項目規
BusyBox是一個遵循GPL協議、以自由軟件形式發行的應用程序。 Busybox在單一的可執行文件中提供了精簡的Unix工具集,可運行於多款POSIX環境的操作系統,例如Linux(包括Android)、Hurd、FreeBSD等等。 由
一、前言 之前就寫過這個方案,當時做的是ffmpeg內核版本,由於ffmpeg內核解析都是代碼實現,所以無縫切換非常完美,看不到絲毫的中間切換過程,看起來就像是在一個通道畫面中。其實這種切換隻能說是取巧辦法,最佳的辦法應該是公用一個open
01 背景介紹 在智能手機市場上,高端機型經常備受矚目,但低端機型亦佔據了不可忽視的份額。衆多廠商爲滿足低端市場的需求,不斷推出低配系列手機。另外過去幾年的中高端
DevExtreme擁有高性能的HTML5 / JavaScript小部件集合,使您可以利用現代Web開發堆棧(包括React,Angular,ASP.NET Core,jQuery,Knockout等)構建交互式的Web應用程序。從Ang
一.Vue文件內容 <template> </template> <script> </script> <style> </style>
CSDN應該是大家接觸到最多的博客平臺了,所以一款能夠發佈到CSDN的自動化工具還是非常有必要的。 今天給大家講講自動化CSDN博客發佈的思路和一些問題的解決辦法。 解決問題的思路一定是最重要的,知識是死的,問題是活的,如何在工作中解決遇
本文分享自華爲雲社區《6個實例帶你解讀TinyVue 組件庫跨框架技術》,作者: 華爲雲社區精選。 在DTSE Tech Talk 《 手把手教你實現mini版TinyVue組件庫 》的主題直播中,華爲雲前端開發DTSE技術佈道師阿健老師給
Ai technology 前言 AppBuilder上線了低代碼製作組件功能,可以通過工作流的方式構建自定義組件,完成簡單Agent無法完成的複雜功能,使得生成的文本更加定製化,
最近在刷一些問題的時候看到有下面一個問題 上面問的是當輸入的字符串爲什麼的時候返回 True 總結 在做題目的時候,第一次還做錯了。 這是因爲解答這個題目的時間只有 3 分鐘,沒有自己看題目 後來拿着程序跑了下。 p
簡介: 搶紅包是我們生活常用的社交功能, 這個功能最主要的特點就是用戶的併發請求高, 在系統設計上, 可以使用非常多的辦法來扛住用戶的高併發請求, 在本文中簡要介紹使用Redis緩存中間件來實現搶紅包算法, Redis是一個在內存中基