2016-03-21 3 views
0

私のアンドロイド・アプリにスプラッシュ・スクリーンが表示されているときにサウンド・ファイルを再生しようとしています....私はそれを数時間になりました.....私は私のアプリを実行したときに、それはちょうど今ここにすべて一緒にアンドロイド・スプラッシュ・スクリーン(アンドロイド・スタジオ)で再生するサウンドを得ることができません

をスプラッシュsreenをスキップし、私の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> 
です
+0

アプリが動作して試すことができます。ログを印刷してみてください。または、logcatに例外がないかどうかを確認してください。また、音楽ファイルが生のフォルダにあるかどうかを確認します。再生時間がわずか3秒なので、スプラッシュ画面はすぐに閉じます。 <: "スプラッシュ" =名前 のandroid:活動 アンドロイドscreenOrientation = "ポートレート" アンドロイド:ラベル= "@文字列/ ICON_NAME"> –

答えて

0

yを宣言しましたか?マニフェストでの私たちの活動は?あなたがやった場合

、この質問は前に頼まれた、以下試してください。

Android Sound not playing in splash screen

How to play audio in splash screen in android

+0

私のマニフェストには、スプラッシュ画面 ため、以下の活性を有する <意図フィルタ> <アクションアンドロイド:名= "android.intent.action.MAIN" /> <カテゴリアンドロイド:名= "android.intent.category.LAUNCHER" /> skapaid

+0

と2あなたが投稿したリンクは私がこれまでに持っている方法です.....まだ運はありません... – skapaid

+0

あなたはlogcatの出力を追加できますか? – Daniel

0

あなたはこの

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