android登录post方法
嗨,我从android开发开始,我必须创建一个登录表单,点击一个按钮,它会发送这个:。 在这里搜索,我发现了一种方法,Vikas Patidar上传了nad,我试图根据自己的需要修改它。但我觉得有点不对劲,因为它不起作用。 你能告诉我我错在哪里吗 这是密码 ` xml如下所示:android登录post方法,android,post,login,Android,Post,Login,嗨,我从android开发开始,我必须创建一个登录表单,点击一个按钮,它会发送这个:。 在这里搜索,我发现了一种方法,Vikas Patidar上传了nad,我试图根据自己的需要修改它。但我觉得有点不对劲,因为它不起作用。 你能告诉我我错在哪里吗 这是密码 ` xml如下所示: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/re
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText
android:hint="Username"
android:id="@+id/U"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</EditText>
<EditText
android:hint="Password"
android:id="@+id/K"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textPassword">
</EditText>
<Button
android:text="Iniciar Sessió"
android:id="@+id/login"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
它说:'标记“字节”上的语法错误,删除此标记'
如果我删除它,我会在reaction中得到更多的错误
我该怎么办?删除
The conn.setRequestMethod("POST");
然后是conn.setDoOutput(true)代码>已表示您正在使用POST通信
下一个
request.write(parameters);
request.flush();
request.close();
换成
request.write(parameters.getBytes());
request.flush();
//request.close();//it is closing prematurly so you will definitely not get any response at all...
试试这些,如果结果好的话让我知道
如果你想试试看,它看起来和你的情况差不多
也许这会对图奥有帮助。。。。回应 它解决了你的问题吗。。。如果是的话,你介意指出我的答案作为你问题的答案吗。。如果没有。。。你能告诉我你试过什么吗?嗨,首先谢谢你的帮助!它不起作用。如果我更改“request.write(parameters.getBytes());”,它会在“write”选项上给我一个错误:“OutputStreamWriter类型中的write(int)方法不适用于参数(byte[]),我认为它不会向我要调用的url发送任何内容。问题是我无法获得对/frmlogin.aspx的物理访问权限…他们告诉我,使用此url:'',我必须获得对表单的访问权限。顺便说一句,我也检查了你给我的例子,但我认为这对于我的android开发实际知识来说太复杂了:请让我为你的案例写下它,并附加到我的答案中。我发现你使用的是post协议对吧。。。或者说是获取方法。
The conn.setRequestMethod("POST");
request.write(parameters);
request.flush();
request.close();
request.write(parameters.getBytes());
request.flush();
//request.close();//it is closing prematurly so you will definitely not get any response at all...