2017-02-27 43 views
0

我開發了一個應用程序併發布在playstore上。Android登錄無法正常工作獲取filenotfount例外

直到yestarday的CheckLogin Servlet的工作方式登錄工作文件,但

從今天mornning它不工作

我得到以下異常

02-27 14:43:23.462 32275-6622/com.dhruva.eprintpost W/System.err: java.io.FileNotFoundException: path of URL 
02-27 14:43:23.463 32275-6622/com.dhruva.eprintpost W/System.err:  at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:238) 
02-27 14:43:23.463 32275-6622/com.dhruva.eprintpost W/System.err:  at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210) 
02-27 14:43:23.463 32275-6622/com.dhruva.eprintpost W/System.err:  at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java) 
02-27 14:43:23.463 32275-6622/com.dhruva.eprintpost W/System.err:  at com.dhruva.eprintpost.login.LoginActivity$10.run(LoginActivity.java:513) 
02-27 14:43:23.463 32275-6622/com.dhruva.eprintpost W/System.err:  at java.lang.Thread.run(Thread.java:818) 

和我的登錄發送請求如下

new Thread(new Runnable() { 

          public void run() { 

           try { 

            URL url = new URL(SessionManager.getAmateurPath() + "LoginCheck"); 
            Log.v("Urllll",""+url); 
            URLConnection connection = url.openConnection(); 

            ComStr = "&usrnm=" + email + "&pwd=" + pwd; 
            str = ComStr.getBytes(); 

            Log.d("inputString", email); 
            Log.d("inputString", pwd); 

            connection.setDoOutput(true); 

            connection.setDoInput(true); 
            connection.setRequestProperty("Content=length", String.valueOf(str.length)); 
            os = connection.getOutputStream(); 
            os.write(str); 
            os.flush(); 


            final String status; 
            final BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); 
            status = in.readLine(); 
            Log.d("Status", status); 

            runOnUiThread(new Runnable() { 
             @Override 
             public void run() { 
              handleStatus(status, in); 
             } 
            }); 

           } 
           catch (Exception e) { 
            e.printStackTrace(); 
           } 
          } 
         }).start(); 
+0

檢查。 –

+0

Checket,但它不工作。 –

+0

文件存在server.I從瀏覽器中打開該網址與它在鉻中工作的相應參數 –

回答

0

使用的AsyncTask

private class SendGcmToServer extends AsyncTask<String, Void, String> { 
    ProgressDialog dialog; 

    @Override 
    protected void onPreExecute() { 

     // TODO Auto-generated method stub 
     super.onPreExecute(); 
     dialog = new ProgressDialog(Activity_Register_Login.this); 
     dialog.setMessage("Loading...."); 
     dialog.show(); 
     if (regid.isEmpty()) { 
      Log.e("***************registration_id", regid); 
      regid = registerInBackground(); 

     } 

    } 

    @Override 
    protected String doInBackground(String... params) { 
     // TODO Auto-generated method stub 
     String url_for_getdata = Util.register_url; 
     BufferedReader reader; 


     String url_data = Util.register_url + "?username=" + editText_user_name.getText().toString() + "&password=" + editText_password.getText().toString() + "&vehId=" + edit_text_vehicle_no.getText().toString() + "&regId=" + regid; 
     url_data = url_data.replace("\n", "%20"); 
     url_data = url_data.replace(" ", "%20"); 
     url_data = url_data.replace("'", "%20"); 
     System.out.println("url: " + url_data); 
     try { 
      URL url = new URL(url_data); 
      URLConnection conection = url.openConnection(); 
      conection.setConnectTimeout(5000); 
      conection.setDoOutput(true); 


      reader = new BufferedReader(new InputStreamReader(conection.getInputStream())); 
      StringBuilder result = new StringBuilder(); 
      String line = null; 
      while ((line = reader.readLine()) != null) { 
       result.append(line + ""); 

      } 
      content = result.toString(); 
      System.out.println(content); 
      getcontent_for_validate = content; 


     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
     return content; 


    } 

    @Override 
    protected void onPostExecute(String result) { 
     JSONObject jsonobj; 
     // TODO Auto-generated method stub 
     super.onPostExecute(result); 


     if (result != null) { 
      if (result.equals("failure")) { 
       Toast.makeText(context, "Check your Username or Password", Toast.LENGTH_LONG).show(); 
       dialog.dismiss(); 

      } else {//ths is getting data for vehicl_list_unread_count code, client id,restapi_key 
       try { 
        Log.d(TAG, "onPostExecute: this inner of post" + getcontent_for_validate); 
        jsonobj = new JSONObject(getcontent_for_validate); 
        System.out.println("this is get content" + jsonobj.toString()); 


        JSONArray array = jsonobj.getJSONArray("Staff_Details"); 
        for (int i = 0; i < array.length(); i++) { 
         Clint_id = editText_user_name.getText().toString(); 
         Api_key = array.getJSONObject(i).getString("api_key"); 
         COMPANY_LOGO = array.getJSONObject(i).getString("company_logo"); 
         Password = editText_password.getText().toString(); 
        } 


       } catch (JSONException e) { 
        e.printStackTrace(); 
       } 


       Database_for_user_details db = new Database_for_user_details(Activity_Register_Login.this); 
       db.createEntry_for_clint_details(Clint_id, Password, Api_key, "login", edit_text_vehicle_no.getText().toString(), COMPANY_LOGO); 

       db.createEntry_for_TRIP_STATUS(); 


       Toast.makeText(getApplicationContext(), "Logged-in Successfully", Toast.LENGTH_SHORT).show(); 

       System.out.println("get data" + " " + Clint_id + " " + Api_key); 
       startActivity(new Intent(Activity_Register_Login.this, Activity_dashboard.class)); 
       dialog.dismiss(); 
       finish(); 


      } 


     } else { 
      dialog.dismiss(); 
      Toast.makeText(context, "Check net connection", Toast.LENGTH_LONG).show(); 
     } 

    } 


} 

我希望這將幫助你與你的服務器

+0

這可能不是答案,而問題屬於服務器而不是代碼。 – TruongHieu

+0

你明白了。但他不清楚。 tats y我在android中回答了另一種方式。 –

+0

請給我解決方案。我的應用程序在playstore不起作用,因爲登錄 –