android http get

主要代码:

	public void selfDestruct(View view) {
	     // Kabloey
		System.out.printf("haha this is a button event!\n");


		Log.v(TAG, "index=" + 2);
		
		String htpget="http://localme.sinaapp.com/insert_point.php?" +
				"longitude=0&latitude=112.297675";
		HttpGet httpRequest=new HttpGet (htpget);
		
		 try   
	        {   
	          /*发出HTTP request*/  
	          HttpResponse httpResponse = new DefaultHttpClient().execute(httpRequest);   
	          /*若状态码为200 ok*/  
	          if(httpResponse.getStatusLine().getStatusCode() == 200)    
	          {   
	      		Log.v(TAG, "http get ok" );
	          }   
	          else   
	          {   
	        	  Log.v(TAG, "http get error" );
	          }   
	        }   
	        catch (ClientProtocolException e)   
	        {    
	        	 Log.v(TAG, "http get IOException1" );
	        } catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				 Log.v(TAG, "http get IOException2" );
			}   
	       
	 }



权限:

<uses-permission android:name="android.permission.INTERNET" />




简单代码上传在:

http://download.csdn.net/detail/xyyangkun/5326560

你可能感兴趣的:(http,android,get)