cordova webview posturl
import android.webkit.WebView;
import org.apache.cordova.*;
import org.apache.http.util.EncodingUtils;
public class MainActivity extends CordovaActivity
{
private static Dialog loginDialog;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
String TRAGET_URL = "http://example.com/login/login_verify";
String POST_DATA = "login_id=test&login_pass=1111";
postUrl(TRAGET_URL,POST_DATA);
}
/**
* Load the url into the webview.
*/
public void postUrl(String url,String data) {
if (appView == null) {
init();
}
// If keepRunning
this.keepRunning = preferences.getBoolean("KeepRunning", true);
//appView.lo
WebView mWebView = (WebView) appView.getView();
// WebView mWebView = (WebView) findViewById(R.id.mWebView); // WHERE R.id.mWebView is of course webview in your layout file.
mWebView.postUrl(url,
EncodingUtils.getBytes(data, "BASE64"));
}
}
댓글
댓글 쓰기