0
在下面的代碼中,我正在做的是從Web服務獲取微調項目。並在項目選擇,一些過程完成。 問題是它沒有從服務器獲取數據到微調器。http連接錯誤javax.net.ssl.SSLPeerUnverifiedException:沒有對等證書
Frnt_mapActivty1.java
/*****************************FOR LOCATION FOR**************************************/
//Download JSON file AsyncTask
public class LocationList extends AsyncTask<Void, Void, Void> {
JSONObject jsonobject;
JSONArray jsonarray;
@Override
protected Void doInBackground(Void... params) {
// Locate the WorldPopulation Class
worldlocation = new ArrayList<LocationBeams>();
// Create an array to populate the spinner
world_locationlist = new ArrayList<String>();
// JSON file URL address
jsonobject = JSONfunctions.getJSONfromURL(Wservices.mGetLocationURL);
try {
// Locate the NodeList name
jsonarray = jsonobject.getJSONArray("location");
for (int i = 0; i < jsonarray.length(); i++) {
jsonobject = jsonarray.getJSONObject(i);
LocationBeams worldpop = new LocationBeams();
worldpop.setTerm_id(jsonobject.optString("term_id"));
worldpop.setName(jsonobject.optString("name"));
worldpop.setSlug(jsonobject.optString("slug"));
worldlocation.add(worldpop);
world_locationlist.add(jsonobject.optString("name"));
}
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void args) {
// Locate the spinner in activity_main.xml
Spinner mySpinner = (Spinner)findViewById(R.id.spin_location);
// Spinner adapter
mySpinner.setAdapter(new ArrayAdapter<String>(Frnt_mapActivity1.this,
android.R.layout.simple_spinner_dropdown_item,world_locationlist));
// Spinner on item click listener
mySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0,
View arg1, int position, long arg3) {
// TODO Auto-generated method stub
txtlocation.setText(worldlocation.get(position).getSlug());
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
if(mDialog!=null && mDialog.isShowing()){
mDialog.dismiss();
}
}
}
登錄
Error in http connection javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
Error converting result java.lang.NullPointerException: lock == null
Error parsing data org.json.JSONException: End of input at character 0 of
FATAL EXCEPTION: AsyncTask #2
Process: com.towncitycards, PID: 29656
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.NullPointerException: println needs a message
at android.util.Log.println_native(Native Method)
at android.util.Log.e(Log.java:334)
at app.towncitycards.activities.Frnt_mapActivity1$LocationList.doInBackground(Frnt_mapActivity1.java:1725)
at app.towncitycards.activities.Frnt_mapActivity1$LocationList.doInBackground(Frnt_mapActivity1.java:1698)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
e.getMessage()返回空消息 –
我有什麼可以用e.getMessage的'代替()'。 – priya
@priya看到我的回答 –