运行我的android项目时出错

运行我的android项目时出错,android,Android,我试图将我的android项目连接到php上的数据库,我的代码中没有错误,但当我试图在手机上运行我的应用程序时,它不起作用 public class Historical_Sites extends ListActivity{ private ProgressDialog pDialog; Json_Parsing jParser = new Json_Parsing(); ArrayList<HashMap<String, String>> Si

我试图将我的android项目连接到php上的数据库,我的代码中没有错误,但当我试图在手机上运行我的应用程序时,它不起作用

public class Historical_Sites extends ListActivity{
    private ProgressDialog pDialog;
    Json_Parsing jParser = new Json_Parsing();
    ArrayList<HashMap<String, String>> SitesList;

    private static String url_all_Sites = "http://tourin.esy.es/php/historical.php";

    private static final String TAG_SUCCESS = "success";
    private static final String TAG_POSTS = "posts";
    private static final String TAG_SITE_NO="Site_NO";
    private static final String TAG_SITE_NAME = "Site_Name";

    JSONArray Sites = null;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.historical_sites);
        SitesList = new ArrayList<HashMap<String, String>>();
        new LoadAllProducts().execute();

        ListView lv = getListView();
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                                    int position, long id) {
                String sitname = ((TextView) view.findViewById(R.id.sitenam)).getText()
                        .toString();
                Intent in = new Intent(getApplicationContext(),
                        Check.class);
                in.putExtra(TAG_SITE_NAME, sitname);
                startActivityForResult(in, 100);
            }
        });
    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == 100) {
            Intent intent = getIntent();
            finish();
            startActivity(intent);
        }
    }

    class LoadAllProducts extends AsyncTask<String, String, String> {

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            pDialog = new ProgressDialog(Historical_Sites.this);
            pDialog.setMessage("Loading Historical Sites. Please wait...");
            pDialog.setIndeterminate(false);
            pDialog.setCancelable(false);
            pDialog.show();
        }

        protected String doInBackground(String... args) {
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            JSONObject json = jParser.makeHttpRequest(url_all_Sites, "GET", params);
            Log.d("All Sites: ", json.toString());
            try {
                int success = json.getInt(TAG_SUCCESS);
                if (success == 1) {

                    Sites = json.getJSONArray(TAG_POSTS);
                    for (int i = 0; i < Sites.length(); i++) {
                        JSONObject c = Sites.getJSONObject(i);

                         String sitno= c.getString(TAG_SITE_NO);
                        String Sitenam = c.getString(TAG_SITE_NAME);

                        HashMap<String, String> map = new HashMap<String, String>();
                        map.put(TAG_SITE_NO, sitno);
                        map.put(TAG_SITE_NAME, Sitenam);
                        SitesList.add(map);
                    }
                } else {

                    Intent i = new Intent(getApplicationContext(),
                            Chat.class);
                    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(i);
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return null;
        }

        protected void onPostExecute(String file_url) {

            pDialog.dismiss();

            runOnUiThread(new Runnable() {
                public void run() {

                    ListAdapter adapter = new SimpleAdapter(
                            Historical_Sites.this, SitesList,
                            R.layout.historical_sites_rows, new String[] {TAG_SITE_NAME},
                            new int[] { R.id.sitenam });

                    setListAdapter(adapter);
                }
            });
        }
    }
}
public class history\u Sites扩展列表活动{
私人对话;
Json_Parsing jParser=新的Json_Parsing();
ArrayList站点列表;
私有静态字符串url\u所有\u站点=”http://tourin.esy.es/php/historical.php";
私有静态最终字符串标记_SUCCESS=“SUCCESS”;
私有静态最终字符串标记_POSTS=“POSTS”;
私有静态最终字符串TAG\u SITE\u NO=“SITE\u NO”;
私有静态最终字符串TAG\u SITE\u NAME=“SITE\u NAME”;
JSONArray站点=null;
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(右布局、历史遗址);
SitesList=newarraylist();
新建LoadAllProducts().execute();
ListView lv=getListView();
lv.setOnItemClickListener(新的AdapterView.OnItemClickListener(){
@凌驾
public void onItemClick(AdapterView父级、视图、,
内部位置,长id){
字符串sitname=((TextView)view.findViewById(R.id.sitenam)).getText()
.toString();
Intent in=新的Intent(getApplicationContext(),
检查(类);
in.putExtra(标签、场地名称、场地名称);
startActivityForResult(in,100);
}
});
}
@凌驾
受保护的void onActivityResult(int请求代码、int结果代码、意图数据){
super.onActivityResult(请求代码、结果代码、数据);
如果(结果代码==100){
Intent=getIntent();
完成();
星触觉(意向);
}
}
类LoadAllProducts扩展了AsyncTask{
@凌驾
受保护的void onPreExecute(){
super.onPreExecute();
pDialog=新进度对话框(历史遗址,此);
pDialog.setMessage(“正在加载历史遗址,请稍候…”);
pDialog.setUndeterminate(假);
pDialog.setCancelable(假);
pDialog.show();
}
受保护的字符串doInBackground(字符串…args){
List params=new ArrayList();
JSONObject json=jParser.makeHttpRequest(url\u所有站点,“GET”,参数);
Log.d(“所有站点:,json.toString());
试一试{
int success=json.getInt(TAG_success);
如果(成功==1){
Sites=json.getJSONArray(TAG_POSTS);
对于(int i=0;i
这就是Json_解析

public class Json_Parsing {   

    static InputStream is = null;
    static JSONObject jObj = null;
    static String json = "";
    // constructor
    public Json_Parsing() { }

    public JSONObject makeHttpRequest(String url, String method,
                                      List<NameValuePair> params) {
        try {
            if(method == "POST"){
                DefaultHttpClient httpClient = new DefaultHttpClient();
                HttpPost httpPost = new HttpPost(url);
                httpPost.setEntity(new UrlEncodedFormEntity(params));
                HttpResponse httpResponse = httpClient.execute(httpPost);
                HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent();
            }else if(method == "GET"){
                DefaultHttpClient httpClient = new DefaultHttpClient();
                String paramString = URLEncodedUtils.format(params, "utf-8");
                url += "?" + paramString;
                HttpGet httpGet = new HttpGet(url);
                HttpResponse httpResponse = httpClient.execute(httpGet);
                HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent();
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (ClientProtocolException e) {
            e.printStackTrace(); } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(
                    is, "iso-8859-1"), 8);
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
            is.close();
            json = sb.toString();
        } catch (Exception e) {
            Log.e("Buffer Error", "Error converting result " + e.toString());
        }
        try {
            jObj = new JSONObject(json);
        } catch (JSONException e) {
            Log.e("JSON Parser", "Error parsing data " + e.toString());
        }

        return jObj;
    }

    public JSONObject getJSONFromUrl(String url) {
        try {
            DefaultHttpClient httpClient = new DefaultHttpClient();
            HttpPost httpPost = new HttpPost(url);
            HttpResponse httpResponse = httpClient.execute(httpPost);
            HttpEntity httpEntity = httpResponse.getEntity();
            is = httpEntity.getContent();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(
                    is, "iso-8859-1"), 8);
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
            is.close();
            json = sb.toString();
        } catch (Exception e) {
            Log.e("Buffer Error", "Error converting result " + e.toString());
        }

        try {
            jObj = new JSONObject(json);
        } catch (JSONException e) {
            Log.e("JSON Parser", "Error parsing data " + e.toString());
        }

        return jObj;
    }
    /*
    *
    *
    *
    *
    *
    * */

}
公共类Json_解析{
静态InputStream为空;
静态JSONObject jObj=null;
静态字符串json=“”;
//建造师
公共Json_解析(){}
公共JSONObject makeHttpRequest(字符串url、字符串方法、,
列表参数){
试一试{
如果(方法==“POST”){
DefaultHttpClient httpClient=新的DefaultHttpClient();
HttpPost HttpPost=新的HttpPost(url);
setEntity(新的UrlEncodedFormEntity(参数));
HttpResponse HttpResponse=httpClient.execute(httpPost);
HttpEntity HttpEntity=httpResponse.getEntity();is=HttpEntity.getContent();
}else if(方法==“GET”){
DefaultHttpClient httpClient=新的DefaultHttpClient();
String paramString=URLEncodedUtils.format(params,“utf-8”);
url+=“?”+参数字符串;
HttpGet HttpGet=新的HttpGet(url);
HttpResponse HttpResponse=httpClient.execute(httpGet);
HttpEntity HttpEntity=httpResponse.getEntity();is=HttpEntity.getContent();
}
}捕获(不支持的编码异常e){
e、 printStackTrace();
}捕获(客户端协议例外e){
e、 printStackTrace();}捕获(IOE异常){
e、 printStackTrace();
}
试一试{
BufferedReader reader=新的BufferedReader(新的InputStreamReader(
is,“iso-8859-1”),8);
StringBuilder sb=新的StringBuilder();
字符串行=null;
而((line=reader.readLine())!=null){
sb.追加(第+行“\n”);
}
is.close();
json=sb.toString();
}捕获(例外e){
Log.e(“缓冲区错误”、“错误”
protected void onPostExecute(String file_url) {

            pDialog.dismiss();


                    ListAdapter adapter = new SimpleAdapter(
                            Historical_Sites.this, SitesList,
                            R.layout.historical_sites_rows, new String[] {TAG_SITE_NAME},
                            new int[] { R.id.sitenam });

                    setListAdapter(adapter);

        }