Пример #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // listOfSongs = getListOfSongs();
    // for (Song song : listOfSongs) {
    // Toast.makeText(getApplicationContext(), song.toString(),
    // Toast.LENGTH_LONG).show();
    // }

    // Get a handle to the activity update list
    mStatusListView = (ListView) findViewById(R.id.log_listview);
    mStatusAdapter = new ArrayAdapter<Spanned>(this, R.layout.item_layout, R.id.log_text);
    mStatusListView.setAdapter(mStatusAdapter);
    mBroadcastManager = LocalBroadcastManager.getInstance(this);
    mBroadcastFilter = new IntentFilter(ActivityUtils.ACTION_REFRESH_STATUS_LIST);
    mBroadcastFilter.addCategory(ActivityUtils.CATEGORY_LOCATION_SERVICES);

    mDetectionRequester = new DetectionRequester(this);
    mDetectionRemover = new DetectionRemover(this);

    mLogFile = LogFile.getInstance(this);

    // for location
    locationClient = new LocationClient(this, this, this);
    // creating request object with some of parameters set
    locationRequest =
        LocationRequest.create()
            .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
            .setInterval(UPDATE_INTERVAL);
  }
Пример #2
0
 /** Display the activity detection history stored in the log file */
 private void updateActivityHistory() {
   try {
     List<Spanned> activityDetectionHistory = mLogFile.loadLogFile();
     mStatusAdapter.clear();
     for (Spanned activity : activityDetectionHistory) {
       mStatusAdapter.add(activity);
     }
     if (mStatusAdapter.getCount() > MAX_LOG_SIZE) {
       if (!mLogFile.removeLogFiles()) {
         Log.e(ActivityUtils.APPTAG, getString(R.string.log_file_deletion_error));
       }
     }
     mStatusAdapter.notifyDataSetChanged();
   } catch (IOException e) {
     Log.e(ActivityUtils.APPTAG, e.getMessage(), e);
   }
 }