Android Open Source - RemoteControl Volume Activity






From Project

Back to project page RemoteControl.

License

The source code is released under:

MIT License

If you think the Android project RemoteControl listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package ch.sebastianhaeni.remotecontrol;
//w w w  .j  av a2s . c  o  m
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;

public class VolumeActivity extends Activity {

  private String _ipAddress;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_volume);

    Intent intent = getIntent();
    _ipAddress = intent.getStringExtra("SERVER");

    SeekBar volumeControler = (SeekBar) findViewById(R.id.volume);
    volumeControler.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

      @Override
      public void onStopTrackingTouch(SeekBar seekBar) {

      }

      @Override
      public void onStartTrackingTouch(SeekBar seekBar) {

      }

      @Override
      public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        (new NetworkThread(VolumeActivity.this, _ipAddress, "volume:" + progress, "VOLUME_SET")).start();
      }
    });
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
  }

  @Override
  public boolean onMenuItemSelected(int featureId, MenuItem item) {
    return handleMenuItemSelected(this, _ipAddress, featureId, item);
  }

  public static boolean handleMenuItemSelected(Context context, String ipAddress, int featureId, MenuItem item) {
    Intent intent = null;
    switch (item.getItemId()) {
    case R.id.action_mouse:
      intent = new Intent(context, MouseActivity.class);
      break;
    case R.id.action_volume:
      intent = new Intent(context, VolumeActivity.class);
      break;
    case R.id.action_keyboard:
      intent = new Intent(context, KeyboardActivity.class);
      break;
    }
    if (intent == null) {
      return false;
    }
    intent.putExtra("SERVER", ipAddress);
    context.startActivity(intent);
    return true;
  }

}




Java Source Code List

ch.sebastianhaeni.remotecontrol.KeyboardActivity.java
ch.sebastianhaeni.remotecontrol.MouseActivity.java
ch.sebastianhaeni.remotecontrol.MyEditText.java
ch.sebastianhaeni.remotecontrol.NetworkThread.java
ch.sebastianhaeni.remotecontrol.ServerSelectionActivity.java
ch.sebastianhaeni.remotecontrol.UDPListenerService.java
ch.sebastianhaeni.remotecontrol.VolumeActivity.java