[android-developers] Re: runOnUIThread method in doInBackground of Async Task...

2011-10-03 Thread Studio LFP
If you aren't using the android:configChanges tag on your activity in the 
AndroidManifest.xml then you application is getting killed and restarted on 
rotation or keyboard changes like when someone slides out a hardware 
keyboard. When this happens, you need to save off the position in your 
AsyncTask and restart it back when the activity gets restarted.

Or you can simple add something like 
android:configChanges="orientation|keyboardHidden" to your activity in the 
AndroidManifest.xml and then your activity won't be killed and restarted. 
You can then override the onConfigurationChanged method to see when these 
things happen if you want to know.

Check this for more info: 
http://developer.android.com/guide/topics/manifest/activity-element.html#config

If you are using properly flowing layouts, most of the time you won't even 
have to do anything at all. If you need specific layouts for portrait and 
landscape, the android:configChanges may make things more complicated than 
just saving off the status of your AsyncTask and restarting it from that 
point.

Steven
Studio LFP
http://www.studio-lfp.com


On Monday, October 3, 2011 12:25:58 PM UTC-5, Bluemercury wrote:
>
> Hi! im using an Async-Task and currently im using runOnUiThread in the 
> doInBackground method to refresh activities UI, this seems to be working but 
> on rotation it loses the data and im usng the 
> getLastNonConfigurationInstance and the onRetainNonConfigurationInstance 
> methods, here's the parent class method that calls the async task:
>
>
> /**
>  * do asynctask for background work
>  */
> public void doAsyncTask(){
> //get task back in case of rotation
> task= (QuadrosMobileActivityTask)getLastNonConfigurationInstance();
>
> if(task==null){
> task= new QuadrosMobileActivityTask(this);
> task.execute();
> //add to the set of tasks
> QuadrosMobileApplicationContext appliContext= 
> (QuadrosMobileApplicationContext)getApplicationContext();
> appliContext.getAsyncTasks().add(task);
> }else{
> task.attach(this);
> }
> }
>
> Here's the async task as normal class(non inner class) main methods;
>
>@Override
> protected void onPreExecute() {
> Logger.write("QuadrosMobileActivityTask ", " AsyncTask pre execution "+ 
> "Current Activity: "+activity.getClass().getName(), Logger.INFO);
>
> if(QuadrosMobileActivity.themeId!=R.style.CustomThemeNoHeader){
>
> activity.findViewById(R.id.progressView).setVisibility(ProgressBar.VISIBLE);
> }
> QuadrosMobileActivity.progressBarstate=ProgressBar.VISIBLE;
> } 
>
> @Override
> protected String doInBackground(Void... params) {
> Logger.write("QuadrosMobileActivityTask ", "initialized", Logger.INFO);
> return activity.*updateResultsInUi()*;
> }
>
> @Override
> protected void onPostExecute(String result) {
> Logger.write("QuadrosMobileActivityTask ", " AsyncTask post execution 
> "+"Current Activity: "+activity.getClass().getName(), Logger.INFO);
>
> if(activity!=null)
> Toast.makeText(activity, result, Toast.LENGTH_LONG).show();
> //remove this task from collection
> QuadrosMobileApplicationContext appliContext= 
> QuadrosMobileApplicationContext.getInstance();
> appliContext.getAsyncTasks().remove(this); 
>
> //check if there's more tasks in the collection
> if(appliContext.getAsyncTasks().isEmpty()){
> if(QuadrosMobileActivity.themeId!=R.style.CustomThemeNoHeader){
> activity.findViewById(R.id.progressView).setVisibility(ProgressBar.GONE);
> }
> QuadrosMobileActivity.progressBarstate=ProgressBar.GONE;
> }
> }
>
> And the sub activities *updateResultsInUi() *method:
>
> runOnUiThread(
>  new Runnable() {
>
> @Override
> public void run() { 
> ((TextView)findViewById(R.id.nome_value)).setText(quadro.getNome());
>
> //((TextView)findViewById(R.id.nif_value)).setText(quadro.getDadosPessoais().getNumeroContribuinte());
>
> ((TextView)findViewById(R.id.datanasc_value)).setText(DateTimeZoneUtils.getInstance().sqlLiteDateTimeFormat(quadro.getDadosPessoais().getDataNascimento()));
>
> ((TextView)findViewById(R.id.provincia_value)).setText(quadro.getResidencia().getProvincia());
>
> ((TextView)findViewById(R.id.municipio_value)).setText(quadro.getResidencia().getMunicipio());
>
> ((TextView)findViewById(R.id.comuna_value)).setText(quadro.getResidencia().getComuna());
>
> ((TextView)findViewById(R.id.bairro_value)).setText(quadro.getResidencia().getBairro());
>
> ((TextView)findViewById(R.id.rua_value)).setText(quadro.getResidencia().getRua());
> }
> }
> );
>
> Can i use the runOnUIThread method inside the doInBackground method of 
> AsyncTask??
> regards,
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: runOnUIThread method in doInBackground of Async Task...

2011-10-03 Thread TreKing
On Mon, Oct 3, 2011 at 5:28 PM, Studio LFP  wrote:

> When this happens, you need to save off the position in your AsyncTask and
> restart it back when the activity gets restarted.


The OP is using getLastNonConfigurationInstance(), which would indicate he's
keeping the same AsyncTask instance across the application restart, so he
wouldn't have to restart the AsyncTask.

2011/10/3 João Rossa 

> Well when i rotate, either while the thread is started or after the screen
> data is refreshed it goes back to the fields having not been filled. but the
> thread does run because if i dont rotate the UI views are filled with the
> content i fetch from the server.


Looks like you AsyncTask is an inner-class of your Activity, which means
that when you start it, it has an implicit reference to the Activity that
started it. When you rotate the device, that Activity is destroyed but your
AsyncTask is still holding on to it, so when you do findViewById() in your
Runnable, you're acting on the old instance that is no longer visible.

One thing you can do is make the AsyncTask *not* an inner-class and give it
an *explicit* reference to the Activity it's working on, then reset that
instance to the new Activity once your activity is restarted.

Or something like that.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: runOnUIThread method in doInBackground of Async Task...

2011-10-03 Thread João Rossa
Actually my async task is not a inner static class, and it still has a
explicit reference to the activity that i refresh,

*here's the parent activity:*

public abstract class ParentActivity extends Activity{

protected static int progressBarstate=ProgressBar.GONE;
protected static int themeId;

private ParentActivityTask task=null;

//this method will get the id for the layout
public abstract int getLayoutId();
//this method will launch respejcting oncreate logic for each activity
public abstract void initActivity();
//thi smethod will return window header menu context text string
public abstract String getWindowTitle();
//this method is used to refresh contents for a screen
public abstract String updateResultsInUi();
//nethod for definined specific theme
public abstract int getThemeId();

@Override
protected void onCreate(Bundle savedInstanceState) {


//set theme first for showing correct header
setTheme(getThemeId());

super.onCreate(savedInstanceState);

themeId=getThemeId();
//in case the screen will have a header
if(getThemeId()!=R.style.CustomThemeNoHeader){

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

setContentView(getLayoutId());

getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.custom_window_title);

//save progressview on application context
QuadrosMobileApplicationContext.getInstance().setProgressView((LinearLayout)
findViewById(R.id.progressView));

//set text header
((TextView)findViewById(R.id.header_title)).setText(getWindowTitle());

progressRefreshState(progressBarstate);

}else
{
setContentView(getLayoutId());
}

//execute subactivity logic
initActivity();

}

/**
 * check for loading/spinner icon in
 *  case there's a thread working in background
 */
@Override
public void onRestart () {
super.onRestart();
if(getThemeId()!=R.style.CustomThemeNoHeader){
QuadrosMobileApplicationContext.getInstance().setProgressView((LinearLayout)
findViewById(R.id.progressView));
progressRefreshState(progressBarstate);

}
}

@Override
protected void onResume() {
super.onResume();

QuadrosMobileApplicationContext.getInstance().refreshAsyncTasksActivity(this);
}


@Override
protected void onPause() {
super.onPause();

QuadrosMobileApplicationContext.getInstance().clearActivityAsyncTasks();
}

@Override
public Object onRetainNonConfigurationInstance() {
if(task!=null)
task.detach();

return(task);
}

/**
 * refresh static references for both progress
 * info views and set visibility state
 */
private void progressRefreshState(int state) {
findViewById(R.id.progressView).setVisibility(state);
}

 /**
 * do asynctask for background work
 */
public void doAsyncTask(){
//get task back in case of rotation
task= (ParentActivityTask)getLastNonConfigurationInstance();

if(task==null){
task= new ParentActivityTask(this);
task.execute();
//add to the set of tasks
QuadrosMobileApplicationContext appliContext=
(QuadrosMobileApplicationContext)getApplicationContext();
appliContext.getAsyncTasks().add(task);
}else{
task.attach(this);
}
}
 }

here's the async task as non inner class:

ublic class ActivityTask extends AsyncTask{
ParentActivity activity=null;


public ActivityTask(QuadrosMobileActivity activity) {

attach(activity);
}

@Override
protected void onPreExecute() {

if(QuadrosMobileActivity.themeId!=R.style.CustomThemeNoHeader){
ParentActivity.findViewById(R.id.progressView).setVisibility(ProgressBar.VISIBLE);
}
QuadrosMobileActivity.progressBarstate=ProgressBar.VISIBLE;
}

@Override
protected String doInBackground(Void... params) {
 return ParentActivity.updateResultsInUi();
}

@Override
protected void onPostExecute(String result) {
 if(activity!=null)
Toast.makeText(activity, result, Toast.LENGTH_LONG).show();
QuadrosMobileApplicationContext appliContext=
QuadrosMobileApplicationContext.getInstance();
appliContext.getAsyncTasks().remove(this);

if(appliContext.getAsyncTasks().isEmpty()){
if(QuadrosMobileActivity.themeId!=R.style.CustomThemeNoHeader){
ParentActivity .findViewById(R.id.progressView).setVisibility(ProgressBar.GONE);
}
QuadrosMobileActivity.progressBarstate=ProgressBar.GONE;
}
}

void detach() {
activity=null;
}

void attach(ParentActivity activity) {
this.activity=activity;
}
}


On Tue, Oct 4, 2011 at 12:18 AM, TreKing  wrote:

> On Mon, Oct 3, 2011 at 5:28 PM, Studio LFP  wrote:
>
>> When this happens, you need to save off the position in your AsyncTask and
>> restart it back when the activity gets restarted.
>
>
> The OP is using getLastNonConfigurationInstance(), which would indicate
> he's keeping the same AsyncTask instance across the application restart, so
> he wouldn't have to restart the AsyncTask.
>
> 2011/10/3 João Rossa 
>
>> Well when i rotate, either while the thread is started or after the screen
>> data is refreshed it goes back to the fields having not been filled. but the
>> thread does run because if i dont rotate the UI views are filled with the
>> content i fetch from the server.
>
>
> Looks like you AsyncTask is an inner-class of your Activity, which 

Re: [android-developers] Re: runOnUIThread method in doInBackground of Async Task...

2011-10-03 Thread João Rossa
Never mind the name of the async taskits ParentActivityTask.

2011/10/4 João Rossa 

> Actually my async task is not a inner static class, and it still has a
> explicit reference to the activity that i refresh,
>
> *here's the parent activity:*
>
> public abstract class ParentActivity extends Activity{
>
> protected static int progressBarstate=ProgressBar.GONE;
> protected static int themeId;
>
> private ParentActivityTask task=null;
>
> //this method will get the id for the layout
>  public abstract int getLayoutId();
> //this method will launch respejcting oncreate logic for each activity
>  public abstract void initActivity();
> //thi smethod will return window header menu context text string
>  public abstract String getWindowTitle();
> //this method is used to refresh contents for a screen
>  public abstract String updateResultsInUi();
> //nethod for definined specific theme
>  public abstract int getThemeId();
>
> @Override
> protected void onCreate(Bundle savedInstanceState) {
>
>
> //set theme first for showing correct header
> setTheme(getThemeId());
>
> super.onCreate(savedInstanceState);
>
> themeId=getThemeId();
>  //in case the screen will have a header
> if(getThemeId()!=R.style.CustomThemeNoHeader){
>
> requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
>
> setContentView(getLayoutId());
>
> getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
> R.layout.custom_window_title);
>
> //save progressview on application context
>  QuadrosMobileApplicationContext.getInstance().setProgressView((LinearLayout)
> findViewById(R.id.progressView));
>
> //set text header
>  ((TextView)findViewById(R.id.header_title)).setText(getWindowTitle());
>
>  progressRefreshState(progressBarstate);
>
> }else
> {
>  setContentView(getLayoutId());
> }
>
> //execute subactivity logic
>  initActivity();
>
> }
>
> /**
>  * check for loading/spinner icon in
>  *  case there's a thread working in background
>  */
> @Override
> public void onRestart () {
>  super.onRestart();
> if(getThemeId()!=R.style.CustomThemeNoHeader){
> QuadrosMobileApplicationContext.getInstance().setProgressView((LinearLayout)
> findViewById(R.id.progressView));
>  progressRefreshState(progressBarstate);
>
> }
> }
>
> @Override
> protected void onResume() {
> super.onResume();
>
>
> QuadrosMobileApplicationContext.getInstance().refreshAsyncTasksActivity(this);
> }
>
>
> @Override
> protected void onPause() {
> super.onPause();
>
> QuadrosMobileApplicationContext.getInstance().clearActivityAsyncTasks();
> }
>
> @Override
> public Object onRetainNonConfigurationInstance() {
>  if(task!=null)
> task.detach();
>
> return(task);
>  }
>
> /**
>  * refresh static references for both progress
>  * info views and set visibility state
>  */
> private void progressRefreshState(int state) {
>  findViewById(R.id.progressView).setVisibility(state);
> }
>
>  /**
>  * do asynctask for background work
>  */
>  public void doAsyncTask(){
> //get task back in case of rotation
> task= (ParentActivityTask)getLastNonConfigurationInstance();
>
> if(task==null){
> task= new ParentActivityTask(this);
> task.execute();
>  //add to the set of tasks
> QuadrosMobileApplicationContext appliContext=
> (QuadrosMobileApplicationContext)getApplicationContext();
>  appliContext.getAsyncTasks().add(task);
> }else{
> task.attach(this);
>  }
> }
>  }
>
> here's the async task as non inner class:
>
> ublic class ActivityTask extends AsyncTask{
>  ParentActivity activity=null;
>
>
> public ActivityTask(QuadrosMobileActivity activity) {
>
> attach(activity);
> }
>
> @Override
>  protected void onPreExecute() {
>
> if(QuadrosMobileActivity.themeId!=R.style.CustomThemeNoHeader){
>
> ParentActivity.findViewById(R.id.progressView).setVisibility(ProgressBar.VISIBLE);
> }
>  QuadrosMobileActivity.progressBarstate=ProgressBar.VISIBLE;
> }
>
> @Override
> protected String doInBackground(Void... params) {
>  return ParentActivity.updateResultsInUi();
> }
>
> @Override
> protected void onPostExecute(String result) {
>  if(activity!=null)
> Toast.makeText(activity, result, Toast.LENGTH_LONG).show();
>  QuadrosMobileApplicationContext appliContext=
> QuadrosMobileApplicationContext.getInstance();
> appliContext.getAsyncTasks().remove(this);
>
> if(appliContext.getAsyncTasks().isEmpty()){
> if(QuadrosMobileActivity.themeId!=R.style.CustomThemeNoHeader){
>
> ParentActivity 
> .findViewById(R.id.progressView).setVisibility(ProgressBar.GONE);
> }
>  QuadrosMobileActivity.progressBarstate=ProgressBar.GONE;
> }
> }
>
> void detach() {
> activity=null;
> }
>
> void attach(ParentActivity activity) {
> this.activity=activity;
>  }
> }
>
>
> On Tue, Oct 4, 2011 at 12:18 AM, TreKing  wrote:
>
>> On Mon, Oct 3, 2011 at 5:28 PM, Studio LFP  wrote:
>>
>>> When this happens, you need to save off the position in your AsyncTask
>>> and restart it back when the activity gets restarted.
>>
>>
>> The OP is using getLastNonConfigurationInstance(), which would indicate
>> he's keeping the same AsyncTask instance acro

Re: [android-developers] Re: runOnUIThread method in doInBackground of Async Task...

2011-10-03 Thread TreKing
2011/10/3 João Rossa 

> public ActivityTask(QuadrosMobileActivity activity) {
>
> attach(activity);
> }
>
> @Override
>  protected String doInBackground(Void... params) {
>  return ParentActivity.updateResultsInUi();
> }
>

You seem to be randomly interchanging instance and static use.
updateResultsInUi() is static?

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: runOnUIThread method in doInBackground of Async Task...

2011-10-04 Thread Bluemercury
The only static variable in use is an int, for maintaining the state of a 
progress bar while switching activities. the updateResultsinUi() is an 
abstract method tha is implemented by sub activties classes.

regards,

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: runOnUIThread method in doInBackground of Async Task...

2011-10-04 Thread TreKing
On Tue, Oct 4, 2011 at 4:14 AM, Bluemercury  wrote:

> The only static variable in use is an int, for maintaining the state of a
> progress bar while switching activities. the updateResultsinUi() is an
> abstract method tha is implemented by sub activties classes.


Um, well, then your code makes no sense to me. From what you posted, you are
using both instance and static methods.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: runOnUIThread method in doInBackground of Async Task...

2011-10-04 Thread João Rossa
I posted the code there..there are no static methods, anyway how do i save
the activity(as in the views that are filled) either on rotation *while and
after *the task is running?

regards,

On Tue, Oct 4, 2011 at 1:47 PM, TreKing  wrote:

> On Tue, Oct 4, 2011 at 4:14 AM, Bluemercury  wrote:
>
>> The only static variable in use is an int, for maintaining the state of a
>> progress bar while switching activities. the updateResultsinUi() is an
>> abstract method tha is implemented by sub activties classes.
>
>
> Um, well, then your code makes no sense to me. From what you posted, you
> are using both instance and static methods.
>
>
> -
> TreKing  - Chicago
> transit tracking app for Android-powered devices
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: runOnUIThread method in doInBackground of Async Task...

2011-10-04 Thread TreKing
2011/10/4 João Rossa 

> I posted the code there..there are no static methods,
>

You have

*public abstract class ParentActivity extends Activity*

Then in your separate AsyncTask class you have:

*@Override*
* protected String doInBackground(Void... params) {*
* *
* return ParentActivity.updateResultsInUi();*
* } *

Maybe I'm missing something but that looks like you're using a static
method.

 anyway how do i save the activity(as in the views that are filled) either
> on rotation *while and after *the task is running?
>

You don't - you re-associate your running AsyncTask with the new Activity
and tell it to refresh the views on that new instance.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: runOnUIThread method in doInBackground of Async Task...

2011-10-04 Thread João Rossa
You're right that was  a mistake while copying the code to here, its
currently like this:

@Override
protected String doInBackground(Void... params) {
 return activity.updateResultsInUi();
}

its the instance of the activity that is pased in the constructor.


On Tue, Oct 4, 2011 at 7:18 PM, TreKing  wrote:

> 2011/10/4 João Rossa 
>
>> I posted the code there..there are no static methods,
>>
>
> You have
>
> *public abstract class ParentActivity extends Activity*
>
> Then in your separate AsyncTask class you have:
>
> *@Override*
> * protected String doInBackground(Void... params) {*
> * *
> * return ParentActivity.updateResultsInUi();*
> * } *
>
> Maybe I'm missing something but that looks like you're using a static
> method.
>
>  anyway how do i save the activity(as in the views that are filled) either
>> on rotation *while and after *the task is running?
>>
>
> You don't - you re-associate your running AsyncTask with the new Activity
> and tell it to refresh the views on that new instance.
>
>
>
> -
> TreKing  - Chicago
> transit tracking app for Android-powered devices
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: runOnUIThread method in doInBackground of Async Task...

2011-10-04 Thread João Rossa
Also is there a problem refreshing the contents inside the
doItinBackground???im using the runOnUIThread to refresh the views inside
the updateResultsInUi()

regarids

2011/10/5 João Rossa 

> You're right that was  a mistake while copying the code to here, its
> currently like this:
>
> @Override
> protected String doInBackground(Void... params) {
>  return activity.updateResultsInUi();
>  }
>
> its the instance of the activity that is pased in the constructor.
>
>
> On Tue, Oct 4, 2011 at 7:18 PM, TreKing  wrote:
>
>> 2011/10/4 João Rossa 
>>
>>> I posted the code there..there are no static methods,
>>>
>>
>> You have
>>
>> *public abstract class ParentActivity extends Activity*
>>
>> Then in your separate AsyncTask class you have:
>>
>> *@Override*
>> * protected String doInBackground(Void... params) {*
>> * *
>> * return ParentActivity.updateResultsInUi();*
>> * } *
>>
>> Maybe I'm missing something but that looks like you're using a static
>> method.
>>
>>  anyway how do i save the activity(as in the views that are filled) either
>>> on rotation *while and after *the task is running?
>>>
>>
>> You don't - you re-associate your running AsyncTask with the new Activity
>> and tell it to refresh the views on that new instance.
>>
>>
>>
>> -
>> TreKing  - Chicago
>> transit tracking app for Android-powered devices
>>
>>  --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to android-developers@googlegroups.com
>> To unsubscribe from this group, send email to
>> android-developers+unsubscr...@googlegroups.com
>> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: runOnUIThread method in doInBackground of Async Task...

2011-10-04 Thread TreKing
2011/10/4 João Rossa 

> Also is there a problem refreshing the contents inside the
> doItinBackground???im using the runOnUIThread to refresh the views inside
> the updateResultsInUi()


That should work.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: runOnUIThread method in doInBackground of Async Task...

2011-10-04 Thread João Rossa
Unfortunately it doesnt seem to be working, at least not when i rotate, i
must be missing something here...still let me test this here.

regards,

On Wed, Oct 5, 2011 at 2:13 AM, TreKing  wrote:

> 2011/10/4 João Rossa 
>
>> Also is there a problem refreshing the contents inside the
>> doItinBackground???im using the runOnUIThread to refresh the views inside
>> the updateResultsInUi()
>
>
> That should work.
>
>
>
> -
> TreKing  - Chicago
> transit tracking app for Android-powered devices
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: runOnUIThread method in doInBackground of Async Task...

2011-10-04 Thread João Rossa
Ok ive put a thread sleep inside the doItInBackground and it seems to
refresh when i rotate while the task is running so the question now is, how
do i save the views states when i rotate after the task completes???it wont
start again because it may not have been gabaged collected...

regards,

2011/10/5 João Rossa 

> Unfortunately it doesnt seem to be working, at least not when i rotate, i
> must be missing something here...still let me test this here.
>
> regards,
>
>
> On Wed, Oct 5, 2011 at 2:13 AM, TreKing  wrote:
>
>> 2011/10/4 João Rossa 
>>
>>> Also is there a problem refreshing the contents inside the
>>> doItinBackground???im using the runOnUIThread to refresh the views inside
>>> the updateResultsInUi()
>>
>>
>> That should work.
>>
>>
>>
>> -
>> TreKing  - Chicago
>> transit tracking app for Android-powered devices
>>
>>  --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to android-developers@googlegroups.com
>> To unsubscribe from this group, send email to
>> android-developers+unsubscr...@googlegroups.com
>> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: runOnUIThread method in doInBackground of Async Task...

2011-10-04 Thread João Rossa
Im returning the current task state in the onRetainNonConfigurationStance
method, but i assume i need to save here the views filler?

regards,

2011/10/5 João Rossa 

> Ok ive put a thread sleep inside the doItInBackground and it seems to
> refresh when i rotate while the task is running so the question now is, how
> do i save the views states when i rotate after the task completes???it wont
> start again because it may not have been gabaged collected...
>
> regards,
>
>
> 2011/10/5 João Rossa 
>
>> Unfortunately it doesnt seem to be working, at least not when i rotate, i
>> must be missing something here...still let me test this here.
>>
>> regards,
>>
>>
>> On Wed, Oct 5, 2011 at 2:13 AM, TreKing  wrote:
>>
>>> 2011/10/4 João Rossa 
>>>
 Also is there a problem refreshing the contents inside the
 doItinBackground???im using the runOnUIThread to refresh the views inside
 the updateResultsInUi()
>>>
>>>
>>> That should work.
>>>
>>>
>>>
>>> -
>>> TreKing  - Chicago
>>> transit tracking app for Android-powered devices
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Android Developers" group.
>>> To post to this group, send email to android-developers@googlegroups.com
>>> To unsubscribe from this group, send email to
>>> android-developers+unsubscr...@googlegroups.com
>>> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: runOnUIThread method in doInBackground of Async Task...

2011-10-06 Thread João Rossa
Ok if put a thread sleep inside the doInBackground method it will work when
changing the screen orientation during the asynctask execution.So how do i
save the filler views when changing the screen orientation after the
asynctask has completed?In the method:

 @Override
public Object onRetainNonConfigurationInstance() {
if(task!=null)
task.detach();
return(task);
}

the task is saved, but how do i save filler views state?

regards,

2011/10/5 João Rossa 

> Im returning the current task state in the onRetainNonConfigurationStance
> method, but i assume i need to save here the views filler?
>
> regards,
>
> 2011/10/5 João Rossa 
>
>> Ok ive put a thread sleep inside the doItInBackground and it seems to
>> refresh when i rotate while the task is running so the question now is, how
>> do i save the views states when i rotate after the task completes???it wont
>> start again because it may not have been gabaged collected...
>>
>> regards,
>>
>>
>> 2011/10/5 João Rossa 
>>
>>> Unfortunately it doesnt seem to be working, at least not when i rotate, i
>>> must be missing something here...still let me test this here.
>>>
>>> regards,
>>>
>>>
>>> On Wed, Oct 5, 2011 at 2:13 AM, TreKing  wrote:
>>>
 2011/10/4 João Rossa 

> Also is there a problem refreshing the contents inside the
> doItinBackground???im using the runOnUIThread to refresh the views inside
> the updateResultsInUi()


 That should work.



 -
 TreKing  - Chicago
 transit tracking app for Android-powered devices

  --
 You received this message because you are subscribed to the Google
 Groups "Android Developers" group.
 To post to this group, send email to
 android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en