2013-02-09 6 views
2

음악 플레이어가 시작되어 첫 번째 노래 재생이 즉시 시작되도록 시도하고 있습니다. 메신저는 의도를 사용하지만 작동하지 않습니다 ... "아무런 행동도 발견되지 않았습니다"라는 메시지가 나타납니다.기본 음악 플레이어 시작

+0

'오디오/*'미디어 유형을 사용해보십시오. 사용하고있는 것이므로 제대로 작동합니다. 어쩌면 아무것도 특정 마임 타입으로'audio/mp3 '을 등록하지 않았을 것입니다. – Squonk

+0

작동하지 않습니다. – Raz

+0

'Uri'값은 무엇입니까? – CommonsWare

답변

2

android.intent.action.MUSIC_PLAYER을 사용하지 않으시겠습니까? 이 위쪽으로는 android.intent.category.APP_MUSIC를 사용할 수있는 API로부터, API (15)에서 사용되지 않습니다 것을

Intent intent = new Intent("android.intent.action.MUSIC_PLAYER"); 
startActivity(intent); 

참고.

+0

이 음악은 "playerpro"라는 음악 플레이어 만 실행하므로 휴대 전화에서 playerpro를 삭제 한 다음 충돌이 발생했습니다. – Raz

+0

다른 뮤직 플레이어가 설치되어 있습니까? – Ahmad

+0

예, playerpro가 기본 파일이 아닙니다. – Raz

1

확인 내가

   Intent intent = new Intent(); 
       intent.setAction(android.content.Intent.ACTION_VIEW); 
       File file = new File(songsList.get(0)); 
       intent.setDataAndType(Uri.fromFile(file), "audio/*"); 
       startActivity(intent); 

을 작동하지만 것은 그 사용자가 뒤로 버튼 안타 말할 수 있습니다 된 후 음악 플레이어의 버튼을 명중이 코드를 찾을 수 있도록, 그것은 플레이어를 다시 시작하고 재생을 시작합니다 다시 첫 번째 노래 ... 그래서 나는 어떻게 음악 플레이어를 시작합니까?

2
 Intent intent = new Intent(); 
     intent.setAction(android.content.Intent.ACTION_VIEW); 
     File file = new File(AUDIO_PATH); 
     intent.setPackage("com.google.android.music");   
     intent.setDataAndType(Uri.fromFile(file), "audio/*"); 
     mContext.startActivity(intent); 
+3

코드는 좋지만 설명이 더 좋습니다 *. – Makoto

0

기본 음악 플레이어를 실행하려면 아래 코드를 시도하십시오.

try { 
    Intent intent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, Intent.CATEGORY_APP_MUSIC); 
    getContext().startActivity(intent); 
} catch (Exception e) { 
    Log.d(TAG, "Exception for launching music player "+e); 
}