开发者

Logging in to site from own form without Webview

Hi I am trying to figure out how to log on to a site from my own Android form in a app, without using Webview so then when its authenticated I can then parse the HTML content of the next page. All I need is to enter the username the password is not necessary.

The HTML is as follows

<form id="ism_login" action="/M/home.mc" method="POST"> 
<fieldset> 
<legend><h2>Login</h2></legend> 
<label>Username</label> 
<input type="text" inputmode="cyrillic predictOff" id="user_name" name="user_name"         size="15" /> 
<input type="submit" name="submit" id="ism_submit" value="Go" /> 
<input type="hidden" name="FPL|is_playing_game_cb" value="1" /> 

here is the test.java

package com.test;
public class test extends Activity {
/** Called when the activity is first created. */
private static EditText edit;
private TextView text;
private String userName;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    edit = (EditText) findViewById(R.id.editTxt);

    Button logIn = (Button) findViewById(R.id.logIn);
    //Set up listeners
    logIn.setOnClickListener(new View.OnClickListener() {
        public void onClic开发者_C百科k(View v) {

            userName = edit.getText().toString();


        }
    });


   }//onCreate
 }

If you could help me that would be great thanks.


You can still use a webview but then attach an overridden WebViewClient and override shouldOverideUrlLoading to get the URL before it loads in the webview. You can then use that url to do whatever you need to do. Here is an example using this method to do an oauth sign-on with twitter. I hope this helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜