Forum » Programiranje » [Android] HttpClient execute problem
[Android] HttpClient execute problem
golobich ::
Zdravo!
Delam čisto enostavno registracijo uporabnika katerega podatki se zapišejo v mysql bazo na enem serverju. Problem je ko program pride do delčka kode kjer se kliče metoda execute od httpclienta. Kakršnekoli pomoči bi bil hvaležen.
Izvedba zahteve
doInBackground metoda
Lp, golobich
Delam čisto enostavno registracijo uporabnika katerega podatki se zapišejo v mysql bazo na enem serverju. Problem je ko program pride do delčka kode kjer se kliče metoda execute od httpclienta. Kakršnekoli pomoči bi bil hvaležen.
Izvedba zahteve
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(); }
doInBackground metoda
@Override protected String doInBackground(String... args) { int success; String username = user.getText().toString(); String password = pass.getText().toString(); try { List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("username", username)); params.add(new BasicNameValuePair("password", password)); Log.d("request!", "starting"); JSONObject json = jsonParser.makeHttpRequest( LOGIN_URL, "POST", params); Log.d("Login attempt", json.toString()); success = json.getInt(TAG_SUCCESS); if (success == 1) { Log.d("User Created!", json.toString()); finish(); return json.getString(TAG_MESSAGE); }else{ Log.d("Login Failure!", json.getString(TAG_MESSAGE)); return json.getString(TAG_MESSAGE); } } catch (JSONException e) { e.printStackTrace(); } return null; }
Lp, golobich
golobich ::
Ah ja vidim da sm še log fajl pozabu dodat zraven.
Evo log fajla:
Edit: Pa to nemoreš vrjet. mislim da mi je jasno kaj je narobe :)
Evo log fajla:
08-14 19:26:10.602: E/AndroidRuntime(32141): FATAL EXCEPTION: AsyncTask #3 08-14 19:26:10.602: E/AndroidRuntime(32141): Process: eu.tgsplet.kmetijstvo, PID: 32141 08-14 19:26:10.602: E/AndroidRuntime(32141): java.lang.RuntimeException: An error occured while executing doInBackground() 08-14 19:26:10.602: E/AndroidRuntime(32141): at android.os.AsyncTask$3.done(AsyncTask.java:300) 08-14 19:26:10.602: E/AndroidRuntime(32141): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) 08-14 19:26:10.602: E/AndroidRuntime(32141): at java.util.concurrent.FutureTask.setException(FutureTask.java:222) 08-14 19:26:10.602: E/AndroidRuntime(32141): at java.util.concurrent.FutureTask.run(FutureTask.java:242) 08-14 19:26:10.602: E/AndroidRuntime(32141): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 08-14 19:26:10.602: E/AndroidRuntime(32141): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 08-14 19:26:10.602: E/AndroidRuntime(32141): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 08-14 19:26:10.602: E/AndroidRuntime(32141): at java.lang.Thread.run(Thread.java:818) 08-14 19:26:10.602: E/AndroidRuntime(32141): Caused by: java.lang.SecurityException: Permission denied (missing INTERNET permission?) 08-14 19:26:10.602: E/AndroidRuntime(32141): at java.net.InetAddress.lookupHostByName(InetAddress.java:451) 08-14 19:26:10.602: E/AndroidRuntime(32141): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252) 08-14 19:26:10.602: E/AndroidRuntime(32141): at java.net.InetAddress.getAllByName(InetAddress.java:215) 08-14 19:26:10.602: E/AndroidRuntime(32141): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137) 08-14 19:26:10.602: E/AndroidRuntime(32141): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164) 08-14 19:26:10.602: E/AndroidRuntime(32141): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119) 08-14 19:26:10.602: E/AndroidRuntime(32141): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360) 08-14 19:26:10.602: E/AndroidRuntime(32141): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555) 08-14 19:26:10.602: E/AndroidRuntime(32141): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487) 08-14 19:26:10.602: E/AndroidRuntime(32141): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465) 08-14 19:26:10.602: E/AndroidRuntime(32141): at eu.tgsplet.kmetijstvo.JSONParser.makeHttpRequest(JSONParser.java:123) 08-14 19:26:10.602: E/AndroidRuntime(32141): at eu.tgsplet.kmetijstvo.Register$CreateUser.doInBackground(Register.java:100) 08-14 19:26:10.602: E/AndroidRuntime(32141): at eu.tgsplet.kmetijstvo.Register$CreateUser.doInBackground(Register.java:1) 08-14 19:26:10.602: E/AndroidRuntime(32141): at android.os.AsyncTask$2.call(AsyncTask.java:288) 08-14 19:26:10.602: E/AndroidRuntime(32141): at java.util.concurrent.FutureTask.run(FutureTask.java:237) 08-14 19:26:10.602: E/AndroidRuntime(32141): ... 4 more 08-14 19:26:10.602: E/AndroidRuntime(32141): Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname) 08-14 19:26:10.602: E/AndroidRuntime(32141): at libcore.io.Posix.android_getaddrinfo(Native Method) 08-14 19:26:10.602: E/AndroidRuntime(32141): at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55) 08-14 19:26:10.602: E/AndroidRuntime(32141): at java.net.InetAddress.lookupHostByName(InetAddress.java:438) 08-14 19:26:10.602: E/AndroidRuntime(32141): ... 18 more 08-14 19:26:10.602: E/AndroidRuntime(32141): Caused by: android.system.ErrnoException: android_getaddrinfo failed: EACCES (Permission denied) 08-14 19:26:10.602: E/AndroidRuntime(32141): ... 21 more
Edit: Pa to nemoreš vrjet. mislim da mi je jasno kaj je narobe :)
Zgodovina sprememb…
- spremenil: golobich ()
shadeX ::
Caused by: java.lang.SecurityException: Permission denied (missing INTERNET permission?)
V manifest datoteko dodaj:
<uses-permission android:name="android.permission.INTERNET"/>
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | Programiranje problem androidOddelek: Programiranje | 1173 (938) | g333kk |
» | [Android] Aplikacija se zrušiOddelek: Programiranje | 813 (650) | g333kk |
» | android črtaOddelek: Programiranje | 2399 (1670) | g333kk |
» | [android] vstavljanje slikeOddelek: Programiranje | 1240 (1137) | messi |
» | [android] crashOddelek: Programiranje | 1338 (1147) | messi |