-1
내 안드로이드 응용 프로그램에 데이터를 가져 오기 위해 webservice를 호출하려고 할 때 다음 코드를 사용합니다.안드로이드 에뮬레이터 및 안드로이드 버전에서 Filenot 예외가 발견되었습니다. <3.0
URL url = new URL(urls[0]);
Log.i("URL", urls[0].toString());
String data=AppData.getKeyId();
System.out.println("http key: "+data);
URLConnection connection = url.openConnection();
connection.setRequestProperty("encryptText", data);
connection.setConnectTimeout(50000);
connection.setRequestProperty("Cookie", "JSESSIONID=" + Data.getInstance().getSessionId());
InputStream is = connection.getInputStream();
System.out.println("Resp Code"+ ((HttpURLConnection) connection).getResponseCode());
if (((HttpURLConnection) connection).getResponseCode() == 200) return getStringFromInputStream(is);
위의 코드는 내가 안드로이드 에뮬레이터에서 응용 프로그램과 안드로이드 버전 < 3.0을 실행하려고하지만, 위의 버전 3에서 잘 작동 할 때 나를 찾을 수 없습니다 예외 파일 제공 (3, 4.0 및 4.4에서 테스트) . 인터넷 사용 권한은 Android 매니페스트에서도 설정됩니다. 가능한 문제가 무엇입니까? 여기
내 로그 캣
> 01-16 02:17:51.684: W/System.err(336): java.io.FileNotFoundException:
> http://192.168.1.2:7029/FieldForceAutomation/service/PreSalesResource/Customer/Save?custName=newcustomer
> &custProf=Nil&addrs=avadi road
> &addline1=&addline2=&cityId=2&areaId=2&pincode=000000&resno=0&offno=00000000&mobno=5555555589&[email protected]&secName=&profWa=&altEmail=None&dcr_no=2001640928&comments=&hasPC=0&serviceProviderId=1&bandwidth=0&status=2&calltypeId=3&custTypeId=1&followUpDate=00210706&createDate=20140116&created_time=02:15:28&chkFeasible=false&[email protected]
> 01-16 02:17:51.694: W/System.err(336): at
> org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:521)
> 01-16 02:17:51.704: W/System.err(336): at
> com.act.Util.HttpReq$Req.doInBackground(HttpReq.java:74) 01-16
> 02:17:51.704: W/System.err(336): at
> com.act.Util.HttpReq$Req.doInBackground(HttpReq.java:1) 01-16
> 02:17:51.704: W/System.err(336): at
> android.os.AsyncTask$2.call(AsyncTask.java:185) 01-16 02:17:51.714:
> W/System.err(336): at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
> 01-16 02:17:51.723: W/System.err(336): at
> java.util.concurrent.FutureTask.run(FutureTask.java:138) 01-16
> 02:17:51.723: W/System.err(336): at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
> 01-16 02:17:51.723: W/System.err(336): at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
> 01-16 02:17:51.733: W/System.err(336): at
> java.lang.Thread.run(Thread.java:1019) 01-16 02:17:51.814:
> D/AndroidRuntime(336): Shutting down VM 01-16 02:17:51.814:
> W/dalvikvm(336): threadid=1: thread exiting with uncaught exception
> (group=0x40015560) 01-16 02:17:51.844: E/AndroidRuntime(336): FATAL
> EXCEPTION: main 01-16 02:17:51.844: E/AndroidRuntime(336):
> java.lang.NullPointerException 01-16 02:17:51.844:
> E/AndroidRuntime(336): at
> com.act.PreSalesFormActivity$5$2.onClick(PreSalesFormActivity.java:1394)
> 01-16 02:17:51.844: E/AndroidRuntime(336): at
> android.view.View.performClick(View.java:2485) 01-16 02:17:51.844:
> E/AndroidRuntime(336): at
> android.view.View$PerformClick.run(View.java:9080) 01-16 02:17:51.844:
> E/AndroidRuntime(336): at
> android.os.Handler.handleCallback(Handler.java:587) 01-16
> 02:17:51.844: E/AndroidRuntime(336): at
> android.os.Handler.dispatchMessage(Handler.java:92) 01-16
> 02:17:51.844: E/AndroidRuntime(336): at
> android.os.Looper.loop(Looper.java:123) 01-16 02:17:51.844:
> E/AndroidRuntime(336): at
> android.app.ActivityThread.main(ActivityThread.java:3683) 01-16
> 02:17:51.844: E/AndroidRuntime(336): at
> java.lang.reflect.Method.invokeNative(Native Method) 01-16
> 02:17:51.844: E/AndroidRuntime(336): at
> java.lang.reflect.Method.invoke(Method.java:507) 01-16 02:17:51.844:
> E/AndroidRuntime(336): at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
> 01-16 02:17:51.844: E/AndroidRuntime(336): at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 01-16
> 02:17:51.844: E/AndroidRuntime(336): at
> dalvik.system.NativeStart.main(Native Method)
505 응답 코드를 반환합니다. – user3200361
오류가 해결되었습니다. URL 인코딩 문제로 판명되었습니다. 고맙습니다. – user3200361