알람리시버에서 알람액티비티 띄워주는 데 알람액티비티에서 소리를 재생할려구 합니다.  mUri is null 이라고 뜨고 음악재생은 되지 않습니다.

에뮬에서는 저런 메시지가 안나오는 데 스마튼폰을 연결해서 하면 저런 메시지가 뜹니다. 에러좀 봐주세요.


소스입니다.

package com.example.test2;


import java.io.IOException;


import android.app.Activity;

import android.content.Intent;

import android.media.AudioManager;

import android.media.MediaPlayer;

import android.os.Bundle;

import android.util.Log;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.TextView;


public class alarmActivity extends Activity {

MediaPlayer mp;

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

   super.onCreate(savedInstanceState);

   setContentView(R.layout.alarm);

   Intent intent = getIntent();

   String msg = intent.getExtras().getString("alarm_message");

   TextView txtMsg = (TextView)findViewById(R.id.txtMsg);

   txtMsg.setText(msg);

   Button btnStop = (Button)findViewById(R.id.btnStop);

   this.getResources().openRawResource(R.raw.tango);

   mp = MediaPlayer.create(this, R.raw.tango);

   

   

   mp.setAudioStreamType(AudioManager.STREAM_MUSIC); 


        mp.setLooping(true);

        if (mp != null)

        {

        mp.seekTo(0);

        mp.start();      

      Log.v("mp3", "play"); 

        }else{

        Log.v("mp3","mp null");

        }

   btnStop.setOnClickListener(new OnClickListener(){

@Override

public void onClick(View v){

mp.stop();

mp.release();

Intent launchHome = new Intent(Intent.ACTION_MAIN);


launchHome.addCategory(Intent.CATEGORY_DEFAULT);


launchHome.addCategory(Intent.CATEGORY_HOME);


startActivity(launchHome);

}

   });

   // TODO Auto-generated method stub

}


}