Tuesday 25 February 2014

How does AirDroid works?

How AirDroid Works? 


I was very curious to know how the AirDroid works, though I was knowing that the data is being passed to HTML page from Android Native and also vice versa.

Actually this works based on hosting a own server on Android device.

Hosting server on your device is possible.

The hosting server is known as PAW server

What is PAW server?

PAW Server is a Web Server for Android devices.
With the PAW webserver you can use the functionality of your phone from a web browser, serve your own web pages or develop phone enabled web applications.


Where can I get It? 

You can get it here


Where can I get more information. 

You  can get it here

Wanna give a try? 

Click here


More about paw server will be coming soon. 

Wednesday 12 February 2014

Android DateTime receiver without using Broadcast Receiver

We usually use Date and Time listener to update Date & Time in our application. This can also be achieved using Runnable and Handler. Which is efficient and very accurate. It just requires the calculation of System Time and Current Time.

Below Snippet is used to update time based on Seconds.

Runnable runnable = new Runnable() {

    @Override
    public void run() {

        long date = System.currentTimeMillis(); 

        SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss");

        TextView txt = (TextView)findViewById(R.id.txt);
        txt.setText(sdf.format(date));

        handler.postDelayed(runnable, DateUtils.SECOND_IN_MILLIS - System.currentTimeMillis() % DateUtils.SECOND_IN_MILLIS);
    }
};

Similarly on Minute based

Runnable runnable = new Runnable() {

    @Override
    public void run() {

        long date = System.currentTimeMillis(); 

        SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss");

        TextView txt = (TextView)findViewById(R.id.txt);
        txt.setText(sdf.format(date));

        handler.postDelayed(runnable, DateUtils.MINUTE_IN_MILLIS - System.currentTimeMillis() % DateUtils.MINUTE_IN_MILLIS);
    }
};

 Similarly on Hourly Basis

Runnable runnable = new Runnable() {

    @Override
    public void run() {

        long date = System.currentTimeMillis(); 

        SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss");

        TextView txt = (TextView)findViewById(R.id.txt);
        txt.setText(sdf.format(date));

        handler.postDelayed(runnable, DateUtils.HOUR_IN_MILLIS - System.currentTimeMillis() % DateUtils.HOUR_IN_MILLIS);
    }
};


Similarly on Daily Basis, which is actually nobody uses. ROFL :D :D but still


Runnable runnable = new Runnable() {

    @Override
    public void run() {

        long date = System.currentTimeMillis(); 

        SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss");

        TextView txt = (TextView)findViewById(R.id.txt);
        txt.setText(sdf.format(date));

        handler.postDelayed(runnable, DateUtils.DAY_IN_MILLIS - System.currentTimeMillis() % DateUtils.DAY_IN_MILLIS);
    }
};

And so on. Enjoy coding.