Breaking News


Wednesday 25 December 2013

REFRESH ACTIVITY ANDROID EXAMPLE....

REFRESH ACTIVITY ANDROID EXAMPLE

FIRST OF CREATE ONE ACTIVITY AND TWO OBJECT CREATA SHOW BELOW CODE.... 


public class TimerActivity extends Activity {
Timer time;
int counter=0;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
    public void onResume() // CREATE ONE METHOD
    {
    super.onResume();
    time=new Timer();
    time.schedule(new TimerTask() {

@Override
public void run()
{
runOnUiThread(new Runnable() {

public void run()
{
temp();

}
});


}
}, 0,5000); // SET TIME FRO REFRESH ACTIVITY HERE 5 SECOND AFTER REFRESH ACTIVITY
    }
    private void temp()
    {
counter++;
Toast.makeText(getApplicationContext(), counter+"", Toast.LENGTH_SHORT).show();
}
    public void onPause()
    {
    time.cancel();
    super.onPause();
    }

}
Share This
Blogger
Facebook
Disqus

comments powered by Disqus

1 comment :

Subscribe
Labels
Popular Posts

Subscribe Via Email

About Us

THIS IS ANDROID AND JAVA FREE TUTORIAL AND ALL PROVIDE SOLUTION IN ANDROID AND JAVA INTERVIEW QUE AND ANS IS AVAILABLE IN MY BLOG AND ANY QUERY PLEASE CONTACT ME GO NOW CONTACT US PAGE.

Total Pageviews

© Android and Java solution All rights reserved | Designed By Fireandroids