Android系统基本功能

本文介绍了如何使用Android的Intent来实现打电话、发送短信、安装APK、浏览文件及调用系统音乐播放器等功能,并提供了相应的代码示例及所需权限。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

打电话

 

Code

Uri uri =Uri.parse("tel:15800001234");
Intentintent = new Intent(Intent.ACTION_CALL, uri);
startActivity(intent);

 

权限:

<uses-permissionandroid:name="android.permission.CALL_PHONE" />



发短信

Code

<span style="white-space:pre">	</span>Uriuri = Uri.parse("smsto:15800001234");
<span style="white-space:pre">	</span>Intentintent = new Intent(Intent.ACTION_SENDTO, uri);
<span style="white-space:pre">	</span>intent.putExtra("sms_body","android...");
<span style="white-space:pre">	</span>startActivity(intent);

 

权限:

<uses-permissionandroid:name="android.permission.SEND_SMS"/>



安装APK

 <span style="white-space:pre">	</span>FileapkFile = new File("mnt/sdcard/tts_3.1_market.apk");
<span style="white-space:pre">	</span>Intentintent = new Intent();
<span style="white-space:pre">	</span>intent.setAction(Intent.ACTION_VIEW);<span style="white-space:pre">	</span>
<span style="white-space:pre">	</span>intent.setDataAndType(Uri.fromFile(apkFile),"application/vnd.android.package-archive");
 
<span style="white-space:pre">	</span>startActivity(intent); 


文件浏览

FiledirFile = new File("指定的目录");

File[] files =dirFile.listFiles(); 


系统音乐播放器

<span style="white-space:pre">	</span>Intent intent = newIntent();
<span style="white-space:pre">	</span>Uri uri =Uri.parse(url);
<span style="white-space:pre">	</span>intent.setDataAndType(uri,"audio/*");
 <span style="white-space:pre">	</span>intent.setAction(Intent.ACTION_VIEW);
<span style="white-space:pre">	</span>startActivity(intent); 

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值