Android Open Source - CopresenceDataCollector Sensor Activity






From Project

Back to project page CopresenceDataCollector.

License

The source code is released under:

Copyright (c) 2014, Xiang Gao All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Re...

If you think the Android project CopresenceDataCollector 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.sesy.coco.datacollector;
//from  ww  w  .  j  a  v  a2 s.c  o  m

import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.sesy.coco.datacollector.log.ConfigureLog4J;

import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceActivity;
import android.widget.RemoteViews;

public class SensorActivity extends PreferenceActivity {
  
  
  private PrefManager pM;
  private StatusManager sM;
  //private CheckBoxPreference _cBoxPref1, _cBoxPref2;
  private static int wid = 0;
  private int tmpbhr;
  private Context context;
  AppWidgetManager appWidgetManager;
  RemoteViews remoteViews;
  Logger log;
  public static boolean settingStatus = false;
  
  @SuppressWarnings("deprecation")
  @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        log = Logger.getLogger(SensorActivity.class);  
        ConfigureLog4J.configure(this);  
        LogManager.getRootLogger().setLevel((Level)Level.DEBUG);   
        log.info("onCreate");
        
        Bundle extras = getIntent().getExtras();        
    if(extras != null){
          wid = extras.getInt("wid");
        }
    
    pM = new PrefManager(getApplicationContext());
    sM = new StatusManager(getApplicationContext());
    //sM.getStatus();
        // Load the preferences from an XML resource
        addPreferencesFromResource(R.xml.sensor_preferences);        
        
        context = getApplicationContext();
        remoteViews = new RemoteViews(context.getPackageName(), R.layout.appwidget);
    appWidgetManager = AppWidgetManager.getInstance(this);
    
        //Thread thr = new Thread(null, sTask1, "Setting");
        //thr.start();
    }
  
  Runnable wTask = new Runnable() {
        public void run() {
          sM.getStatus();        
            sM.updateWidgetStatus();  
        }
  };
  
  Runnable sTask2 = new Runnable() {
        public void run() {
          DataMonitor.sendData(context, DataMonitor.class, wid, DataMonitor.APP_SELECTOR_FINISHED_CODE, null, null, DataMonitor.DISREGARD_ID);
        
        }
  };
  
  @Override
  public void onStart(){
    super.onStart();
    //_prefs = PreferenceManager.getDefaultSharedPreferences(this);
    
  }
  @Override
  protected void onResume() {
      super.onResume();
      
      settingStatus = true;
    AlarmService.alarmStatus = false;
        if(AlarmService.vib != null){
        AlarmService.vib.cancel();
      }
      if(AlarmService.r != null){
        AlarmService.r.stop();
      } 
      new Thread(null, wTask, "wUpdate").start();
    log.info("sM widget+task updated");
      /*RemoteViews remoteViews = new RemoteViews(this.getApplicationContext().getPackageName(), R.layout.appwidget);
      UpdateWidgetService.widgetStatus = 1;
        remoteViews.setViewVisibility(R.id.asklayout, View.GONE);
      remoteViews.setViewVisibility(R.id.remindlayout, View.GONE);
      remoteViews.setViewVisibility(R.id.initlayout, View.VISIBLE);  
      AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
      appWidgetManager.updateAppWidget(new ComponentName(this.getPackageName(), MyWidgetProvider.class.getName()), remoteViews);
   */
      //getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
  }

  @Override
  protected void onPause() {
    log.info("onPause");
    settingStatus = false;
    new Thread(null, wTask, "wUpdate").start();
    
    log.info("sM widget+task updated");
    
      super.onPause();
      //getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
  }
  
  @Override
  protected void onStop() {
    
    //DataMonitor.sendData(this, DataMonitor.class, wid, DataMonitor.APP_SELECTOR_FINISHED_CODE, null, null, wid);
    Thread thr = new Thread(null, sTask2, "SetUpdate");
        thr.start();
    //finish();
      super.onStop();
            
  }
  
  @Override
  protected void onDestroy() {
    super.onDestroy();    
  }
  
  
}




Java Source Code List

org.sesy.coco.datacollector.ARPWorker.java
org.sesy.coco.datacollector.AlarmService.java
org.sesy.coco.datacollector.AppLauncher.java
org.sesy.coco.datacollector.AudioProc.java
org.sesy.coco.datacollector.AudioWorker.java
org.sesy.coco.datacollector.BindActivity.java
org.sesy.coco.datacollector.BluetoothWorker.java
org.sesy.coco.datacollector.CellWorker.java
org.sesy.coco.datacollector.Constants.java
org.sesy.coco.datacollector.DaemonService.java
org.sesy.coco.datacollector.DataMonitor.java
org.sesy.coco.datacollector.GpsWorker.java
org.sesy.coco.datacollector.HelpActivity.java
org.sesy.coco.datacollector.MainActivity.java
org.sesy.coco.datacollector.MyPreference.java
org.sesy.coco.datacollector.MyWidgetProvider.java
org.sesy.coco.datacollector.PluginManager.java
org.sesy.coco.datacollector.PrefManager.java
org.sesy.coco.datacollector.ReportErrActivity.java
org.sesy.coco.datacollector.SDSetupActivity.java
org.sesy.coco.datacollector.SensorActivity.java
org.sesy.coco.datacollector.SensorListener.java
org.sesy.coco.datacollector.SensordroneWorker.java
org.sesy.coco.datacollector.SettingActivity.java
org.sesy.coco.datacollector.StatusActivity.java
org.sesy.coco.datacollector.StatusManager.java
org.sesy.coco.datacollector.TriggerService.java
org.sesy.coco.datacollector.UpdateWidgetService.java
org.sesy.coco.datacollector.WifiWorker.java
org.sesy.coco.datacollector.WorkerService.java
org.sesy.coco.datacollector.audio.Convolution.java
org.sesy.coco.datacollector.audio.CrossCorrelation.java
org.sesy.coco.datacollector.audio.ExtAudioRecorder.java
org.sesy.coco.datacollector.audio.XCorrAndDistFromWav.java
org.sesy.coco.datacollector.communication.HttpFileUploader.java
org.sesy.coco.datacollector.database.Entry.java
org.sesy.coco.datacollector.file.FileHelper.java
org.sesy.coco.datacollector.log.ConfigureLog4J.java
org.sesy.coco.datacollector.net.NetInfo.java
org.sesy.coco.datacollector.plugin.PlugInterface.java
wei.mark.standout.StandOutWindow.java
wei.mark.standout.Utils.java
wei.mark.standout.WindowCache.java
wei.mark.standout.constants.StandOutFlags.java
wei.mark.standout.ui.TouchInfo.java
wei.mark.standout.ui.Window.java