【问题标题】:PostURL in WEBVIEW in androidandroid中WEBVIEW中的PostURL
【发布时间】:2014-05-23 08:27:08
【问题描述】:

我想在 android 中使用 webview 发布数据。试过下面的代码,

String postdata="username=abcd";
myWebView.postUrl(url, EncodingUtils.getBytes(postData, "BASE64"));

但没有得到想要的输出。如果有其他方法可以在 webview 中发布数据,请告诉我。

在 IOS 中也进行了同样的操作,并成功实施。下面是IOS中的代码:

NSString *loginUrl = @"https://www.abcdefgh.com/SellOnline/j_spring_check";
    NSURL *url = [NSURL URLWithString:loginUrl];
    NSMutableURLRequest *requestObj = [NSMutableURLRequest requestWithURL:url];

    // POST the username password
    [requestObj setHTTPMethod:@"POST"];
    NSString *postString = [NSString stringWithFormat:@"agent=%@", @"839878"];
    NSData *data = [postString dataUsingEncoding: NSUTF8StringEncoding];
    [requestObj setHTTPBody:data];

    self.webview.delegate = self;
    [self.webview loadRequest:requestObj];\ 

【问题讨论】:

  • 你得到什么输出?因为这在我看来是正确的,所以也许您忘记了您的 postdata 中的某些内容?我需要更多信息。
  • 我希望 web 视图中的页面通过登录会话打开,但现在它要求我提供登录凭据。
  • 您的意思是您正在登录本机应用程序,例如使用 webservice(http 调用)以及您希望通过 webview 与 httpclient 的同一会话进行的一些进一步处理。简而言之,您正在尝试在 webview 和 Httpclient 之间同步 cookie 对吗?
  • @Biraj- 是的,你是对的。本地登录后,我试图在 webview 中发布 url
  • 使用“UTF-8”更改 Base64 这可能会有所帮助

标签: android post webview http-post


【解决方案1】:
out_marginLeft="50dp"
            android:layout_marginTop="50dp"
            android:layout_marginRight="50dp"
            android:gravity="center"
            android:orientation="vertical">

            <ProgressBar
                android:id="@+id/progressBar"
                style="?android:attr/progressBarStyleHorizontal"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_above="@+id/txtProgress"
                android:layout_centerHorizontal="true"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:progress="50"
                android:progressTint="@android:color/black" />

            <TextView
                android:id="@+id/txtProgress"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:text="Progress"
                android:textColor="@android:color/black" />
        </LinearLayout>  

Java

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-20
    • 2013-05-02
    • 2011-12-11
    • 1970-01-01
    • 2012-11-10
    • 2014-11-05
    • 2017-06-25
    • 1970-01-01
    相关资源
    最近更新 更多