Android实现打开浏览器

1. 调用浏览器打开对应的网址:

		Intent intent = new Intent();
		intent.setAction(Intent.ACTION_VIEW);        
		Uri uri = Uri.parse("http://www.baidu.com/");       
		intent.setData(uri);
		intent.setClassName("com.android.browser","com.android.browser.BrowserActivity");        
		launcher.startActivity(intent);

 

2. 调用手机上的Google Play程序,搜索应用程序:

       /** 
 * market://search?q=pname: 
 */  
private void startSearchPNAMEIntent(){  
    String pkgname;  
      
    if(mEditText != null){  
        pkgname = mEditText.getText().toString();  
    }else{  
        return;  
    }  
      
    Uri uri = Uri.parse("market://search?q=pname:"+pkgname);           
    Intent it = new Intent(Intent.ACTION_VIEW, uri);           
    startActivity(it);   
}  
  
/** 
 * market://search?q=pnames: 
 */  
private void startSearchPNAMESIntent(){  
       String pkgnames;  
      
    if(mEditText != null){  
        pkgnames = mEditText.getText().toString();  
    }else{  
        return;  
    }  
      
    Uri uri = Uri.parse("market://search?q=pnames:"+pkgnames);           
    Intent it = new Intent(Intent.ACTION_VIEW, uri);           
    startActivity(it);   
}  
  
/** 
 * market://search?q=pub:Your Publisher Name 
 */  
private void startSearchPUBIntent(){  
       String pub;  
      
    if(mEditText != null){  
        pub = mEditText.getText().toString();  
    }else{  
        return;  
    }  
      
    Uri uri = Uri.parse("market://search?q=pub:"+pub);           
    Intent it = new Intent(Intent.ACTION_VIEW, uri);           
    startActivity(it);   
}  
  
/** 
 * market://details?id= 
 */  
private void startSearchIDIntent(){  
       String id;  
      
    if(mEditText != null){  
        id = mEditText.getText().toString();  
    }else{  
        return;  
    }  
      
    Uri uri = Uri.parse("market://details?id="+id);           
    Intent it = new Intent(Intent.ACTION_VIEW, uri);           
    startActivity(it);   
}  

 

你可能感兴趣的:(移动终端开发)