安装了XAMPP服务器,创建了数据库并成功从chrome浏览器以及android模拟器访问它。但是,每当我尝试从我的三星设备运行应用程序时,它拒绝连接我的IP地址。
我的IP地址未在DNS中注册。
我试过了: 1)从url-127.0.0.1和localhost访问 2)修改了httpd.conf和httpd-xampp.conf文件 - 更改为要求所有授予的权限 3)卸载了我的防病毒软件 4)更改了防火墙和代理设置 5)在防火墙高级安全性中创建新的入站规则 6)重新输入INTERNET权限 7)写了httpPost.setHeader(" Accept"," application / json");在代码中
我仍然得到以下错误:
W/IInputConnectionWrapper(22232): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper(22232): setComposingText on inactive InputConnection
W/IInputConnectionWrapper(22232): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper(22232): setComposingText on inactive InputConnection
D/request!(22232): starting
W/System.err(22232): org.apache.http.conn.HttpHostConnectException: Connection to
http://192.XXX.X.XXX refused
W/System.err(22232): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:183)
W/System.err(22232): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
W/System.err(22232): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
W/System.err(22232): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
W/System.err(22232): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
W/System.err(22232): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
W/System.err(22232): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
W/System.err(22232): at com.example.mysqltest.JSONParser.makeHttpRequest(JSONParser.java:111)
W/System.err(22232): at com.example.mysqltest.Login$AttemptLogin.doInBackground(Login.java:121)
W/System.err(22232): at com.example.mysqltest.Login$AttemptLogin.doInBackground(Login.java:1)
W/System.err(22232): at android.os.AsyncTask$2.call(AsyncTask.java:287)
W/System.err(22232): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
W/System.err(22232): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
W/System.err(22232): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
W/System.err(22232): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
W/System.err(22232): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
W/System.err(22232): at java.lang.Thread.run(Thread.java:856)
W/System.err(22232): Caused by: java.net.ConnectException: failed to connect to /192.168.0.114 (port 80): connect failed: ETIMEDOUT (Connection timed out)
W/System.err(22232): at libcore.io.IoBridge.connect(IoBridge.java:114)
W/System.err(22232): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
W/System.err(22232): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:460)
W/System.err(22232): at java.net.Socket.connect(Socket.java:832)
W/System.err(22232): at `enter code here`org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
W/System.err(22232): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)
W/System.err(22232): ... 16 more
W/System.err(22232): Caused by: libcore.io.ErrnoException: connect failed: ETIMEDOUT (Connection timed out)
W/System.err(22232): at libcore.io.Posix.connect(Native Method)
W/System.err(22232): at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:85)
W/System.err(22232): at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
W/System.err(22232): at libcore.io.IoBridge.connect(IoBridge.java:112)
W/System.err(22232): ... 21 more
E/Buffer Error(22232): Error converting result java.lang.NullPointerException
E/JSON Parser(22232): Error parsing data org.json.JSONException: End of input at character 0 of
W/dalvikvm(22232): threadid=12: thread exiting with uncaught exception (group=0x41180438)
E/AndroidRuntime(22232): FATAL EXCEPTION: AsyncTask #1
E/AndroidRuntime(22232): java.lang.RuntimeException: An error occured while executing doInBackground()
E/AndroidRuntime(22232): at android.os.AsyncTask$3.done(AsyncTask.java:299)
E/AndroidRuntime(22232): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
E/AndroidRuntime(22232): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
E/AndroidRuntime(22232): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
E/AndroidRuntime(22232): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
E/AndroidRuntime(22232): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
E/AndroidRuntime(22232): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
E/AndroidRuntime(22232): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
E/AndroidRuntime(22232): at java.lang.Thread.run(Thread.java:856)
E/AndroidRuntime(22232): Caused by: java.lang.NullPointerException
E/AndroidRuntime(22232): at com.example.mysqltest.Login$AttemptLogin.doInBackground(Login.java:125)
E/AndroidRuntime(22232): at com.example.mysqltest.Login$AttemptLogin.doInBackground(Login.java:1)
E/AndroidRuntime(22232): at android.os.AsyncTask$2.call(AsyncTask.java:287)
E/AndroidRuntime(22232): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
E/AndroidRuntime(22232): ... 5 more
I/Choreographer(22232): Skipped 1143 frames! The application may be doing too much work on its main thread.
E/WindowManager(22232): Activity com.example.mysqltest.Login has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41bea8a8 that was originally added here
E/WindowManager(22232): android.view.WindowLeaked: Activity com.example.mysqltest.Login has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41bea8a8 that was originally added here
E/WindowManager(22232): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:419)
E/WindowManager(22232): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:322)
E/WindowManager(22232): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:234)
E/WindowManager(22232): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:153)
E/WindowManager(22232): at android.view.Window$LocalWindowManager.addView(Window.java:557)
E/WindowManager(22232): at android.app.Dialog.show(Dialog.java:277)
E/WindowManager(22232): at com.example.mysqltest.Login$AttemptLogin.onPreExecute(Login.java:103)
E/WindowManager(22232): at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586)
E/WindowManager(22232): at android.os.AsyncTask.execute(AsyncTask.java:534)
E/WindowManager(22232): at com.example.mysqltest.Login.onClick(Login.java:77)
E/WindowManager(22232): at android.view.View.performClick(View.java:4191)
E/WindowManager(22232): at android.view.View$PerformClick.run(View.java:17229)
E/WindowManager(22232): at android.os.Handler.handleCallback(Handler.java:615)
E/WindowManager(22232): at android.os.Handler.dispatchMessage(Handler.java:92)
E/WindowManager(22232): at android.os.Looper.loop(Looper.java:137)
E/WindowManager(22232): at android.app.ActivityThread.main(ActivityThread.java:4960)
E/WindowManager(22232): at java.lang.reflect.Method.invokeNative(Native Method)
E/WindowManager(22232): at java.lang.reflect.Method.invoke(Method.java:511)
E/WindowManager(22232): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
E/WindowManager(22232): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
E/WindowManager(22232): at dalvik.system.NativeStart.main(Native Method)"
答案 0 :(得分:0)
请尝试检查您PC的本地IP地址。将手机连接到同一网络(WIFI)。然后使用以下地址/端口连接到您的PC。
在Android中:
网址:your_pc_local_ip
PORT:80
(但我认为这不是强制性的)
我以这种方式使用,它对我来说正常。