Android Wifi连接 [英] Android Wifi Connection

查看:76
本文介绍了Android Wifi连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,我在android中创建了我的应用程序,它在第一页执行验证任务。我通过php文件发送参数,该文件存储在我的xampp / htdoc / android_connect文件夹中。对不,我的笔记本电脑只是我的服务器。当我在Android模拟器中运行我的应用程序与本地区域连接它工作正常。但是当我在我的平板电脑上运行它连接到我的wifi和我的笔记本电脑也连接到wifi它不要调用那个php文件请给我一些解决方案来正确运行它。我会非常感谢你...请帮助我...请。



笔记本电脑ipaddress当我连接到wifi时是

192.168.1.101

我的平板电脑ipaddress是

192.168.1.103



我的安卓代码我用这个:::在服务器上发帖



 httpclient = < span class =code-keyword> new  DefaultHttpClient(); 
// httppost = new HttpPost(http://192.168.32.203/android_connect/check.php );
httppost = new HttpPost( http://192.168.1.101/android_connect/check.php);
// httppost = new HttpPost(http://192.168.137.1/android_connect/check.php );
// httppost = new HttpPost(http://192.168.32.203/ android_connect / insert.php); //确保网址正确。
// 添加数据
nameValuePairs = new ArrayList< NameValuePair>( 3 );
// 始终使用相同的变量名称进行发布,即android侧变量名和php侧变量名应该相似,
nameValuePairs。 add new BasicNameValuePair( username,et.getText()。toString()。trim())); // $ Edittext_value = $ _POST ['Edittext_value'];
nameValuePairs。添加 new BasicNameValuePair( 密码,pass.getText()的toString()修剪()))。。

nameValuePairs。 add new BasicNameValuePair( type,agent.getContext()。toString()。trim()));
httppost.setEntity( new UrlEncodedFormEntity(nameValuePairs));
// 执行HTTP发布请求
response = httpclient.execute(httppost) ;

解决方案

Edittext_value =


_POST ['Edittext_value'];
nameValuePairs。 add new BasicNameValuePair( password,pass.getText()。toString()。trim()));

nameValuePairs。 add new BasicNameValuePair( type,agent.getContext()。toString()。trim()));
httppost.setEntity( new UrlEncodedFormEntity(nameValuePairs));
// 执行HTTP发布请求
response = httpclient.execute(httppost) ;


Guys, I have created my application in android which perform validation task in its first page .i am sending the parameters through php file which is stored in my xampp/htdoc/android_connect folder. right noe my laptop is my server only .when i run my application in android emulator with local area connection it works fine.but when i run it in on my tablet which is connected to my wifi and my laptop is also connected to wifi it does not calling that php file please give me some solution to run it properly.i will be so thankfull to you..please help me...please .

laptop ipaddress when i connect it to wifi is
192.168.1.101
and my tablet ipaddress is
192.168.1.103

in my android code i am using this:::to post on server

httpclient=new DefaultHttpClient();
           // httppost= new HttpPost("http://192.168.32.203/android_connect/check.php");
           httppost= new HttpPost("http://192.168.1.101/android_connect/check.php");
          //  httppost= new HttpPost("http://192.168.137.1/android_connect/check.php");
            //httppost= new HttpPost("http://192.168.32.203/android_connect/insert.php"); // make sure the url is correct.
            //add your data
            nameValuePairs = new ArrayList<NameValuePair>(3);
            // Always use the same variable name for posting i.e the android side variable name and php side variable name should be similar,
            nameValuePairs.add(new BasicNameValuePair("username",et.getText().toString().trim()));  // $Edittext_value = $_POST['Edittext_value'];
            nameValuePairs.add(new BasicNameValuePair("password",pass.getText().toString().trim()));

            nameValuePairs.add(new BasicNameValuePair("type",agent.getContext().toString().trim()));
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            //Execute HTTP Post Request
            response=httpclient.execute(httppost);

解决方案

Edittext_value =


_POST['Edittext_value']; nameValuePairs.add(new BasicNameValuePair("password",pass.getText().toString().trim())); nameValuePairs.add(new BasicNameValuePair("type",agent.getContext().toString().trim())); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); //Execute HTTP Post Request response=httpclient.execute(httppost);


这篇关于Android Wifi连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆