Actually i am building an app for online chat... i am trying to check server after certain interval if there is any new data or not. if any new message exists on server that will be downloaded and shown in the app... the main reason i want to do this is to get latest message on device as soon as it arrives on server..
On Tuesday, July 10, 2012 9:19:00 PM UTC+5:30, MagouyaWare wrote: > > What are you trying to accomplish by doing this? Surely you don't want to > be starting the activity from scratch again every time just to update the > data that is displayed? > > Thanks, > Justin Anderson > MagouyaWare Developer > http://sites.google.com/site/magouyaware > > > On Fri, Jul 6, 2012 at 5:36 AM, Akhil wrote: > >> >> Hi, >> >> I want to reload my activity after every 1 minute. I tried using handler >> for this... but problem is that when i press back key of device, it doesn't >> stop and goes into an infinite loop.. >> >> here is my code what i have done-- >> >> >> public class Chat extends Activity { >> Handler handler; >> public void onCreate(Bundle savedInstance) { >> super.onCreate(savedInstance); >> setContentView(R.layout.chat); >> handler = new Handler(); >> >> Toast.makeText(getApplicationContext(), "again", 400).show(); >> >> doTheAutoRefresh(); >> } >> >> private void doTheAutoRefresh() { >> handler.postDelayed(new Runnable() { >> public void run() { >> Intent intent = getIntent(); >> startActivity(intent); >> finish(); >> //doTheAutoRefresh(); >> } >> }, 10000); >> >> } >> >> public void onPause(){ >> super.onPause(); >> } >> } >> >> >> Thanks, >> Akhil >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en > > > On Tuesday, July 10, 2012 9:19:00 PM UTC+5:30, MagouyaWare wrote: > > What are you trying to accomplish by doing this? Surely you don't want to > be starting the activity from scratch again every time just to update the > data that is displayed? > > Thanks, > Justin Anderson > MagouyaWare Developer > http://sites.google.com/site/magouyaware > > > On Fri, Jul 6, 2012 at 5:36 AM, Akhil wrote: > >> >> Hi, >> >> I want to reload my activity after every 1 minute. I tried using handler >> for this... but problem is that when i press back key of device, it doesn't >> stop and goes into an infinite loop.. >> >> here is my code what i have done-- >> >> >> public class Chat extends Activity { >> Handler handler; >> public void onCreate(Bundle savedInstance) { >> super.onCreate(savedInstance); >> setContentView(R.layout.chat); >> handler = new Handler(); >> >> Toast.makeText(getApplicationContext(), "again", 400).show(); >> >> doTheAutoRefresh(); >> } >> >> private void doTheAutoRefresh() { >> handler.postDelayed(new Runnable() { >> public void run() { >> Intent intent = getIntent(); >> startActivity(intent); >> finish(); >> //doTheAutoRefresh(); >> } >> }, 10000); >> >> } >> >> public void onPause(){ >> super.onPause(); >> } >> } >> >> >> Thanks, >> Akhil >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en > > > On Tuesday, July 10, 2012 9:19:00 PM UTC+5:30, MagouyaWare wrote: > > What are you trying to accomplish by doing this? Surely you don't want to > be starting the activity from scratch again every time just to update the > data that is displayed? > > Thanks, > Justin Anderson > MagouyaWare Developer > http://sites.google.com/site/magouyaware > > > On Fri, Jul 6, 2012 at 5:36 AM, Akhil wrote: > >> >> Hi, >> >> I want to reload my activity after every 1 minute. I tried using handler >> for this... but problem is that when i press back key of device, it doesn't >> stop and goes into an infinite loop.. >> >> here is my code what i have done-- >> >> >> public class Chat extends Activity { >> Handler handler; >> public void onCreate(Bundle savedInstance) { >> super.onCreate(savedInstance); >> setContentView(R.layout.chat); >> handler = new Handler(); >> >> Toast.makeText(getApplicationContext(), "again", 400).show(); >> >> doTheAutoRefresh(); >> } >> >> private void doTheAutoRefresh() { >> handler.postDelayed(new Runnable() { >> public void run() { >> Intent intent = getIntent(); >> startActivity(intent); >> finish(); >> //doTheAutoRefresh(); >> } >> }, 10000); >> >> } >> >> public void onPause(){ >> super.onPause(); >> } >> } >> >> >> Thanks, >> Akhil >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en > > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

