How to Pause/Stop the media player from a different activity?
===

I have declared a media player variable in MediaPActivity activity and then want to pause or stop it in a Second activity. I have declared intent in the Second class but when i try to the mediplayer on click of btn1 MediaPActivity  the mediaplayer in the Second activity is not paused/stopped. What is wrong with the below given piece of code ?



       public class MediaPActivity extends Activity {
	Button btn, btn1;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        btn = (Button) findViewById(R.id.btn);
        btn1 = (Button) findViewById(R.id.btn1);
        btn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(MediaPActivity.this, Second.class);
				startActivity(i);
			}
		});
        btn1.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(MediaPActivity.this, Second.class);
				i.setAction(Second.ACTION_PAUSE);
				}
		});
    }
}


Second Activity:


          public class Second extends Activity {
	Button btnplay, btnpause;
	MediaPlayer player;
	public static final String ACTION_PLAY = "com.synapse.test.PLAY";
	public static final String ACTION_PAUSE = "com.synapse.test.PAUSE";
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.second);
		
		btnplay = (Button) findViewById(R.id.button1);
		btnpause = (Button) findViewById(R.id.button2);
		player = new MediaPlayer();
		player = MediaPlayer.create(Second.this, R.raw.testsong_20_sec);
		btnplay.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				player.start();
			}
		});
		btnpause.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				player.pause();
			}
		});
	}
	@Override
    protected void onNewIntent(Intent intent) {
		if(intent.getAction().equals(ACTION_PLAY)){
    		    	player.start();
    		}
		else if(intent.getAction().equals(ACTION_PAUSE)){
    		    	player.pause();
    		    }
    		}
}


    Manifest File:

      <activity
            android:name=".MediaPActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
           </activity>
            <activity android:name=".Second" android:launchMode="singleTop" />