Tuesday, January 3, 2017

The Simplest Async Task possible

private class SomeAsyncTask extends AsyncTask<Void, Void, Void> {

    @Override    protected Void doInBackground(Void... voids) {
        Log.d(P.Tag, "doInBackground");
        return null;

Sunday, November 20, 2016

Activity does not have the latest intent information put in the pending intent extras

It happens when the activity is resumed.

You need to:

1. In the intent:
  PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,

  If you have more then one notification at a time, set the request code uniquely

  PendingIntent pendingIntent = PendingIntent.getActivity(this, uniqueIntForName, intent, PendingIntent.FLAG_UPDATE_CURRENT);

  This way you will have the correct extras for the specific notification when lunching the 

2. In the Activity the pending intent is calling:

   public void onNewIntent(Intent newIntent) {
    Log.i(P.Tag, "===onNewIntent called===");

Friday, November 11, 2016

How to uninstall an app from wearable

Android wear connect via Bluetooth

adb forward tcp:4444 localabstract:/adb-hub
adb connect

Uninstall a standalone app

adb -s uninstall com.netcompss.fl_groups

If you want to uninstall a regular app, then just uninstall the phone app, and the wearable app will uninstall automaticly

Friday, October 28, 2016

OK Google beep sound fix

Google decided to remove the beep sound from the OK Google assistant.
Lots of users hate this decision, giving the Google app bad reviews, but Google will not fold.

Here is how to get the beep sound back in a few easy steps:

Setting, accessibility, switch access to on.

Here is a video that shows, the issue, and how to solve it:


Sunday, September 18, 2016

Simple Java Timer (Can be used in Android)

With the default fixed-period execution, each successive run of a task is scheduled relative to the start time of the previous run, so two runs are never fired closer together in time than the specified period. With fixed-rate execution, the start time of each successive run of a task is scheduled without regard for when the previous run took place. This may result in a series of bunched-up runs (one launched immediately after another) if delays prevent the timer from starting tasks on time.

// First run after 2000ms, next run after 1000ms
public static void testTimer() {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
int i = 0;
public void run() {
Random rand = new Random();
int randInt5000 = rand.nextInt(5000);
System.out.println("working : " + randInt5000);
try {
} catch (InterruptedException e) {
// TODO Auto-generated catch block
if (i == 5) timer.cancel();

}, 2000, 1000);


Monday, July 25, 2016

Sending a Toast from a Service

Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() { @Override public void run()
    Toast.makeText(getApplicationContext(), "Detection Service Failed, restart it", Toast.LENGTH_LONG).show();

Sunday, June 19, 2016

Security Camera Help

Security Camera is an Advanced Security / Spy / Baby, Pet Monitor App, available for free download on Google Play.

Operation Modes

Motion detection with video

This is the default operation mode, it will take image every x seconds (default is 3), 
and will run motion detection on it. If motion is detected, 
it will upload a the picture to your Google Drive
Account, and will record a video.
The quality of the video can be controlled from the app setting,
it will effect the time of the recorded video.
The lower the video quality the longer the video.

Pictures Only

The same as above, but will not record a video (will only upload a picture).

Video Burst

Records a sequence of videos (The default is 4).
After the recording is over, will return to the previous mode of operation.
This mode is useful when a major event is detected, and you need to have more information on it.
This (as all over modes) can be controlled remotely by the controller.

Audio Only

The same as the first mode, but instead of recording video, it will record a high quality audio.
This mode is useful when audio is more important, and you want to save battery, and get the uploads 
media more quickly.

The Controller

All your detectors (phone devices that acts as motion detectors), can be controlled remotely
Using the Controller,
Your detectors can be anywhere in the world, in a place with internet connection,
And your controller will be able to control them.
The controller will send the control command to the detectors (you will see the message: 
"command was sent"), and the detector will act according to the new command.
For example, if you changed the mode to video burst, all the videos from the video burst, 
will be pushed to your Viewer/CTRL device. 
If you change the video to high quality, a high quality video will be pushed to your device.

Tips & Tricks

+ Its recommended to connect the detector to a power source. 
It could be a regular charger, but if not available, you can use a power stick.
Our tests shows that on regular use, a detector could last without power for around 6 hours.
But since most devices used as a detectors are old ones (and their battery is used), 
the above is recommended. 

+ Make sure your device WiFi is not configured to stop when the device sleeps.

+ When detection service is on, its recommended to leave the security camera app on the front 
Before switching the device screen off (putting device to sleep).
This way Android will not kill the detection service.

+ When done with the detection service, 
make sure you switch it off before continuing using your 
device as a regular device.
Failing to do so will drain the battery an upload unnecessary media to your Google Drive. 

+ You can setup your device as as both Detector and Viewer for testing purposes.
  To do this, simply restart the wizard (options, Restart Setup Wiz), and setup your device 
  Again, make sure you use the same Google Account.


  This way your device will be able to capture images and videos, and also get them via push