Reputation: 3
why is raw folder in code have a red line although i have this folder !!!! ?
what is the wrong ?
package com.example.second;
public class omar extends Activity {
MediaPlayer song;
@Override
protected void onCreate(Bundle omar) {
// TODO Auto-generated method stub
super.onCreate(omar);
setContentView(R.layout.omar);
song = MediaPlayer.create(omar.this, R.raw.one);
song.start();
Thread timer = new Thread(){
public void run(){
try{
sleep(5000);
}catch(InterruptedException e){
e.printStackTrace();
}finally{
Intent open = new Intent("android.intent.action.MAIN");
startActivity(open);
}
}
};
timer.start();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
song.release();
finish();
}
}
and what is the last method mean ?
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
song.release();
finish();
}
Upvotes: 0
Views: 75
Reputation: 473
When the activity is being paused it is a good strategy to release the resources used by the MediaPlayer object.That's what release() does here.
finish() just finishes the activity
Check these out
http://developer.android.com/reference/android/media/MediaPlayer.html#release()
http://developer.android.com/reference/android/app/Activity.html#finish()
Upvotes: 0
Reputation: 1360
You have res/layout/raw
. It's not right. It's res/raw
Also follow the link given to you by rup35h.
Upvotes: 0
Reputation: 2891
raw
should be outside from the layout
folder and inside res
Please prefer this.
http://developer.android.com/guide/topics/resources/providing-resources.html
Upvotes: 3
Reputation: 170158
You have res/layout/raw
, while it should be res/raw
I believe.
Upvotes: 4