. NET to implement MD5 encryption simply

Source: Internet
Author: User
Tags md5 encryption

1, WebView display progress bar in the OnCreate event write:

[Java]View Plaincopy
  1. WebView Mywebview = (WebView) Findviewbyid (R.ID.WEBVIEW1);
  2. Final activity activity = this;
  3. Mywebview.setwebchromeclient (New Webchromeclient () {
  4. public void onprogresschanged (WebView view, int progress) {
  5. Activity.settitle ("Trying to load for you ....");
  6. Activity.setprogress (Progress * 100);
  7. if (progress = = 100)
  8. Activity.settitle ("completed");//or set as the original activity title
  9. }
  10. });

2, Web page adaptive webview width in the OnCreate event wrote:

[Java]View Plaincopy
    1. WebView Mywebview = (WebView) Findviewbyid (R.ID.WEBVIEW1);
    2. Mywebview.getsettings (). Setlayoutalgorithm (Layoutalgorithm.single_column);

3, WebView support Web JavaScript language in the OnCreate event write:

[Java]View Plaincopy
    1. WebView Mywebview = (WebView) Findviewbyid (R.ID.WEBVIEW1);
    2. Mywebview.getsettings (). Setjavascriptenabled (True);

4, the page inside the hyperlink in WebView in Riga, not in the phone default browser opened in the OnCreate event wrote:

[Java]View Plaincopy
    1. WebView Mywebview = (WebView) Findviewbyid (R.ID.WEBVIEW1);
[Java]View Plaincopy
    1. Mywebview.setwebviewclient (New Webviewclient () {
    2. public boolean shouldoverrideurlloading (WebView view, String URL) {
    3. View.loadurl (URL);
    4. return true;
    5. }
    6. });
[Java]View Plaincopy
    1. Mywebview.loadurl ("http://www.baidu.com"));//The default load URL can only be placed behind setwebviewclient otherwise hyperlinks in the Web page or in the phone's default browser open instead of in the WebView in Riga

5, press the Phone Back button back page instead of opening the WebView program before the interface:

[Java]View Plaincopy
  1. public boolean onKeyDown (int keycode, keyevent event)
  2. {//Check if the key event is the back key and if there's history
  3. WebView Mywebview = (WebView) Findviewbyid (R.ID.WEBVIEW1);
  4. if ((keycode = = keyevent.keycode_back) && mywebview.cangoback ())
  5. {
  6. Mywebview.goback ();
  7. return true;
  8. }//If It wasn ' t the back key or there's no Web page history, bubble up to the default//system behavior (probably exit The activity)
  9. Return Super.onkeydown (KeyCode, event);
  10. }

6, Web page JS call Android Program:

New Class of Javascriptinterface

[Java]View Plaincopy
    1. Package com.example.androidhouse;
    2. Import Android.content.Context;
    3. Import Android.widget.Toast;
    4. public class Javascriptinterface {
    5. Context Mcontext;
    6. /** instantiate the interface and set the context */
    7. Javascriptinterface (Context c) {mcontext = C;}
    8. /** Show A toast from the Web page */
    9. public void Showtoast (String toast)
    10. {
    11. Toast.maketext (Mcontext, Toast, Toast.length_short). Show ();
    12. }
    13. }

In the OnCreate event, write:

[Java]View Plaincopy
    1. WebView Mywebview = (WebView) Findviewbyid (R.ID.WEBVIEW1);
[Java]View Plaincopy
    1. Mywebview.addjavascriptinterface (New Javascriptinterface (This), "Android");

The page JS code is written in:

[JavaScript]View Plaincopy
    1. Window. Andorid.showtoast ("I Call the Android program");

Remember: in Andorid2.2 and Android2.3 inside the WebView JS call will cause a system crash VM aborting error This is the two version of the bug solved very troublesome until now, I still did not find a solution.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.