English 中文(简体)
android http post response into webview and navigate
原标题:android http post response into webview and navigate

如果我点击一些链接,就会拯救我的证书和格列斯,“你不gged”和信条继续。

该守则是:

public class ilias extends Activity {

 WebView webView;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        webView = (WebView)findViewById(R.id.webview);

        BufferedReader bufferedReader = null;
        HttpClient httpClient = new DefaultHttpClient();
        HttpPost request = new HttpPost("http://www.ilias.de/docu/login.php?client_id=docu");
        List<NameValuePair> postParameters = new ArrayList<NameValuePair>();
        postParameters.add(new BasicNameValuePair("username", "stacked")); //this username 
        postParameters.add(new BasicNameValuePair("password", "overflow"));//works


  try {
   UrlEncodedFormEntity entity = new UrlEncodedFormEntity(postParameters);
         request.setEntity(entity);

         HttpResponse response= httpClient.execute(request);

   bufferedReader = new BufferedReader(
           new InputStreamReader(response.getEntity().getContent()));
   StringBuffer stringBuffer = new StringBuffer("");
   String line = "";
   String LineSeparator = System.getProperty("line.separator");
   while ((line = bufferedReader.readLine()) != null) {
    stringBuffer.append(line + LineSeparator); 
   }
   bufferedReader.close();

   Toast.makeText(ilias.this, 
     "Finished", 
     Toast.LENGTH_LONG).show();

   String webData = stringBuffer.toString();

   webView.loadData(webData,"text/html","UTF-8");
   webView.loadDataWithBaseURl("http://www.ilias.de/docu/",webData,"text/html","UTF-8","about:blank");

  } catch (ClientProtocolException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   Toast.makeText(ilias.this, 
     e.toString(), 
     Toast.LENGTH_LONG).show();
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   Toast.makeText(ilias.this, 
     e.toString(), 
     Toast.LENGTH_LONG).show();
  }finally{
   if (bufferedReader != null){
    try {
     bufferedReader.close();
    } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    }
   }
  }

    }
}
最佳回答

这样,你就会重新失去储存厨师的能力。 您还必须在上从服务器中推广认证机制。 您可直接使用网上电话,并可与申请机构联系。 看来,你通过URL encoded实体通过用户名和密码,该实体与网站

Try something like:

String query = "username=" + username + "&password=" + password";
webview.postUrl("http://www.ilias.de/docu/login.php?client_id=docu", query.getBytes());
问题回答

如果你使用“网点”多次,你可以通过http://client 维持 co。 如果你只是在一个网站上浏览,那么网站实际上就应当储存你的信息,因为该网站是由网站处理的,否则就使网站成为全球公众静态的,并在你的活动中或通过其他活动分享。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签