android 调用系统程序

本文介绍了如何在Android中通过Intent调用系统自带的各种应用程序,包括系统设置、音频播放器、视频播放器、PDF阅读器及APK安装程序等。

调用系统自带的程序,可以直接使用以下语句调用。

如,调用系统设置程序:

    	Intent intent=new Intent(android.provider.Settings.ACTION_SETTINGS);
    	startActivity(intent);

参考:

http://www.eoeandroid.com/forum.php?mod=viewthread&tid=179142&reltid=64145&pre_thread_id=0&pre_pos=1&ext=CB

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);


打开其他类型的文件依此类推。




评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值