Need to access method for 1 java class by another
<p>I am trying to access a method from a java class by a another java class. I have created the object of the class and import the class into my java class but i am not able to access it my code.</p>

<pre><code>   package com.example.musicplayer;

import java.io.File;
import java.util.ArrayList;
import java.util.List;



import android.R.string;

import android.app.ListActivity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.Bundle;
import android.provider.MediaStore.Audio.Playlists;
import android.test.suitebuilder.TestSuiteBuilder.FailedToCreateTests;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;


        public class MainActivity extends ListActivity {

    public static final String MEDIA_PATH = new String("/sdcard/");
    private List&lt;String&gt; songs = new ArrayList&lt;String&gt;();
    public MediaPlayer mp = new MediaPlayer();
    private int currentPosition = 0;

    public MediaPlayer getmp(){
        return mp;
    }
    public void setmp(MediaPlayer mp){
        this.mp = mp;
    }

       @Override
          protected void onCreate(Bundle icicle) {
             super.onCreate(icicle);
           setContentView(R.layout.activity_main);
         updateSongList();         
     }

            private void updateSongList() {
        // TODO Auto-generated method stub
        File home = new File(MEDIA_PATH);
        if(home.listFiles(new Mp3Filter()).length &gt; 0){
            for(File file: home.listFiles(new Mp3Filter())){
                songs.add(file.getName());
            }
          }
                ArrayAdapter&lt;String&gt; songList = new ArrayAdapter&lt;String&gt;(this, R.layout.song_item, songs);


        setListAdapter(songList);
      }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id){
        currentPosition = position;
        playSong(MEDIA_PATH + songs.get(position));

        //Toast.makeText(getApplicationContext(), songs.get(position).toString(), Toast.LENGTH_SHORT).show();

        final String songName = songs.get(position).toString();
        //final TextView textchange = (TextView) v.findViewById(R.id.current_song_name);

        Intent in = new Intent(this, current_song.class);
        in.putExtra("song_name", songName);
        startActivity(in);

        //Toast.makeText(getApplicationContext(), "End of Song List", Toast.LENGTH_SHORT).show();       
        //textchange.setText(songName);
    }


    private void playSong(String songPath) {
        // TODO Auto-generated method stub

        try{

            mp.reset();
            mp.setDataSource(songPath);
            mp.prepare();
            mp.start();

            mp.setOnCompletionListener(new OnCompletionListener() {

                @Override
                public void onCompletion(MediaPlayer mp) {
                    // TODO Auto-generated method stub
                    auto_nextSong();
                }               
            });

        }
        catch (Exception e) {
            // TODO: handle exception
        }

    }

    public void pause(){
        mp.pause();
    }

    public void stop(){

        mp.stop();
    }

    public void next(){ 
        Toast.makeText(getApplicationContext(), "In Next()", Toast.LENGTH_SHORT).show();
        if(currentPosition &lt; songs.size()){
            currentPosition = currentPosition + 1;
            playSong(MEDIA_PATH + songs.get(currentPosition));
        }
    }

    public void prv(){
        if(currentPosition &gt; songs.size()){
            currentPosition = currentPosition - 1;      
            playSong(MEDIA_PATH + songs.get(currentPosition));
        }
    }

    private void auto_nextSong() {
        // TODO Auto-generated method stub
        if(++currentPosition &gt;= songs.size()){
            currentPosition = 0;
            Toast.makeText(getApplicationContext(), "End of Song List", Toast.LENGTH_SHORT).show();
        }
        else{
            playSong(MEDIA_PATH + songs.get(currentPosition));
            Toast.makeText(getApplicationContext(), "Next Song", Toast.LENGTH_SHORT).show();
        }
    }

     }
</code></pre>

<p>from the above class i am trying to access pause() and stop()</p>

<p>this is my class where i am trying to access </p>

<pre><code>package com.example.musicplayer;



     import com.example.musicplayer.MainActivity;
             import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

        public class current_song extends Activity implements OnClickListener{


     public MainActivity ma;
     protected void onCreate(Bundle icicle, MainActivity ma) {

         Bundle extra = getIntent().getExtras();

         super.onCreate(icicle);
         setContentView(R.layout.songplay_page);

         if(extra != null){
             String song_name = extra.getString("song_name");
             TextView textchange = (TextView)findViewById(R.id.current_song_name);
             textchange.setText(song_name);
             textchange.setSelected(true);
         }       

         //MainActivity ma = ((MainActivity)getApplicationContext());
         //MediaPlayer mp = ma.getmp();

         this.ma = ma;
         Button btn_pause = (Button)findViewById(R.id.pause_btn);
         btn_pause.setOnClickListener(this);    

         Button btn_next = (Button)findViewById(R.id.next_btn);
         btn_next.setOnClickListener(this);

         Button btn_prv = (Button)findViewById(R.id.prv_btn);
         btn_prv.setOnClickListener(this);

         Button btn_stop = (Button)findViewById(R.id.stop_btn);
         btn_stop.setOnClickListener(this);

     }

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        //Toast.makeText(getApplicationContext(), "In Onclick ()", Toast.LENGTH_SHORT).show();
        switch(v.getId())
        {
            case R.id.pause_btn:
                ((MainActivity)ma).pause();
            break;

            case R.id.next_btn:
                //ma.next();
            break;

            case R.id.prv_btn:
                //ma.prv();
            break;

            case R.id.stop_btn:
                ((MainActivity)ma).stop();
            break;
        }

    }

       }
</code></pre>

<p>The concept is that i want to stop, pause the music which is playing. If my logic i wrong please guide me how to do it else please help me how to control my current music in Current music java class.   </p>
