Java 无法在android启动屏幕上播放声音(android studio)

Java 无法在android启动屏幕上播放声音(android studio),java,android,android-studio,mobile,Java,Android,Android Studio,Mobile,当我的闪屏显示在我的android应用程序上时,我正在尝试播放一个声音文件。。。。我已经想了几个小时了。。。。。当我运行我的应用程序时,它只是跳过了所有的启动 这是我的SplashScreen.java package com.skapaidbeats.app.skapaidbeats; import android.app.Activity; import android.content.Intent; import android.media.MediaPlayer; import andr

当我的闪屏显示在我的android应用程序上时,我正在尝试播放一个声音文件。。。。我已经想了几个小时了。。。。。当我运行我的应用程序时,它只是跳过了所有的启动

这是我的SplashScreen.java

package com.skapaidbeats.app.skapaidbeats;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import com.skapaidbeats.app.skapaidbeats.MainActivity;
import com.skapaidbeats.app.skapaidbeats.R;
public class SplashScreen extends Activity {

MediaPlayer music;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);

    Thread timerThread = new Thread(){
        public void run(){
            try{
                music= MediaPlayer.create(SplashScreen.this, R.raw.sound);
                music.start();
                sleep(3000);
            }catch(InterruptedException e){
                e.printStackTrace();
            }finally{
                Intent intent = new Intent(SplashScreen.this,MainActivity.class);
                startActivity(intent);
            }
        }
    };
    timerThread.start();
}

@Override
protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    music.release();
    finish();
} 
}
这是我的AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
package="com.skapaidbeats.app.skapaidbeats">



<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />



<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">


    <activity
        android:name=".SplashScreen"
        android:screenOrientation="portrait"
        android:label="@string/icon_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".MainActivity"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar">
    </activity>

    <activity
        android:name="com.google.android.gms.ads.AdActivity"
        android:screenOrientation="portrait"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <activity
        android:name="com.startapp.android.publish.list3d.List3DActivity"
        android:theme="@android:style/Theme" />
    <activity
        android:name="com.startapp.android.publish.AppWallActivity"
        android:configChanges="orientation|keyboardHidden"
        android:theme="@android:style/Theme.Translucent" />
    <activity
        android:name="com.startapp.android.publish.OverlayActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:theme="@android:style/Theme.Translucent" />
    <activity
        android:name="com.startapp.android.publish.FullScreenActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:theme="@android:style/Theme" />


</application>
</manifest>

您是否在清单中声明了您的活动

如果您以前问过此问题,请尝试以下操作:

你可以试试这个

MediaPlayer player = new MediaPlayer();
player.setDataSource("/sdcard/audiotrack.mp3");
player.prepare();
player.start();

你的应用程序正在运行。只需打印日志即可。或者检查logcat是否存在任何异常。还要检查原始文件夹中是否有音乐文件。由于持续时间仅为3秒,启动屏幕立即关闭。我的清单在启动屏幕上有以下活动您可以添加您的logcat输出吗?03-21 03:32:38.102 10691-10691/com.skapaidbeats.app.skapaidbeats E/qdmemalloc:heap_msk=40000000 flags=1i我反复得到该错误再一次大约100次,我只是将我的AndroidManifest.Xml添加到上面发布的原始问题中。。你现在可以在那里看到了