Android系统调用之Intent

android通过程序打开mp3播放器播放音乐

  1. Intent it = new Intent(Intent.ACTION_VIEW);  
  2.   
  3. Uri uri = Uri.parse("file:///sdcard/song.mp3");  
  4.   
  5. it.setDataAndType(uri, "audio/mp3");  
  6.   
  7. startActivity(it);  

  1. Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");     
  2.   
  3. Intent it = new Intent(Intent.ACTION_VIEW, uri);     
  4.   
  5. startActivity(it);     

 

Uninstall 程序 :

  1. Uri uri = Uri.fromParts("package", strPackageName, null);     
  2.   
  3. Intent it = new Intent(Intent.ACTION_DELETE, uri);     
  4.   
  5. startActivity(it);  

 

发送彩信

  1. Uri uri = Uri.parse("content://media/external/images/media/23");     
  2.   
  3. Intent it = new Intent(Intent.ACTION_SEND);     
  4.   
  5. it.putExtra("sms_body""some text");     
  6.   
  7. it.putExtra(Intent.EXTRA_STREAM, uri);     
  8.   
  9. it.setType("image/png");     
  10.   
  11. startActivity(it);    

 

 

 

 

发送SMS/MMS
调用发送短信的程序

  1.  Intent it = new Intent(Intent.ACTION_VIEW);     
  2.   
  3. it.putExtra("sms_body""The SMS text");     
  4.   
  5. it.setType("vnd.android-dir/mms-sms");     
  6.   
  7. startActivity(it);     

 

发送短信

 

  1. Uri uri = Uri.parse("smsto:0800000123");     
  2.   
  3. Intent it = new Intent(Intent.ACTION_SENDTO, uri);     
  4.   
  5. it.putExtra("sms_body""The SMS text");     
  6.   
  7. startActivity(it);    

 

 

拨打电话:
调用拨号程序

  1.  Uri uri = Uri.parse("tel:xxxxxx");  
  2.   
  3. Intent it = new Intent(Intent.ACTION_DIAL, uri);     
  4.   
  5. startActivity(it);     
  6.   
  7.   
  8. Uri uri = Uri.parse("tel.xxxxxx");  
  9.   
  10. Intent it =new Intent(Intent.ACTION_CALL,uri);  


要使用这个必须在配置文件中加入<uses-permission id="android.permission.CALL_PHONE" />

 

 

显示网页:

  1.  Uri uri = Uri.parse("http://www.google.com");  
  2.   
  3. Intent it = new Intent(Intent.ACTION_VIEW,uri);  
  4.   
  5. startActivity(it);  

显示地图:

 

  1.  Uri uri = Uri.parse("geo:38.899533,-77.036476");  
  2.   
  3. Intent it = new Intent(Intent.Action_VIEW,uri);  
  4.   
  5. startActivity(it);    

路径规划:

  1. Uri uri = Uri.parse("http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en");  
  2.   
  3. Intent it = new Intent(Intent.ACTION_VIEW,URI);  
  4.   
  5. startActivity(it);  

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值