title: Android: How to use mediaController in service class?
body: <p>I have a app that plays radio via MediaPlayer as a service. Is it possible to use MediaController in Service class?
  The problem is that I can use findViewById.</p>
  
  <p>I try to get my LinearLayout in onPrepeared methiod ...</p>
  
  <pre><code>public class RadioPlayer extends Service implements OnPreparedListener, MediaController.MediaPlayerControl {
    @Override
    public void onCreate() {
    super.onCreate();
    mediaPlayer = new MediaPlayer();
    mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    mediaPlayer.setOnPreparedListener(this);
    mediaController = new MediaController(this, false); mediaPlayer.setDataSource(url);
    mediaPlayer.prepareAsync(); 
  }
  
  @Override
    public void onPrepared(MediaPlayer mediaPlayer) {
    mediaPlayer.start();
    mediaController.setMediaPlayer(this);
    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.main, (ViewGroup) findViewById(R.id.main_program_view));
    mediaController.setAnchorView(layout);
  }
  }
  </code></pre>
  
  <p>main.xml file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/main_program_view"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:background="#FFFFFF"
          android:orientation="vertical" &gt;  
  
          &lt;TextView
              android:id="@+id/now_playing_text"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_marginTop="30dp"
              android:gravity="center"
              android:text="@string/na_antenie"
              android:textColor="#333333" /&gt;    
  &lt;/LinearLayout&gt;
  </code></pre>