|
|
|
Android Write Resource
Android Source Code
Java program for surveillance using an Android smartphone. Webcam with FTP access to the photo storage.
Android Safety SYSTEM >>
Because in application Rescue PHOTO, the main procedures are performed by a timer, it is necessary to turn on and off the timer. For example, if you are just setting up the work of the photocontrol system.
Let's create a button and write a processing procedure:
public void onButtonClick(View view) {
// Stop / Start timer
Button button = (Button)findViewById(R.id.stop); // Button with ID STOP
if (TimePoint == 0) {
timer.cancel();
timer = null;
Log.i(TAG, "==== Timer STOPED ===="); // Writing a message to LOG
TimePoint = 1;
} else {
timer = new Timer();
mTimerTask = new MyTimerTask();
timer.schedule(mTimerTask, 1000, 1000);
Log.i(TAG, "==== Timer STARTED ===="); // Writing a message to LOG
TimePoint = 0;
//==================================================
}
}
TimePoint == 0 - This variable acts as a trigger. Accepts the value 0 or 1.
LOG messages are left in the source code for debugging. They are not needed in the finished application.
Another variation on the timer source code:
private Handler handler = new Handler();
private boolean isRunning;
public void onClick2(View view) { - Timer start
isRunning = true;
handler.post(new Runnable() {
@Override
public void run() {
if (isRunning) {
Button button = (Button) findViewById(R.id.button);
button.performClick();
handler.postDelayed(this, 1000);
}
}
});
}
private void invokeStop() { - Timer stop
isRunning = false;
}
Handler
The handler can help us manage the UI thread in the child thread, for example, the child thread parses the data and notifies the UI to update the UI after parsing. It can also implement timers on its own.
private Handler handler = new Handler() {
public void handleMessage(android.os.Message msg) {
switch (msg.what) {
case 0:
// Delete all messages like msg.what before 0 and make sure there is only one circular message queue before starting
handler.removeMessages(0);
// Functional application processing logic
...
// Releasing the message again, updating in a loop
handler.sendEmptyMessageDelayed(0, 1000);
break;
case 1:
// Delete directly, timer stops
handler.removeMessages(0);
break;
default:
break;
}
};
};
With Handler you can send messages to TextView
Handler allows you to put messages in the queue and is able to process them itself. The trick here is that he can put a message from one stream, and read it from another.
dnl0001.htm - about Rescue PHOTO
dnl0002.htm - application in a car
dnl0003.htm - monitor the car park
dnl0004.htm - Office desktop control
dnl0005.htm - source code ftpConnect
dnl00016.htm - source code Image File Write
Android Safety SYSTEM >>
You can use the web page with HTML and Java Script code. Such a web page can be hosted on any hosting. Or use the PHP web page and get more information. But then your free or paid hosting must support PHP.
Android Source Code >> Sitemap >>
The application has complex Java code. The source code spans several pages. Source codes of application modules are available on GitHub.
The Wayback Machine is an initiative of the Internet Archive, a 501(c)(3) non-profit, building a digital library of Internet sites and other cultural artifacts in digital form.
Android Write Resource
|
|
|
|