Android Open Source - android-uds U I Activity






From Project

Back to project page android-uds.

License

The source code is released under:

MIT License

If you think the Android project android-uds 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 org.imazlwifu.uds;
/*w ww.  j  ava 2  s . c o m*/
import org.imazlwifu.uds.model.Battery;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

/**
 * An entry point example.
 * 
 * 
 * @author Sascha Eiteneuer
 *
 */
public class UIActivity extends Activity {
  private LibConfig config;
  private UDS uds;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setUpUDS();
    
    uiBinding();
  }
  
  private void setUpUDS() {
    config = (LibConfig) getApplication();
    // Test Code - not a clean implementation
    config.setTextBox( new TextView( this ) );
    
    uds = config.getUDS();
    uds.setMonitoringInterval( 10 );
    uds.putMonitoredSensors();
    uds.putCustomMonitorable( Battery.class );
/* TODO    
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this)
      .addNextIntent( new Intent( this, StopServiceActivity.class) );
    
    Notification n = new NotificationCompat.Builder( this )
      .setContentTitle( "monitoring updated" )
        .setContentText( "swipe down to expand" )
        .setSmallIcon( android.R.drawable.stat_notify_sync_noanim )
//        .setContentInfo( "iteration: "+ iteration )
        .setAutoCancel( true )
        .addAction( android.R.drawable.ic_menu_delete, "stop monitoring", stackBuilder.getPendingIntent( 0, 0 ) )
//          .setContentIntent( stackBuilder.getPendingIntent( 0, 0 ) )
      .build();
    */

  }

  private void uiBinding() {
    setContentView( config.getTextBox() );
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    menu.add( 0, 0, 0, "settings" );
    menu.add( 1, 1, 1, "start service" );
    menu.add( 1, 2, 2, "STOP service" );
    return true;
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch( item.getItemId() ) {
      case 0:
        uds.startPreferenceActivity( this );
        break;
      case 1:
        uds.startService();
        break;
      case 2:
        uds.stopService();
        break;
    }
    
    return true;
  }
}




Java Source Code List

org.imazlwifu.uds.DataService.java
org.imazlwifu.uds.LibConfig.java
org.imazlwifu.uds.PreferencesActivity.java
org.imazlwifu.uds.UDS.java
org.imazlwifu.uds.UIActivity.java
org.imazlwifu.uds.Util.java
org.imazlwifu.uds.ipc.AlarmReceiver.java
org.imazlwifu.uds.ipc.PublishingDataReceiver.java
org.imazlwifu.uds.ipc.ServiceStarter.java
org.imazlwifu.uds.ipc.ServiceTerminator.java
org.imazlwifu.uds.model.Battery.java
org.imazlwifu.uds.model.Monitorable.java
org.imazlwifu.uds.model.MonitoredSensor.java
org.imazlwifu.uds.rpc.DataPublisher.java
org.imazlwifu.uds.rpc.HTTPRemoteConnection.java
org.imazlwifu.uds.rpc.RemoteConnection.java