Bonjour,

J'essaye de mettre en place une page "Login" en place sur mon application (Android 5.1 API 22). Pour cela je passe pas un "services web php".
J'ai verifié mon url qui est bien valide, j'effectue la connexion avec HttpURLConnection dans une classe hérité de AsyncTask. J'ai simplifie mon code au maximum pour tester uniquement la connexion sans succès, j'ai testé pas mal de chose et j'avoue que je suis un peu perdu

Ma page "Login" :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.example.toto42.myapp;
 
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
 
import java.util.regex.Matcher;
import java.util.regex.Pattern;
 
public class LogIn extends AppCompatActivity implements View.OnClickListener {
    protected EditText login = null;
    protected EditText pass = null;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_log_in);
 
        login = (EditText) findViewById(R.id.acc_email);
        pass = (EditText) findViewById(R.id.acc_password);
        final Button connexion = (Button) findViewById(R.id.acc_connexion);
 
        connexion.setOnClickListener(this);
    }
 
    @Override
    public void onClick(View v) {
        final String email = login.getText().toString();
        final String password = pass.getText().toString();
 
        if (email.equals("") || password.equals("")) {
            Toast.makeText(LogIn.this, R.string.acc_error_empty, Toast.LENGTH_SHORT).show();
            return;
        }
        Pattern pattern = Pattern.compile(".+@+[a-z]+.[a-z]+");
        Matcher matcher = pattern.matcher(email);
        if (!matcher.matches()) {
            Toast.makeText(LogIn.this, R.string.acc_error_email, Toast.LENGTH_SHORT).show();
            return;
        }
        getUser();
    }
 
    private void getUser() {
        new WebService().execute();
    }
}
Ma classe "WebService"
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.example.toto42.myapp;
 
import android.os.AsyncTask;
import android.util.Log;
 
import com.google.gson.Gson;
 
import org.json.JSONObject;
 
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
 
/**
 * Created by toto42 on 16/09/15.
 */
public class WebService extends AsyncTask<Void, Void, Void> {
    private String urlLogin =  "http://mobile_app.olympe.in/login.php";
 
    @Override
    protected Void doInBackground(Void... params) {
 
        int idUser = getIdUser();
        Log.d("idUser", "AsyncTask " + idUser);
        return null;
    }
 
    private InputStream sendRequest(URL url) throws Exception {
        try {
            HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
            urlConnection.setDoOutput(true);
            urlConnection.setRequestMethod("GET");
 
            urlConnection.connect();
            if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
                return urlConnection.getInputStream();
            }
        } catch (MalformedURLException e) {
            Log.d("Web service", "MalformedURL");
        } catch (IOException e) {
            Log.d("Web service", "IOException");
        } catch (Exception e) {
            throw new Exception("input stream");
        }
        return null;
    }
 
    public int getIdUser() {
        try {
            InputStream inputStream = sendRequest(new URL(urlLogin));
 
            if (inputStream != null) {
                InputStreamReader reader = new InputStreamReader(inputStream);
                JSONObject job = new Gson().fromJson(reader, JSONObject.class);
 
                String result = job.get("Id").toString();
                return Integer.parseInt(result.toString());
            }
        } catch (MalformedURLException e) {
            Log.d("Web service", "getIdUSER  1");
            e.printStackTrace();
        } catch (Exception e) {
            Log.d("Web service", "getIdUSER  2");
            e.printStackTrace();
        }
        return -1;
    }
}
J'ajoute également le Logcat
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 
09-16 23:05:57.393    1217-1685/? I/ActivityManager﹕ START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.therou_g.myapp/.LogIn} from uid 0 on display 0
09-16 23:05:57.393    1217-1685/? V/WindowManager﹕ addAppToken: AppWindowToken{22bab936 token=Token{242d4ad1 ActivityRecord{350d05f8 u0 com.example.therou_g.myapp/.LogIn t7}}} to stack=1 task=7 at 0
09-16 23:05:57.397    1217-1243/? V/WindowManager﹕ Adding window Window{8d8309 u0 Starting com.example.therou_g.myapp} at 2 of 7 (after Window{3ee0011c u0 com.android.launcher/com.android.launcher2.Launcher})
09-16 23:05:57.405    2398-2398/? D/AndroidRuntime﹕ Shutting down VM
09-16 23:05:57.406    2398-2400/? I/art﹕ Debugger is no longer active
09-16 23:05:57.410    2407-2407/? I/art﹕ Not late-enabling -Xcheck:jni (already on)
09-16 23:05:57.415    1217-1234/? I/ActivityManager﹕ Start proc 2407:com.example.therou_g.myapp/u0a46 for activity com.example.therou_g.myapp/.LogIn
09-16 23:05:57.418    2398-2406/? E/art﹕ Thread attaching while runtime is shutting down: Binder_1
09-16 23:05:57.418    2398-2406/? I/AndroidRuntime﹕ NOTE: attach of thread 'Binder_1' failed
09-16 23:05:57.537    2407-2422/? D/OpenGLRenderer﹕ Use EGL_SWAP_BEHAVIOR_PRESERVED: true
09-16 23:05:57.538    2407-2407/? D/﹕ HostConnection::get() New Host Connection established 0xb42b3e60, tid 2407
09-16 23:05:57.539    2407-2407/? D/Atlas﹕ Validating map...
09-16 23:05:57.540    1217-1682/? V/WindowManager﹕ Adding window Window{3f01dbe6 u0 com.example.therou_g.myapp/com.example.therou_g.myapp.LogIn} at 2 of 8 (before Window{8d8309 u0 Starting com.example.therou_g.myapp})
09-16 23:05:57.584    2407-2422/? D/﹕ HostConnection::get() New Host Connection established 0xb43f50e0, tid 2422
09-16 23:05:57.588    2407-2422/? I/OpenGLRenderer﹕ Initialized EGL, version 1.4
09-16 23:05:57.601    2407-2422/? D/OpenGLRenderer﹕ Enabling debug mode 0
09-16 23:05:57.615    2407-2422/? W/EGL_emulation﹕ eglSurfaceAttrib not implemented
09-16 23:05:57.615    2407-2422/? W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xb42ce5a0, error=EGL_SUCCESS
09-16 23:05:58.221    2407-2407/? I/Choreographer﹕ Skipped 40 frames!  The application may be doing too much work on its main thread.
09-16 23:05:58.290    1217-1243/? I/ActivityManager﹕ Displayed com.example.therou_g.myapp/.LogIn: +893ms
09-16 23:06:00.956    1217-1309/? D/TaskPersister﹕ removeObsoleteFile: deleting file=6_task.xml
09-16 23:06:06.859     930-1298/? W/AudioPolicyManager﹕ getOutput() could not find output for stream 1, samplingRate 0,format 0, channels 3, flags 0
09-16 23:06:06.859     930-2060/? W/AudioPolicyManager﹕ getOutput() could not find output for stream 1, samplingRate 0,format 0, channels 3, flags 0
09-16 23:06:06.860      930-930/? W/AudioPolicyManager﹕ getOutput() could not find output for stream 1, samplingRate 48000,format 1, channels 3, flags 4
09-16 23:06:06.860    1217-1297/? E/AudioTrack﹕ Could not get audio output for stream type 1, usage 0, sample rate 48000, format 0x1, channel mask 0x3, flags 0x4
09-16 23:06:06.863    1217-1297/? E/SoundPool﹕ Error creating AudioTrack
09-16 23:06:06.866    2407-2426/? D/Web service﹕ getIdUSER  2
09-16 23:06:06.866    2407-2426/? W/System.err﹕ java.lang.Exception: input stream
09-16 23:06:06.866    2407-2426/? W/System.err﹕ at com.example.therou_g.myapp.WebService.sendRequest(WebService.java:46)
09-16 23:06:06.866    2407-2426/? W/System.err﹕ at com.example.therou_g.myapp.WebService.getIdUser(WebService.java:53)
09-16 23:06:06.866    2407-2426/? W/System.err﹕ at com.example.therou_g.myapp.WebService.doInBackground(WebService.java:26)
09-16 23:06:06.866    2407-2426/? W/System.err﹕ at com.example.therou_g.myapp.WebService.doInBackground(WebService.java:20)
09-16 23:06:06.867    2407-2426/? W/System.err﹕ at android.os.AsyncTask$2.call(AsyncTask.java:292)
09-16 23:06:06.867    2407-2426/? W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:237)
09-16 23:06:06.867    2407-2426/? W/System.err﹕ at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
09-16 23:06:06.867    2407-2426/? W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
09-16 23:06:06.867    2407-2426/? W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
09-16 23:06:06.867    2407-2426/? W/System.err﹕ at java.lang.Thread.run(Thread.java:818)
09-16 23:06:06.867    2407-2426/? D/idUser﹕ AsyncTask -1
N'étant pas un grand habitué des forums j'espère n'avoir rien oublié.

Merci par avance a ceux qui prendrons la peine de me lire.