本文介绍了打开音乐播放器的Galaxy S3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这下code适用于所有Android设备(API> = 8),但不能在三星Galaxy S3(音乐播放器未找到)。

 尝试{
    字符串名称;
    尝试 {
        NAME =(字符串)MediaStore.class.getDeclaredField(INTENT_ACTION_MUSIC_PLAYER)获得(空)。
    }赶上(例外五){
        NAME =(字符串)Intent.class.getDeclaredField(CATEGORY_APP_MUSIC)获得(空)。
    }
    startActivity(新意图(名称));
}赶上(例外五){
    //没有找到音乐播放器
}
 

三星构造层是什么呢?有没有人有一个解决方案,以打开在银河S3?

媒体播放器

作为一个更新,我已经改变了我的错误,但我还是对银河S3没有get媒体播放器:

 尝试{
    尝试 {
        // 8示= API< 15
        串动=(字符串)MediaStore.class.getDeclaredField(INTENT_ACTION_MUSIC_PLAYER)获得(空)。
        意向意图=新的意图(动作);
        startActivity(意向);
    }赶上(例外五){
        // 15℃; = API
        字符串类=(字符串)Intent.class.getDeclaredField(CATEGORY_APP_MUSIC)获得(空)。
        方法方法= Intent.class.getMethod(makeMainSelectorActivity,为String.class,为String.class);
        意向意图=(意向)method.invoke(NULL,Intent.ACTION_MAIN,类别);
        startActivity(意向);
    }
赶上(例外五){
    //没有找到音乐播放器
}
 

解决方案

我终于找到了解决我的问题有以下步骤:

  • 在我安装了从Android Market
  • 包名应用程序
  • 在我发现了音乐播放器的包命名为com.sec.android.app.music
  • 在我创建了getLaunchIntentForPackage方法的意图方法从PackageManger
  • 在我开始用这种意图的活动,音乐播放器中发现

此产生的意图转换成字符串返回:

 意向{
    ACT = android.intent.action.MAIN
    猫= [android.intent.category.LAUNCHER]
    FLG = 0x10000000处
    PKG = com.sec.android.app.music
    CMP = com.sec.android.app.music / .MusicActionTabActivity
}
 

我不明白,为什么CATEGORY_APP_MUSIC并不只在GS3工程...

在code,推出音乐播放器:

 尝试{
    字符串PKGNAME =com.sec.android.app.music;
    PackageManager pkgmanager = getPackageManager();
    意向意图= pkgmanager.getLaunchIntentForPackage(包名称);
    startActivity(意向);
}赶上(例外五){
    //没有找到音乐播放器
}
 

This following code works on any android device (api >= 8) but not on Samsung Galaxy S3 (music player not found).

try {
    String name;
    try {
        name = (String) MediaStore.class.getDeclaredField("INTENT_ACTION_MUSIC_PLAYER").get(null);
    } catch(Exception e) {
        name = (String) Intent.class.getDeclaredField("CATEGORY_APP_MUSIC").get(null);
    }
    startActivity(new Intent(name));
} catch(Exception e) {
    // music player not found
}

Samsung constructor layer is something to it? Does anyone have a solution to open the media player on a Galaxy S3?

As an update, I have changed my mistake but I still no get mediaplayer on Galaxy S3:

try {
    try {
        // 8 <= API < 15
        String action = (String) MediaStore.class.getDeclaredField("INTENT_ACTION_MUSIC_PLAYER").get(null);
        Intent intent = new Intent(action);
        startActivity(intent);
    } catch(Exception e) {
        // 15 <= API
        String category = (String) Intent.class.getDeclaredField("CATEGORY_APP_MUSIC").get(null);
        Method method = Intent.class.getMethod("makeMainSelectorActivity", String.class, String.class);
        Intent intent = (Intent) method.invoke(null, Intent.ACTION_MAIN, category);
        startActivity(intent);
    }
catch(Exception e) {
    // music player not found
}
解决方案

I finally found the solution to my problem with the following steps:

  • I installed "Package Name" application from Android Market
  • I found music player's package named "com.sec.android.app.music"
  • I created an Intent with "getLaunchIntentForPackage" method from PackageManager
  • I start activity with this Intent, music player is found

This generated Intent converted to String returns :

Intent {
    act=android.intent.action.MAIN
    cat=[android.intent.category.LAUNCHER]
    flg=0x10000000
    pkg=com.sec.android.app.music
    cmp=com.sec.android.app.music/.MusicActionTabActivity
}

I don't understand why "CATEGORY_APP_MUSIC" doesn't works only on GS3...

The code to launch music player:

try {
    String pkgname = "com.sec.android.app.music";
    PackageManager pkgmanager = getPackageManager();
    Intent intent = pkgmanager.getLaunchIntentForPackage(pkgname);
    startActivity(intent);
} catch(Exception e) {
    // music player not found
}

这篇关于打开音乐播放器的Galaxy S3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 08:29