編輯:關於Android編程
在使用http請求server時常常要傳遞一些參數給server,如IMEI號、平台號、渠道號、客戶端的版本號等一些通用信息,像這些參數我們沒有必要每次都拼在url後,我們可以統一添加到http頭裡。
1.HttpClient的設置http頭的參數
HttpClient httpclient = new DefaultHttpClient(); httpclient.getParams().setParameter( CoreConnectionPNames.CONNECTION_TIMEOUT, CONN_TIME_OUT); HttpGet httpget = new HttpGet(url); httpget.addHeader("version", SystemInfo.getVersionChars()); httpget.addHeader("client_token", SystemInfo.getIMEI()); httpget.addHeader("platform", SystemInfo.getPlatForm() + ""); httpget.addHeader("channel_id", SystemInfo.getChannelId() + "");
2.HttpURLConnection的設置http頭的參數
httpURLConnection.addRequestProperty("version", SystemInfo.getVersionChars()); httpURLConnection.addRequestProperty("client_token", SystemInfo.getIMEI()); httpURLConnection.addRequestProperty("platform", SystemInfo.getPlatForm() + ""); httpURLConnection.addRequestProperty("channel_id", SystemInfo.getChannelId() + "");
httpURLConnection.setRequestProperty("version", SystemInfo.getVersionChars()); httpURLConnection.setRequestProperty("client_token", SystemInfo.getIMEI()); httpURLConnection.setRequestProperty("platform", SystemInfo.getPlatForm() + ""); httpURLConnection.setRequestProperty("channel_id", SystemInfo.getChannelId() + "");
需要改變下拉狀態欄的背景色。關於這方面的代碼路徑 frameworks/base/packages/SystemUI中通過androidSDK自帶的工具uiautomat
React Native號稱能跨平台開發IOS和Android的原生應用,想來必定會成為一種趨勢。剛好計劃開發一款手機APP,又沒有相應的開發資源,決定自己摸索著試試。第
Android藍牙串口通訊 閒著無聊玩起了Android藍牙模塊與單片機藍牙模塊的通信,簡單思路就是要手機通過藍牙發送控制指令給單片機,並作簡單的控制應用。單片機的藍牙
概述 本篇博客是對developer.android.com/上的Training課程的簡單翻譯,若是覺得翻譯出來的理解有困難,請點擊下方鏈接查看原文! 關