Bonjour la famille, j'ai un lien de json api en Https quand je compile on m'affiche cette erreur (je fais dans un tabhost):
Voici mon Code :
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 04-21 14:48:26.984 5416-5416/com.example.mao.myapplication D/GraphicBuffer: create handle(0x555891b0) (w:480, h:800, f:1) 04-21 14:48:27.014 5416-5473/com.example.mao.myapplication D/libc-netbsd: getaddrinfo: <a href="http://www.parionsdirect.ci" target="_blank">www.parionsdirect.ci</a> NO result from proxy 04-21 14:48:27.015 5416-5473/com.example.mao.myapplication I/System.out: [CDS][DNS]Unable to resolve host "www.parionsdirect.ci": No address associated with hostname 04-21 14:48:27.020 5416-5473/com.example.mao.myapplication W/System.err: java.net.UnknownHostException: Unable to resolve host "www.parionsdirect.ci": No address associated with hostname 04-21 14:48:27.026 5416-5473/com.example.mao.myapplication W/System.err: at java.net.InetAddress.lookupHostByName(InetAddress.java:446) 04-21 14:48:27.026 5416-5473/com.example.mao.myapplication W/System.err: at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236) 04-21 14:48:27.026 5416-5473/com.example.mao.myapplication W/System.err: at java.net.InetAddress.getAllByName(InetAddress.java:214) 04-21 14:48:27.027 5416-5473/com.example.mao.myapplication W/System.err: at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137) 04-21 14:48:27.027 5416-5473/com.example.mao.myapplication W/System.err: at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164) 04-21 14:48:27.027 5416-5473/com.example.mao.myapplication W/System.err: at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119) 04-21 14:48:27.028 5416-5473/com.example.mao.myapplication W/System.err: at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:365) 04-21 14:48:27.028 5416-5473/com.example.mao.myapplication W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:587) 04-21 14:48:27.028 5416-5473/com.example.mao.myapplication W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:511) 04-21 14:48:27.028 5416-5473/com.example.mao.myapplication W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:489) 04-21 14:48:27.029 5416-5473/com.example.mao.myapplication W/System.err: at com.example.mao.myapplication.ServiceHandler.makeServiceCall(ServiceHandler.java:75) 04-21 14:48:27.029 5416-5473/com.example.mao.myapplication W/System.err: at com.example.mao.myapplication.ServiceHandler.makeServiceCall(ServiceHandler.java:39) 04-21 14:48:27.029 5416-5473/com.example.mao.myapplication W/System.err: at com.example.mao.myapplication.CoursesAlr$LoadInbox.doInBackground(CoursesAlr.java:97) 04-21 14:48:27.029 5416-5473/com.example.mao.myapplication W/System.err: at com.example.mao.myapplication.CoursesAlr$LoadInbox.doInBackground(CoursesAlr.java:75) 04-21 14:48:27.029 5416-5473/com.example.mao.myapplication W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:288) 04-21 14:48:27.030 5416-5473/com.example.mao.myapplication W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237) 04-21 14:48:27.030 5416-5473/com.example.mao.myapplication W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 04-21 14:48:27.030 5416-5473/com.example.mao.myapplication W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 04-21 14:48:27.030 5416-5473/com.example.mao.myapplication W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 04-21 14:48:27.030 5416-5473/com.example.mao.myapplication W/System.err: at java.lang.Thread.run(Thread.java:848) 04-21 14:48:27.031 5416-5473/com.example.mao.myapplication W/System.err: Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname) 04-21 14:48:27.045 5416-5416/com.example.mao.myapplication D/GraphicBuffer: create handle(0x55163838) (w:480, h:144, f:1) 04-21 14:48:27.046 5416-5416/com.example.mao.myapplication I/MaliEGL: [Mali]window_type=1, is_framebuffer=0, errnum = 0 04-21 14:48:27.046 5416-5416/com.example.mao.myapplication I/MaliEGL: [Mali]surface->num_buffers=4, surface->num_frames=3, win_min_undequeued=1 04-21 14:48:27.046 5416-5416/com.example.mao.myapplication I/MaliEGL: [Mali]max_allowed_dequeued_buffers=3 04-21 14:48:27.047 5416-5416/com.example.mao.myapplication D/GraphicBuffer: close handle(0x55163838) (w:480 h:144 f:1) 04-21 14:48:27.051 5416-5473/com.example.mao.myapplication W/System.err: at libcore.io.Posix.getaddrinfo(Native Method) 04-21 14:48:27.052 5416-5416/com.example.mao.myapplication D/GraphicBuffer: create handle(0x5558d090) (w:480, h:144, f:1) 04-21 14:48:27.053 5416-5416/com.example.mao.myapplication D/OpenGLRenderer: setViewport 456x144 <0x5558d190> 04-21 14:48:27.056 5416-5473/com.example.mao.myapplication W/System.err: at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:61) 04-21 14:48:27.057 5416-5473/com.example.mao.myapplication W/System.err: at java.net.InetAddress.lookupHostByName(InetAddress.java:412) 04-21 14:48:27.060 5416-5416/com.example.mao.myapplication V/InputMethodManager: Not IME target window, ignoring 04-21 14:48:27.062 5416-5473/com.example.mao.myapplication W/System.err: ... 19 more 04-21 14:48:27.063 5416-5473/com.example.mao.myapplication D/Reponse: >null 04-21 14:48:27.063 5416-5473/com.example.mao.myapplication E/ServiceHandler: Impossible d'avoir les donnees de l'URL 04-21 15:02:54.964 14351-14411/com.example.mao.myapplication W/System.err: javax.net.ssl.SSLPeerUnverifiedException: No peer certificate 04-21 15:02:54.977 14351-14411/com.example.mao.myapplication W/System.err: at com.android.org.conscrypt.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:146) 04-21 15:02:54.977 14351-14411/com.example.mao.myapplication W/System.err: at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:93) 04-21 15:02:54.977 14351-14411/com.example.mao.myapplication W/System.err: at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:388) 04-21 15:02:54.977 14351-14411/com.example.mao.myapplication W/System.err: at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:179) 04-21 15:02:54.978 14351-14411/com.example.mao.myapplication W/System.err: at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164) 04-21 15:02:54.978 14351-14411/com.example.mao.myapplication W/System.err: at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119) 04-21 15:02:54.978 14351-14411/com.example.mao.myapplication W/System.err: at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:365) 04-21 15:02:54.978 14351-14411/com.example.mao.myapplication W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:587) 04-21 15:02:54.978 14351-14411/com.example.mao.myapplication W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:511) 04-21 15:02:54.978 14351-14411/com.example.mao.myapplication W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:489) 04-21 15:02:54.978 14351-14411/com.example.mao.myapplication W/System.err: at com.example.mao.myapplication.ServiceHandler.makeServiceCall(ServiceHandler.java:75) 04-21 15:02:54.978 14351-14411/com.example.mao.myapplication W/System.err: at com.example.mao.myapplication.ServiceHandler.makeServiceCall(ServiceHandler.java:39) 04-21 15:02:54.978 14351-14411/com.example.mao.myapplication W/System.err: at com.example.mao.myapplication.CoursesAlr$LoadInbox.doInBackground(CoursesAlr.java:97) 04-21 15:02:54.978 14351-14411/com.example.mao.myapplication W/System.err: at com.example.mao.myapplication.CoursesAlr$LoadInbox.doInBackground(CoursesAlr.java:75) 04-21 15:02:54.978 14351-14411/com.example.mao.myapplication W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:288) 04-21 15:02:54.978 14351-14411/com.example.mao.myapplication W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237) 04-21 15:02:54.979 14351-14411/com.example.mao.myapplication W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 04-21 15:02:54.979 14351-14411/com.example.mao.myapplication W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 04-21 15:02:54.979 14351-14411/com.example.mao.myapplication W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 04-21 15:02:54.979 14351-14411/com.example.mao.myapplication W/System.err: at java.lang.Thread.run(Thread.java:848) 04-21 15:02:54.979 14351-14411/com.example.mao.myapplication D/Reponse: >null 04-21 15:02:54.979 14351-14411/com.example.mao.myapplication E/ServiceHandler: Impossible d'avoir les donnees de l'URL
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219 private ProgressDialog pDialog; private static final String INBOX_URL = "https://www.parionsdirect.ci/api/mobile/get_horses_list/N1"; // ALL JSON node names private static final String TAG_LISTE_CHEVAUX = "liste_chevaux"; private static final String TAG_TICKET_NUMBER = "num"; private static final String TAG_REF_NUMBER = "nom_cheval"; private static final String TAG_TRANSACTION_ID = "distance"; private static final String TAG_AUDIT_NUMBER = "temps"; private static final String TAG_BET_COST_AMOUNT = "sexe_age"; private static final String TAG_BET_PAYOUT = "drivers"; private static final String TAG_BET_CODE = "entraineur"; private static final String TAG_BET_MODIFIER = "proprietaire"; private static final String TAG_SELECTION1 = "origine"; private static final String TAG_SELECTION2 = "gains"; private static final String TAG_REPEATS = "cote"; private static final String TAG_SPECIAL_ENTRIES = "partant"; // contacts JSONArray JSONArray contacts = null; // Hashmap for ListView ArrayList<HashMap<String, String>> contactList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.coursealr); contactList = new ArrayList<HashMap<String, String>>(); // Loading INBOX in Background Thread new LoadInbox().execute(); } /** * Background Async Task to Load all INBOX messages by making HTTP Request * */ class LoadInbox extends AsyncTask<Void, Void, Void> { @Override protected void onPreExecute() { super.onPreExecute(); //Showing progress dialog pDialog = new ProgressDialog(CoursesAlr.this); pDialog.setMessage("Veillez patientez..."); pDialog.setIndeterminate(false); pDialog.setCancelable(false); pDialog.show(); } @Override protected Void doInBackground(Void... params) { // Creating service handler class instance ServiceHandler sh = new ServiceHandler(); // Making a request to url and getting response String json = sh.makeServiceCall(INBOX_URL, ServiceHandler.GET); Log.d("Reponse", ">" + json); if (json != null){ try { JSONObject jsonObject = new JSONObject(json); // Getting JSON Array node contacts = jsonObject.getJSONArray(TAG_LISTE_CHEVAUX); // looping through All Contacts for (int i = 0; i < contacts.length(); i++) { JSONObject c = contacts.getJSONObject(i); // Storing each json item in variable String ticket = c.getString(TAG_TICKET_NUMBER); String ref = c.getString(TAG_REF_NUMBER); String transaction = c.getString(TAG_TRANSACTION_ID); String audit = c.getString(TAG_AUDIT_NUMBER); String cost = c.getString(TAG_BET_COST_AMOUNT); String payout = c.getString(TAG_BET_PAYOUT); String code = c.getString(TAG_BET_CODE); String modifier = c.getString(TAG_BET_MODIFIER); String select = c.getString(TAG_SELECTION1); String selection = c.getString(TAG_SELECTION2); String repeats = c.getString(TAG_REPEATS); String special = c.getString(TAG_SPECIAL_ENTRIES); // creating new HashMap HashMap<String, String> contact = new HashMap<String, String>(); // adding each child node to HashMap key => value contact.put(TAG_TICKET_NUMBER, ticket); contact.put(TAG_REF_NUMBER, ref); contact.put(TAG_TRANSACTION_ID, transaction); contact.put(TAG_AUDIT_NUMBER, audit); contact.put(TAG_BET_COST_AMOUNT, cost); contact.put(TAG_BET_PAYOUT, payout); contact.put(TAG_BET_CODE, code); contact.put(TAG_BET_MODIFIER, modifier); contact.put(TAG_SELECTION1, select); contact.put(TAG_SELECTION2, selection); contact.put(TAG_REPEATS, repeats); contact.put(TAG_SPECIAL_ENTRIES, special); // adding HashList to ArrayList contactList.add(contact); } } catch (JSONException e) { e.printStackTrace(); } }else{ Log.e("ServiceHandler", "Impossible d'avoir les donnees de l'URL"); } return null; } /** * After completing background task Dismiss the progress dialog * **/ protected void onPostExecute(Void file_url) { super.onPostExecute(file_url); // dismiss the dialog after getting all products if (pDialog.isShowing()) pDialog.dismiss(); /** * Updating parsed JSON data into ListView * */ ListAdapter adapter = new SimpleAdapter( CoursesAlr.this, contactList, R.layout.list_item_list, new String[] { TAG_TICKET_NUMBER, TAG_REF_NUMBER, TAG_TRANSACTION_ID, TAG_AUDIT_NUMBER }, new int[] { R.id.ticket_number, R.id.ref_number, R.id.transaction_id, R.id.audit_number }); // updating listview setListAdapter(adapter); } } VOICI LET SERCIHANDLER: static String response = null; public final static int GET = 1; public final static int POST = 2; public ServiceHandler() { } /** * Making service call * @url - url to make request * @method - http request method * */ public String makeServiceCall(String url, int method) { return this.makeServiceCall(url, method, null); } /** * Making service call * @url - url to make request * @method - http request method * @params - http request params * */ public String makeServiceCall(String url, int method, List<NameValuePair> params) { try { // http client DefaultHttpClient httpClient = new DefaultHttpClient(); HttpEntity httpEntity = null; HttpResponse httpResponse = null; // Checking http request method type if (method == POST) { HttpPost httpPost = new HttpPost(url); // adding post params if (params != null) { httpPost.setEntity(new UrlEncodedFormEntity(params)); } httpResponse = httpClient.execute(httpPost); } else if (method == GET) { if (params != null) { String paramString = URLEncodedUtils .format(params, "utf-8"); url += "?" + paramString; } HttpGet httpGet = new HttpGet(url); httpResponse = httpClient.execute(httpGet); } httpEntity = httpResponse.getEntity(); response = EntityUtils.toString(httpEntity); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return response; }
Partager