Back to project page watcher.
The source code is released under:
CC0 1.0 Universal Statement of Purpose The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent...
If you think the Android project watcher listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.appspot.staffordbears.watcher; /* w ww .ja v a2 s . co m*/ import android.app.Application; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothSocket; import android.os.Handler; import android.os.Looper; import android.util.Log; import android.widget.TextView; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.Runnable; import java.util.UUID; import java.util.LinkedList; import java.util.Queue; import java.util.Date; import java.text.SimpleDateFormat; public class Hermit extends Application { public Watch mAct; public CommLink mService; private static final String TAG = "watcher.Hermit"; private static final int QLEN = 20; protected class LimitedQueue<E> extends LinkedList<E> { private int limit; public LimitedQueue(int limit) { this.limit = limit; } @Override public boolean add(E o) { super.add(o); while (size() > limit) { super.remove(); } return true; } } public Queue<String> mLogMessages = new LimitedQueue<String>(QLEN); public Queue<Date> mMotions = new LimitedQueue<Date>(QLEN); public Queue<Date> mPictures = new LimitedQueue<Date>(QLEN); public String summary() { Queue<String> me_q = new LinkedList<String>(mLogMessages); Queue<Date> mo_q = new LinkedList<Date>(mMotions); Queue<Date> pic_q = new LinkedList<Date>(mPictures); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd/HH:mm:ss"); String sum = new String(); int index; sum += "*** messages ***\n"; index = 1; while (me_q.peek() != null) { sum += index + "/" + QLEN + " " + me_q.remove() + "\n"; index++; } sum += "*** motion ***\n"; index = 1; while (mo_q.peek() != null) { String t_mo = sdf.format(mo_q.remove()); sum += index + "/" + QLEN + " " + t_mo + "\n"; index++; } sum += "*** pictures ***\n"; index = 1; while (pic_q.peek() != null) { String t_pic = sdf.format(pic_q.remove()); sum += index + "/" + QLEN + " " + t_pic + "\n"; index++; } return sum; } }