Android系统调用之Intent


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

  • Intent it = new Intent(Intent.ACTION_VIEW);  
  •   
  • Uri uri = Uri.parse("file:///sdcard/song.mp3");  
  •   
  • it.setDataAndType(uri, "audio/mp3");  
  •   
  • startActivity(it);  
  • Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");     
  •   
  • Intent it = new Intent(Intent.ACTION_VIEW, uri);     
  •   
  • startActivity(it);   

    Uninstall 程序 :

  • Uri uri = Uri.fromParts("package", strPackageName, null);     
  •   
  • Intent it = new Intent(Intent.ACTION_DELETE, uri);     
  •   
  • startActivity(it);  

    发送彩信

  • Uri uri = Uri.parse("content://media/external/images/media/23");     
  •   
  • Intent it = new Intent(Intent.ACTION_SEND);     
  •   
  • it.putExtra("sms_body""some text");     
  •   
  • it.putExtra(Intent.EXTRA_STREAM, uri);     
  •   
  • it.setType("image/png");     
  •   
  • startActivity(it);    

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

    Intent it = new Intent(Intent.ACTION_VIEW);     

  •   
  • it.putExtra("sms_body""The SMS text");     
  •   
  • it.setType("vnd.android-dir/mms-sms");     
  •   
  • startActivity(it);   

    发送短信

  • Uri uri = Uri.parse("smsto:0800000123");     
  •   
  • Intent it = new Intent(Intent.ACTION_SENDTO, uri);     
  •   
  • it.putExtra("sms_body""The SMS text");     
  •   
  • startActivity(it); 
    • 1
    • 2
    • 下一页

    相关内容