浏览器方式一:
public class BrowserIntent extends Activity {
    /** Called when the activity is first created. */
    private EditText urlText;
    private Button goButton;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        urlText = (EditText)this.findViewById(R.id.url_field);
        goButton = (Button)this.findViewById(R.id.go_button);
        goButton.setOnClickListener(new OnClickListener(){
            public void onClick(View v) {
                openBrowser();
               
            }
           
        });
       
       urlText.setOnKeyListener(new OnKeyListener(){

        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if(keyCode==KeyEvent.KEYCODE_ENTER){
                openBrowser();
                return true;
            }
            return false;
        }
          
       });
    }
   
    public void openBrowser(){
        Uri uri = Uri.parse(urlText.getText().toString());
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        startActivity(intent);
    }
}

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:andro
2)addJavascriptInterface方法中要绑定的Java对象及方法要运行另外的线程中,不能运行在构造他的线程中,这也是使用 Handler的目的。


0RVAX0AJdhcBsgJHj2NfDRnFBB9xR1pCq4eo6IQ

相关文章:

  • 2022-01-30
  • 2021-07-29
  • 2021-11-21
  • 2021-09-07
  • 2021-09-11
  • 2020-05-17
  • 2021-12-01
  • 2022-12-23
猜你喜欢
  • 2021-11-18
  • 2021-08-01
  • 2021-12-30
  • 2021-05-05
  • 2021-07-23
  • 2021-04-21
相关资源
相似解决方案