/** 调用的是系统的音乐播放器*/Intent intent_music = new Intent(Intent.ACTION_PICK);intent_music.setDataAndType(Uri.EMPTY,"vnd.android.cursor.dir/playlist");intent_music.putExtra("withtabs", true); // 显示tab选项卡intent_music.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);startActivity(intent_music);
-------------2014-01-17 17:07更新------------

上面代码在华为手机上运行时会报错.

修改如下:

Intent intent_music = new Intent(Intent.ACTION_PICK);  intent_music.setDataAndType(Uri.EMPTY,"vnd.android.cursor.dir/playlist");  intent_music.putExtra("withtabs", true); // 显示tab选项卡  intent_music.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Intent j =Intent.createChooser(intent_music, "Choose an application to open with:");if (j == intent_music) {startActivity(j); } else {Intent intent = new Intent("android.intent.action.MUSIC_PLAYER");  startActivity(intent);}

使用createdChooser方法, 不至于运行时直接挂掉,然后选择另一种方法调用音乐播放器。



//在你所需要调用系统播放器的监听事件中添加上上面的一段代码就可以了。 这对于在做一个APP应用时不想在应用中重新再写一个音乐播放器时非常的有用。

一般的方法调用的音乐播放器只是对于某一首隔得播放,界面不友好!

更多相关文章

  1. Android(安卓)ListView(Selector 背景图片)
  2. AIDL
  3. 禁止Android的StatusBar下拉
  4. (android 关机/重启)Android关机/重启流程解析
  5. Android面试-基础知识
  6. android生命周期
  7. Android(安卓)Interface Definition Language (AIDL) android接
  8. zxing项目源码解读(2.3.0版本,Android部分)
  9. 详解 Android(安卓)的 Activity 组件

随机推荐

  1. Android(安卓)Camera 架构简析1
  2. Android(安卓)自定义adapter的getView中
  3. android获取网络图片的用法 BitmapFactor
  4. Android动画基础点记录
  5. 第十三篇 Android(安卓)系统电话管理机制
  6. Android静态安全检测 -> Intent Scheme U
  7. Android(安卓)activity之间的跳转和传参
  8. Android(安卓)UI设计总结
  9. android 6.0 logcat机制(二)logcat从logd中
  10. DialogFragment的使用