Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android學習-新聞客戶端養成記(一)

Android學習-新聞客戶端養成記(一)

編輯:關於Android編程

經過數日的努力,新聞客戶端終於完成了,想用博客記錄一下開發過程中遇到的問題和解決方法,以免以後遇到同樣的問題罵自己記性差.

項目的前期准備

做項目前應該仔細的規劃一下功能需求,大體的預估一需要用到什麼知識.

新聞客戶端需要用到的第三方jar包包括

\

 

 

volley Jar包:

據我所知,在Android中主要提供了兩種方式來進行HTTP通信,分別是httpURLconnect和httpclient ,但是用過這兩種方式的人都會感覺到這樣的方法有些繁瑣,還要考慮主線程問題,volley的出現解決了這些繁瑣的問題,volley適合進行數據量不大但是相當頻繁的網絡操作,也不用考慮主線程問題,新聞客戶端正好需要這樣的框架.

viewpagertransformslibrary.jar 包:

viewpagertransformslibrary 是給viewpager做切換動畫用的

com.haarman.listviewanimations-2.6.0.jar 包

com.haarman.listviewanimations 是給列表控件的Item做動畫顯示用的

androidannotations-api-3.1.jar 包

androidannotations 是一個注解框架,現在的新聞客戶端沒有用到此框架,但我覺得這是一個相當不錯的框架,沒捨得刪掉,等有時間會把這個框架加到項目裡面的

nineoldandroids-2.4.0.jar 包

nineoldandroids 是一個不錯的動畫庫

open_sdk_r5756.jar 包 mta-sdk-1.6.2.jar包

這兩個包是騰訊提供的第三方jar包,通過這兩個包可實現騰訊提供的第三方功能

initActivity.jar

這個是我自己打的包,自己命的名,它實際上是vitamio包,官網上提供了源代碼,我嫌麻引用外部庫太麻煩就直接源碼打包了.

 

 

\

除了以上一些第三方jar包以外,還要知道新聞來源,客戶端用到的是網易新聞的接口 ,以下是我整理的項目所需要的網址

packageeNews.url;
/**
**@author王凱
*@date2016-9-12數據網址*/

publicclassUrl{publicstaticfinalStringhost="http://c.m.163.com/";
publicstaticfinalStringendUrl="-20.html";publicstaticfinalStringendDetailUrl="/full.html";

//頭條publicstaticfinalStringTopUrl=host+"nc/article/headline/";
publicstaticfinalStringTopId="T1348647909107";
//新聞詳情
publicstaticfinalStringNewDetail=host+"/nc/article/";
publicstaticfinalStringCommonUrl=host+"nc/article/list/";
//足球publicstaticfinalStringFootId="T1399700447917";
//娛樂publicstaticfinalStringYuLeId="T1348648517839";
//體育publicstaticfinalStringTiYuId="T1348649079062";
//財經publicstaticfinalStringCaiJingId="T1348648756099";
//科技publicstaticfinalStringKeJiId="T1348649580692";
//電影publicstaticfinalStringDianYingId="T1348648650048";
//汽車publicstaticfinalStringQiChiId="T1348654060988";
//笑話publicstaticfinalStringXiaoHuaId="T1350383429665";
//笑話publicstaticfinalStringYouXiId="T1348654151579";
//時尚publicstaticfinalStringShiShangId="T1348650593803";
//情感publicstaticfinalStringQingGanId="T1348650839000";
//精選publicstaticfinalStringJingXuanId="T1370583240249";
//電台publicstaticfinalStringDianTaiId="T1379038288239";
//nbapublicstaticfinalStringNBAId="T1348649145984";
//數碼publicstaticfinalStringShuMaId="T1348649776727";
//數碼publicstaticfinalStringYiDongId="T1351233117091";
//彩票publicstaticfinalStringCaiPiaoId="T1356600029035";
//教育publicstaticfinalStringJiaoYuId="T1348654225495";
//論壇publicstaticfinalStringLunTanId="T1349837670307";
//旅游publicstaticfinalStringLvYouId="T1348654204705";
//手機publicstaticfinalStringShouJiId="T1348649654285";
//博客publicstaticfinalStringBoKeId="T1349837698345";
//社會publicstaticfinalStringSheHuiId="T1348648037603";
//家居publicstaticfinalStringJiaJuId="T1348654105308";
//暴雪游戲publicstaticfinalStringBaoXueId="T1397016069906";
//親子publicstaticfinalStringQinZiId="T1397116135282";
//CBApublicstaticfinalStringCBAId="T1348649475931";
//消息publicstaticfinalStringMsgId="T1371543208049";

publicstaticfinalStringFangChanId="5YyX5Lqs";
//美圖
publicstaticfinalStringTuPianMeitu="http://c.m.163.com/recommend/getChanRecomNews?channel=T1456112189138&size=20&offset=";//體育

//體壇42262.jsonpublicstaticfinalStringTuPianTiTanInit=host
+"photo/api/morelist/0096/54GM0096/42262.json";//初始圖集
publicstaticfinalStringTuJiInit=host+"photo/api/list/0096/54GI0096.json";//42358.json

publicstaticfinalStringTuJi=host+"photo/api/morelist/0096/54GI0096/";//42358.json

//圖集endpublicstaticfinalStringTuJiEnd=".json";

//熱點42577publicstaticfinalStringTuPianReDian=host
+"photo/api/morelist/0096/54GI0096/42577.json";//獨家42010
publicstaticfinalStringTuPianDuJia=host+"photo/api/morelist/0096/54GJ0096/";
//明星42599.jsonpublicstaticfinalStringTuPianMingXing=host
+"photo/api/morelist/0096/54GK0096/";
//http://c.m.163.com/recommend/getChanRecomNews?channel=T1456112189138
//&size=20&offset=40&fn=1&passport=&devId=1W%2FpqPI0eimZMOMbswN2gw%3D%3D&lat=w7Ifc7bHs%2Bfw2bqO4TuUNw%3D%3D&lon=KuBH1jAZjiNo60aoq4e1Ag%3D%3D&version=14.2&net=wifi&ts=1472895595&sign=sU4j0lqP9jfsfmwV9dwTTAGpFOwYk2mWrXTRAA3nHPh48ErR02zJ6%2FKXOnxX046I&encryption=1&canal=meizu_store2014_news&mac=oHWFn0cEzVi3yidKr0L43U8dvF5D%2FPPigcKX35%2FLlyc%3D
//http://c.m.163.com/recommend/getChanRecomNews?channel=T1456112189138

//視頻http://c.3g.163.com/nc/video/list/00850FRB/n/10-10.htmlpublicstaticfinalStringVideo=host+"nc/video/list/";
publicstaticfinalStringVideoCenter="/n/";publicstaticfinalStringvideoEndUrl="-20.html";
//熱點視頻publicstaticfinalStringVideoReDianId="V9LG4B3A0";
//娛樂視頻publicstaticfinalStringVideoYuLeId="V9LG4CHOR";
//搞笑視頻publicstaticfinalStringVideoGaoXiaoId="V9LG4E6VR";
//精品視頻publicstaticfinalStringVideoJingPinId="00850FRB";

//天氣預報urlpublicstaticfinalStringWeatherHost="http://wthrcdn.etouch.cn/weather_mini?city=";
//http://v.juhe.cn/weather/index?cityname=//
//http://api.k780.com:88/?app=weather.city&format=json獲取城市列表
publicstaticfinalStringWeatherKey="&key=1734f933d24634331a24aaadc1cb088f";
//地址反編publicstaticfinalStringGeocoderUrl="http://maps.google.cn/maps/api/geocode/json?language=zh-CN&sensor=true&";//latlng=38.92,121.62&sensor=false

}

package eNews.url; /** * * @author 王凱 * @date 2016-9-12 數據網址 */ public class Url { public static final String host = "http://c.m.163.com/"; public static final String endUrl = "-20.html"; public static final String endDetailUrl = "/full.html"; // 頭條 public static final String TopUrl = host + "nc/article/headline/"; public static final String TopId = "T1348647909107"; // 新聞詳情 public static final String NewDetail = host + "/nc/article/"; public static final String CommonUrl = host + "nc/article/list/"; // 足球 public static final String FootId = "T1399700447917"; // 娛樂 public static final String YuLeId = "T1348648517839"; // 體育 public static final String TiYuId = "T1348649079062"; // 財經 public static final String CaiJingId = "T1348648756099"; // 科技 public static final String KeJiId = "T1348649580692"; // 電影 public static final String DianYingId = "T1348648650048"; // 汽車 public static final String QiChiId = "T1348654060988"; // 笑話 public static final String XiaoHuaId = "T1350383429665"; // 笑話 public static final String YouXiId = "T1348654151579"; // 時尚 public static final String ShiShangId = "T1348650593803"; // 情感 public static final String QingGanId = "T1348650839000"; // 精選 public static final String JingXuanId = "T1370583240249"; // 電台 public static final String DianTaiId = "T1379038288239"; // nba public static final String NBAId = "T1348649145984"; // 數碼 public static final String ShuMaId = "T1348649776727"; // 數碼 public static final String YiDongId = "T1351233117091"; // 彩票 public static final String CaiPiaoId = "T1356600029035"; // 教育 public static final String JiaoYuId = "T1348654225495"; // 論壇 public static final String LunTanId = "T1349837670307"; // 旅游 public static final String LvYouId = "T1348654204705"; // 手機 public static final String ShouJiId = "T1348649654285"; // 博客 public static final String BoKeId = "T1349837698345"; // 社會 public static final String SheHuiId = "T1348648037603"; // 家居 public static final String JiaJuId = "T1348654105308"; // 暴雪游戲 public static final String BaoXueId = "T1397016069906"; // 親子 public static final String QinZiId = "T1397116135282"; // CBA public static final String CBAId = "T1348649475931"; // 消息 public static final String MsgId = "T1371543208049"; public static final String FangChanId = "5YyX5Lqs"; // 美 圖 public static final String TuPianMeitu = "http://c.m.163.com/recommend/getChanRecomNews?channel=T1456112189138&size=20&offset="; // 體育 // 體壇 42262.json public static final String TuPianTiTanInit = host + "photo/api/morelist/0096/54GM0096/42262.json"; // 初始圖集 public static final String TuJiInit = host + "photo/api/list/0096/54GI0096.json";// 42358.json public static final String TuJi = host + "photo/api/morelist/0096/54GI0096/";// 42358.json // 圖集end public static final String TuJiEnd = ".json"; // 熱點42577 public static final String TuPianReDian = host + "photo/api/morelist/0096/54GI0096/42577.json"; // 獨家42010 public static final String TuPianDuJia = host + "photo/api/morelist/0096/54GJ0096/"; // 明星 42599.json public static final String TuPianMingXing = host + "photo/api/morelist/0096/54GK0096/"; // http://c.m.163.com/recommend/getChanRecomNews?channel=T1456112189138 // &size=20&offset=40&fn=1&passport=&devId=1W%2FpqPI0eimZMOMbswN2gw%3D%3D&lat=w7Ifc7bHs%2Bfw2bqO4TuUNw%3D%3D&lon=KuBH1jAZjiNo60aoq4e1Ag%3D%3D&version=14.2&net=wifi&ts=1472895595&sign=sU4j0lqP9jfsfmwV9dwTTAGpFOwYk2mWrXTRAA3nHPh48ErR02zJ6%2FKXOnxX046I&encryption=1&canal=meizu_store2014_news&mac=oHWFn0cEzVi3yidKr0L43U8dvF5D%2FPPigcKX35%2FLlyc%3D // http://c.m.163.com/recommend/getChanRecomNews?channel=T1456112189138 // 視頻 http://c.3g.163.com/nc/video/list/00850FRB/n/10-10.html public static final String Video = host + "nc/video/list/"; public static final String VideoCenter = "/n/"; public static final String videoEndUrl = "-20.html"; // 熱點視頻 public static final String VideoReDianId = "V9LG4B3A0"; // 娛樂視頻 public static final String VideoYuLeId = "V9LG4CHOR"; // 搞笑視頻 public static final String VideoGaoXiaoId = "V9LG4E6VR"; // 精品視頻 public static final String VideoJingPinId = "00850FRB"; // 天氣預報url public static final String WeatherHost = "http://wthrcdn.etouch.cn/weather_mini?city="; // http://v.juhe.cn/weather/index?cityname= // // http://api.k780.com:88/?app=weather.city&format=json 獲取城市列表 public static final String WeatherKey = "&key=1734f933d24634331a24aaadc1cb088f"; // 地址反編 public static final String GeocoderUrl = "http://maps.google.cn/maps/api/geocode/json?language=zh-CN&sensor=true&";// latlng=38.92,121.62&sensor=false }
  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved