Android calls the player installed in the system to play network streaming video
Uri uri = Uri.parse( "http://rbv01.ku6.com/omtSn0z_PTREtneb3GRtGg.mp4" );
Intent intent = new Intent( Intent.ACTION_VIEW );
intent.setDataAndType( uri, "video/mp4" );
startActivity( intent );
Call the image software viewer installed in the system to open the image
Uri uri = Uri.parse( "http://10.8.2.152:7700/UpdateAPP/bzb.png" );
Intent intent = new Intent( Intent.ACTION_VIEW );
Log.v( "URI:::::::::", uri.toString() );
intent.setDataAndType( uri, "image/*" );
startActivity( intent );
Use the system's built-in browser to open the web page
String Ustr ="https://www.baidu.com/";
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
Uri content_url = Uri.parse(Ustr);
intent.setData(content_url);
startActivity(intent);
System.out.println("连接可用");
Uri uri = Uri.parse("https://www.baidu.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
Uri uri = Uri.parse( "https://www.baidu.com/" );
Intent intent = new Intent( Intent.ACTION_VIEW );
intent.setData( uri );
startActivity( intent );
Specify a browser (judging whether to install a browser before using it, it will crash if you run it directly)
Uri uri = Uri.parse("https://www.baidu.com");
Intent intent = new Intent(Intent.ACTION_VIEW,uri);
//intent.setClassName("com.UCMobile","com.uc.browser.InnerUCMobile");//打开UC浏览器
intent.setClassName("com.tencent.mtt","com.tencent.mtt.MainActivity");//打开QQ浏览器
startActivity(intent);
Example of judging whether the software is installed
/**
* 判断qq浏览器是否可用
*
* @param context
* @return
*/
public static boolean isQQClientAvailable(Context context) {
final PackageManager packageManager = context.getPackageManager();
List<PackageInfo> pinfo = packageManager.getInstalledPackages( 0 );
if (pinfo != null) {
for (int i = 0; i < pinfo.size(); i++) {
String pn = pinfo.get( i ).packageName;
if (pn.equals( "com.tencent.mtt" )) {
return true;
}
}
}
return false;
}
Complementary system file browser
//进入文件选择
Intent intent = new Intent( Intent.ACTION_GET_CONTENT );
intent.setType( "*/*" );//设置类型,我这里是任意类型,任意后缀的可以这样写。
intent.addCategory( Intent.CATEGORY_OPENABLE );
startActivityForResult( intent, 1 );
//选择完成返回当前页面 onActivityResult 方法获取文件地址
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult( requestCode, resultCode, intent );
if (resultCode == Activity.RESULT_OK) {
if (requestCode == 1) {
Uri uri = intent.getData();
Toast.makeText( this, "文件路径:" + uri.getPath().toString(), Toast.LENGTH_SHORT ).show();
// File file = new File( uri.getPath() );
//startActivity( OpenFiles.getVideoFileIntent( file ) );
//Intent intent1 = new Intent( Intent.ACTION_VIEW );
intent.setDataAndType( uri, "video/mp4" );
startActivity( intent );
}
}
}
个人记录
// Intent intent = new Intent( Intent.ACTION_GET_CONTENT );
// intent.setType("*/*");//设置类型,我这里是任意类型,任意后缀的可以这样写。
intent.setType(“*/*”);
// intent.addCategory( Intent.CATEGORY_OPENABLE );
// try {
// startActivityForResult( Intent.createChooser( intent, "请选择一个要上传的文件" ),
// 1 );
// } catch (android.content.ActivityNotFoundException ex) {
Potentially direct the user to the Market with a Dialog
// Toast.makeText( MainActivity.this, "请安装文件管理器", Toast.LENGTH_SHORT )
// .show();
// }