/**
創(chuàng)新互聯(lián)專注于龍圩企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站設(shè)計,電子商務(wù)商城網(wǎng)站建設(shè)。龍圩網(wǎng)站建設(shè)公司,為龍圩等地區(qū)提供建站服務(wù)。全流程按需定制,專業(yè)設(shè)計,全程項目跟蹤,創(chuàng)新互聯(lián)專業(yè)和態(tài)度為您提供的服務(wù)
*?@description:?
*?@author?chenshiqiang?E-mail:csqwyyx@163.com
*?@date?2014年9月7日?下午2:51:50???
*?@version?1.0???
*/
package?com.example.baidumap;
import?java.util.ArrayList;
import?java.util.Collections;
import?java.util.HashSet;
import?java.util.List;
import?android.app.Activity;
import?android.os.Bundle;
import?android.support.v4.view.PagerAdapter;
import?android.support.v4.view.PagerTabStrip;
import?android.support.v4.view.ViewPager;
import?android.text.Editable;
import?android.util.Log;
import?android.view.LayoutInflater;
import?android.view.View;
import?android.view.ViewGroup;
import?android.widget.ExpandableListView;
import?android.widget.ListView;
import?com.baidu.mapapi.map.offline.MKOLSearchRecord;
import?com.baidu.mapapi.map.offline.MKOLUpdateElement;
import?com.baidu.mapapi.map.offline.MKOfflineMap;
import?com.baidu.mapapi.map.offline.MKOfflineMapListener;
import?com.example.baidumap.adapters.OfflineExpandableListAdapter;
import?com.example.baidumap.adapters.OfflineMapAdapter;
import?com.example.baidumap.adapters.OfflineMapManagerAdapter;
import?com.example.baidumap.interfaces.OnOfflineItemStatusChangeListener;
import?com.example.baidumap.models.OfflineMapItem;
import?com.example.baidumap.utils.CsqBackgroundTask;
import?com.example.baidumap.utils.ToastUtil;
import?com.example.system.R;
public?class?BaiduOfflineMapActivity?extends?Activity?implements?MKOfflineMapListener,?OnOfflineItemStatusChangeListener
{
//?------------------------?Constants?------------------------
//?-------------------------?Fields?--------------------------
private?ViewPager?viewpager;
private?PagerTabStrip?pagertab;
private?MySearchView?svDown;
private?ListView?lvDown;
private?MySearchView?svAll;
private?ExpandableListView?lvWholeCountry;
private?ListView?lvSearchResult;
private?ListView?views?=?new?ArrayListView(2);
private?ListString?titles?=?new?ArrayListString(2);
private?MKOfflineMap?mOffline?=?null;
private?OfflineMapManagerAdapter?downAdapter;
private?OfflineMapAdapter?allSearchAdapter;
private?OfflineExpandableListAdapter?allCountryAdapter;
private?ListOfflineMapItem?itemsDown;?//?下載或下載中城市
private?ListOfflineMapItem?itemsAll;?//?所有城市,與熱門城市及下載管理對象相同
private?ListOfflineMapItem?itemsProvince;
private?ListListOfflineMapItem?itemsProvinceCity;
//?-----------------------?Constructors?----------------------
//?--------?Methods?for/from?SuperClass/Interfaces?-----------
@Override
protected?void?onCreate(Bundle?savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_offline_map);
// final?String?packname?=?this.getPackageName();
// PackageInfo?packageInfo;
// try
// {
// packageInfo?=?this.getPackageManager().getPackageInfo(packname,?PackageManager.GET_SIGNATURES);
//
//
// if?(code?==?-00)
// {
//?初始化離線地圖管理
mOffline?=?new?MKOfflineMap();
mOffline.init(this);
initViews();
viewpager.setCurrentItem(1);
// }
// }
// catch?(NameNotFoundException?e)
// {
// e.printStackTrace();
// }
}
private?boolean?isResumed?=?false;
@Override
protected?void?onResume()
{
super.onResume();
if?(!isResumed)
{
isResumed?=?true;
loadData();
}
}
@Override
protected?void?onDestroy()
{
super.onDestroy();
mOffline.destroy();
}
/**
?*?
?*?@author?chenshiqiang?E-mail:csqwyyx@163.com
?*?@param?type
?*????????????事件類型:?MKOfflineMap.TYPE_NEW_OFFLINE,?MKOfflineMap.TYPE_DOWNLOAD_UPDATE,?MKOfflineMap.TYPE_VER_UPDATE.
?*?@param?state
?*????????????事件狀態(tài):?當(dāng)type為TYPE_NEW_OFFLINE時,表示新安裝的離線地圖數(shù)目.?當(dāng)type為TYPE_DOWNLOAD_UPDATE時,表示更新的城市ID.
?*/
@Override
public?void?onGetOfflineMapState(int?type,?int?state)
{
switch?(type)
{
case?MKOfflineMap.TYPE_DOWNLOAD_UPDATE:
MKOLUpdateElement?update?=?mOffline.getUpdateInfo(state);
if?(setElement(update,?true)?!=?null)
{
if?(itemsDown?!=?null??itemsDown.size()??1)
{
Collections.sort(itemsDown);
}
refreshDownList();
}
else
{
downAdapter.notifyDataSetChanged();
}
allSearchAdapter.notifyDataSetChanged();
allCountryAdapter.notifyDataSetChanged();
break;
case?MKOfflineMap.TYPE_NEW_OFFLINE:
//?有新離線地圖安裝
Log.d("OfflineDemo",?String.format("add?offlinemap?num:%d",?state));
break;
case?MKOfflineMap.TYPE_VER_UPDATE:
//?版本更新提示
break;
}
}
/**
?*?百度下載狀態(tài)改變(暫停--》恢復(fù))居然不回調(diào),所以改變狀態(tài)時自己得增加接口監(jiān)聽狀態(tài)改變刷新界面
?*?
?*?@author?chenshiqiang?E-mail:csqwyyx@163.com
?*?@param?item
?*????????????有狀態(tài)改變的item
?*?@param?removed
?*????????????item是否被刪除
?*/
@Override
public?void?statusChanged(OfflineMapItem?item,?boolean?removed)
{
if?(removed)
{
for?(int?i?=?itemsDown.size()?-?1;?i?=?0;?i--)
{
OfflineMapItem?temp?=?itemsDown.get(i);
if?(temp.getCityId()?==?item.getCityId())
{
itemsDown.remove(i);
}
}
refreshDownList();
}
else
{
loadData();
downAdapter.notifyDataSetChanged();
}
allSearchAdapter.notifyDataSetChanged();
allCountryAdapter.notifyDataSetChanged();
}
//?---------------------?Methods?public?----------------------
public?void?toDownloadPage()
{
viewpager.setCurrentItem(0);
}
//?---------------------?Methods?private?---------------------
private?void?initViews()
{
//?TODO
viewpager?=?(ViewPager)?findViewById(R.id.viewpager);
pagertab?=?(PagerTabStrip)?findViewById(R.id.pagertab);
LayoutInflater?inf?=?LayoutInflater.from(this);
View?v1?=?inf.inflate(R.layout.view_offline_download,?null,?false);
svDown?=?(MySearchView)?v1.findViewById(R.id.svDown);
lvDown?=?(ListView)?v1.findViewById(R.id.lvDown);
views.add(v1);
View?v2?=?inf.inflate(R.layout.view_offline_countrys,?null,?false);
svAll?=?(MySearchView)?v2.findViewById(R.id.svAll);
lvWholeCountry?=?(ExpandableListView)?v2.findViewById(R.id.lvWholeCountry);
lvSearchResult?=?(ListView)?v2.findViewById(R.id.lvSearchResult);
views.add(v2);
titles.add("下載管理");
titles.add("城市列表");
pagertab.setTabIndicatorColor(0xff00cccc);
pagertab.setDrawFullUnderline(false);
pagertab.setBackgroundColor(0xFF38B0DE);
pagertab.setTextSpacing(50);
viewpager.setOffscreenPageLimit(2);
viewpager.setAdapter(new?MyPagerAdapter());
svDown.setSearchListener(new?MySearchView.SearchListener()
{
@Override
public?void?afterTextChanged(Editable?text)
{
refreshDownList();
}
@Override
public?void?search(String?text)
{
}
});
svAll.setSearchListener(new?MySearchView.SearchListener()
{
@Override
public?void?afterTextChanged(Editable?text)
{
refreshAllSearchList();
}
@Override
public?void?search(String?text)
{
}
});
downAdapter?=?new?OfflineMapManagerAdapter(this,?mOffline,?this);
lvDown.setAdapter(downAdapter);
allSearchAdapter?=?new?OfflineMapAdapter(this,?mOffline,?this);
lvSearchResult.setAdapter(allSearchAdapter);
allCountryAdapter?=?new?OfflineExpandableListAdapter(this,?mOffline,?this);
lvWholeCountry.setAdapter(allCountryAdapter);
lvWholeCountry.setGroupIndicator(null);
}
/**
?*?刷新下載列表,?根據(jù)搜索關(guān)鍵字及itemsDown?下載管理數(shù)量變動時調(diào)用
?*/
private?void?refreshDownList()
{
String?key?=?svDown.getInputText();
if?(key?==?null?||?key.length()??1)
{
downAdapter.setDatas(itemsDown);
}
else
{
ListOfflineMapItem?filterList?=?new?ArrayListOfflineMapItem();
if?(itemsDown?!=?null??!itemsDown.isEmpty())
{
for?(OfflineMapItem?i?:?itemsDown)
{
if?(i.getCityName().contains(key))
{
filterList.add(i);
}
}
}
downAdapter.setDatas(filterList);
}
}
/**
?*?刷新所有城市搜索結(jié)果
?*/
private?void?refreshAllSearchList()
{
String?key?=?svAll.getInputText();
if?(key?==?null?||?key.length()??1)
{
lvSearchResult.setVisibility(View.GONE);
lvWholeCountry.setVisibility(View.VISIBLE);
allSearchAdapter.setDatas(null);
}
else
{
lvSearchResult.setVisibility(View.VISIBLE);
lvWholeCountry.setVisibility(View.GONE);
ListOfflineMapItem?filterList?=?new?ArrayListOfflineMapItem();
if?(itemsAll?!=?null??!itemsAll.isEmpty())
{
for?(OfflineMapItem?i?:?itemsAll)
{
if?(i.getCityName().contains(key))
{
filterList.add(i);
}
}
}
allSearchAdapter.setDatas(filterList);
}
}
private?void?loadData()
{
new?CsqBackgroundTaskVoid(this)
{
@Override
protected?Void?onRun()
{
//?TODO?Auto-generated?method?stub
//?導(dǎo)入離線地圖包
//?將從官網(wǎng)下載的離線包解壓,把vmp文件夾拷入SD卡根目錄下的BaiduMapSdk文件夾內(nèi)。
//?把網(wǎng)站上下載的文件解壓,將\BaiduMap\vmp\l里面的.dat_svc文件,拷貝到手機(jī)BaiduMapSDK/vmp/h目錄下
int?num?=?mOffline.importOfflineData();
if?(num??0)
{
ToastUtil.showToastInfo(BaiduOfflineMapActivity.this,?"成功導(dǎo)入"?+?num?+?"個離線包",?false);
}
ListMKOLSearchRecord?all?=?null;
try
{
all?=?mOffline.getOfflineCityList();
}
catch?(Exception?e)
{
e.printStackTrace();
}
if?(all?==?null?||?all.isEmpty())
{
ToastUtil.showToastInfo(BaiduOfflineMapActivity.this,?"未獲取到離線地圖城市數(shù)據(jù),可能有其他應(yīng)用正在使用百度離線地圖功能!",?false);
return?null;
}
ListMKOLSearchRecord?hotCity?=?mOffline.getHotCityList();
HashSetInteger?hotCityIds?=?new?HashSetInteger();
if?(!hotCity.isEmpty())
{
for?(MKOLSearchRecord?r?:?hotCity)
{
hotCityIds.add(r.cityID);
}
}
itemsAll?=?new?ArrayListOfflineMapItem();
itemsDown?=?new?ArrayListOfflineMapItem();
itemsProvince?=?new?ArrayListOfflineMapItem();
itemsProvinceCity?=?new?ArrayListListOfflineMapItem();
//?cityType?0:全國;1:省份;2:城市,如果是省份,可以通過childCities得到子城市列表
//?全國概略圖、直轄市、港澳?子城市列表
ArrayListMKOLSearchRecord?childMunicipalities?=?new?ArrayListMKOLSearchRecord();
proHot.cityName?=?"熱門城市";
proHot.childCities?=?cs;
ListMKOLUpdateElement?updates?=?mOffline.getAllUpdateInfo();
if?(updates?!=?null??updates.size()??0)
{
}
@Override
protected?void?onResult(Void?result)
{
//?TODO?Auto-generated?method?stub
refreshDownList();
refreshAllSearchList();
allCountryAdapter.setDatas(itemsProvince,?itemsProvinceCity);
}
}.execute();
}
package test;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class HttpTest {
private String u;
private String encoding;
public static void main(String[] args) throws Exception {
HttpTest client = new HttpTest("", "UTF-8");
client.run();
}
public HttpTest(String u, String encoding) {
this.u = u;
this.encoding = encoding;
}
public void run() throws Exception {
URL url = new URL(u);// 根據(jù)鏈接(字符串格式),生成一個URL對象
HttpURLConnection urlConnection = (HttpURLConnection) url
.openConnection();// 打開URL
BufferedReader reader = new BufferedReader(new InputStreamReader(
urlConnection.getInputStream(), encoding));// 得到輸入流,即獲得了網(wǎng)頁的內(nèi)容
String line; // 讀取輸入流的數(shù)據(jù),并顯示
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
}
}
根據(jù)具體問題類型,進(jìn)行步驟拆解/原因原理分析/內(nèi)容拓展等。
具體步驟如下:/導(dǎo)致這種情況的原因主要是……
首先 java網(wǎng)站是基于jdk運行的。你得先裝jdk。去官網(wǎng)下載一個jdk安裝。然后你得編譯你的項目,打包到容器(tomcat,weblogic,jboss等)中運行即可。再提醒一下就是,看看你的源代碼有木有用到數(shù)據(jù)庫或者其他類型的服務(wù)。如果有的話,你得裝數(shù)據(jù)庫或服務(wù),并且初始化數(shù)據(jù)。再啟動你的你的容器。
網(wǎng)頁地址在代碼中的java代碼寫法如下:
package com.test;
import java.lang.reflect.Method;
//實現(xiàn)打開瀏覽器并跳到指定網(wǎng)址的類
public class BareBonesBrowserLaunch {
public static void openURL(String url) {
try {
browse(url);
} catch (Exception e) {
}
}
private static void browse(String url) throws Exception {
//獲取操作系統(tǒng)的名字
String osName = System.getProperty("os.name", "");
if (osName.startsWith("Mac OS")) {
//蘋果的打開方式
Class fileMgr = Class.forName("com.apple.eio.FileManager");
Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] { String.class });
openURL.invoke(null, new Object[] { url });
} else if (osName.startsWith("Windows")) {
//windows的打開方式。
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
} else {
// Unix or Linux的打開方式
String[] browsers = { "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" };
String browser = null;
for (int count = 0; count browsers.length browser == null; count++)
//執(zhí)行代碼,在brower有值后跳出,
//這里是如果進(jìn)程創(chuàng)建成功了,==0是表示正常結(jié)束。
if (Runtime.getRuntime().exec(new String[] { "which", browsers[count] }).waitFor() == 0)
browser = browsers[count];
if (browser == null)
throw new Exception("Could not find web browser");
else
//這個值在上面已經(jīng)成功的得到了一個進(jìn)程。
Runtime.getRuntime().exec(new String[] { browser, url });
}
}
}
//主方法 測試類
public static void main(String[] args) {
String url = ""; ? ? ?
BareBonesBrowserLaunch.openURL(url);
}
網(wǎng)頁題目:java網(wǎng)站代碼 javaweb網(wǎng)站
轉(zhuǎn)載注明:http://jinyejixie.com/article0/dossgoo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、自適應(yīng)網(wǎng)站、面包屑導(dǎo)航、電子商務(wù)、ChatGPT、域名注冊
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)