url - Android - web request not working and application stop working -


i have android app, , want request server , show user, it's not working , application stops working. here's code:

 url url;     try {         url = new url("http://accounting.hamyar.net/ibsng/user/index.php?normal_username=7325238658&normal_password=hamidreza3329");         urlconnection conn = url.openconnection();         conn.setrequestproperty("cookie", "ibs_sessid=hlpjpnm8hdrf84n7igk0m5n9v6; session_id=f49f028f0c3b87719638136ce5cd5f23090eca5e");         bufferedreader br = new bufferedreader(new inputstreamreader(conn.getinputstream()));          string inputline;          while ((inputline = br.readline()) != null) {             if (inputline.contains("<td class=") && inputline.contains("middle") && inputline.contains("<sub>"))             {                 string chargenum =  getbetween(inputline, "<td class=\"list_col\" valign=\"middle\" >", "<sub>").trim();                  string chargeunit = getbetween(inputline, "<sub>", "</sub>");                 string gig = chargenum.trim() + chargeunit.trim();                 system.out.println("your gig "+gig);             }         }         br.close();        } catch (ioexception e) {     } } public static string getbetween(string str, string open, string close) {     if (str == null || open == null || close == null) {         return null;     }     int start = str.indexof(open);     if (start != -1) {         int end = str.indexof(close, start + open.length());         if (end != -1) {             return str.substring(start + open.length(), end);         }     }     return null; } 

you have add internet permission in androidmanifest.xml outside application tag this:

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

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -