调用系统自带的程序,可以直接使用以下语句调用。
如,调用系统设置程序:
Intent intent=new Intent(android.provider.Settings.ACTION_SETTINGS);
startActivity(intent);
参考:
http://www.2cto.com/kf/201206/137789.html
如果要调用系统的程序打开相应的文件的话,可使用以下语句调用。
如,打开音频文件:
Intent i = new Intent();
i.setAction(android.content.Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(file), "audio/*");
startActivity(i);
打开视频文件:
Intent movieIntent = new Intent();
movieIntent.setAction(android.content.Intent.ACTION_VIEW);
movieIntent.setDataAndType(Uri.fromFile(file), "video/*");
startActivity(movieIntent);
打开pdf文件:
Intent pdfIntent = new Intent();
pdfIntent.setAction(android.content.Intent.ACTION_VIEW);
pdfIntent.setDataAndType(Uri.fromFile(file), "application/pdf");
安装apk文件:
Intent apkIntent = new Intent();
apkIntent.setAction(android.content.Intent.ACTION_VIEW);
apkIntent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
startActivity(apkIntent);
本文介绍了如何在Android中通过Intent调用系统自带的各种应用程序,包括系统设置、音频播放器、视频播放器、PDF阅读器及APK安装程序等。
3765

被折叠的 条评论
为什么被折叠?



