Display progress bar while loading - android

I have one button in the main.xml which will link to another xml which include information from server. I include progress bar to avoid the blank screen while the system is loading the information. i already done the code as below but it's still not the things i wanted. the code below will "WAIT" for 1000 ms then only will execute the next code. how can i modify it so that the loading "WAIT TIME" will depends on the internet speed, if internet connection is slow, then the progress-bar-screen will show longer.
package com.android.myApps;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.TextView;
public class MainScr extends Activity {
private final int WAIT_TIME = 1000;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.MainScr);
}
public void onClickCategory(View view)
{
findViewById(R.id.mainSpinner1).setVisibility(View.VISIBLE);
new Handler().postDelayed(new Runnable(){
#Override
public void run() {
Intent mainIntent = new Intent(MainScr.this, Category.class);
MainScr.this.startActivity(mainIntent);
MainScr.this.finish();
}
}, WAIT_TIME);
}
}

The mistake you are doing here is you are dumping specific time into your code
You never know how much it will take to get response.
You should follow following approach
Step 1 Show progress dialog on screen
Step 2 Let download take its own time.But it should be done in new thread
Step 3 Once download is complete it will raise message that task is done,now remove that
progress dialog and proceed.
I am pasting sample code here.Hope it will help you.
package com.android.myApps;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
public class MainScr extends Activity
{
private Handler handler;
private ProgressDialog progress;
private Context context;
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
context = AncActivity.this;
progress = new ProgressDialog(this);
progress.setTitle("Please Wait!!");
progress.setMessage("Wait!!");
progress.setCancelable(false);
progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
handler = new Handler()
{
#Override
public void handleMessage(Message msg)
{
progress.dismiss();
Intent mainIntent = new Intent(context, Category.class);
startActivity(mainIntent);
super.handleMessage(msg);
}
};
progress.show();
new Thread()
{
public void run()
{
// Write Your Downloading logic here
// at the end write this.
handler.sendEmptyMessage(0);
}
}.start();
}
}

Did you try Asyntask? Your doing process will be update in UI.
public final class HttpTask
extends
AsyncTask<String/* Param */, Boolean /* Progress */, String /* Result */> {
private HttpClient mHc = new DefaultHttpClient();
#Override
protected String doInBackground(String... params) {
publishProgress(true);
// Do the usual httpclient thing to get the result
return result;
}
#Override
protected void onProgressUpdate(Boolean... progress) {
// line below coupled with
// getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS)
// before setContentView
// will show the wait animation on the top-right corner
MyActivity.this.setProgressBarIndeterminateVisibility(progress[0]);
}
#Override
protected void onPostExecute(String result) {
publishProgress(false);
// Do something with result in your activity
}
}

Related

Android - Dynamically Create Controls in AsyncTask onPostExecute

I'm working on getting a better handle on AsyncTask and am trying to create controls dynamically with asyncTask's onPostExecute().
The code I have below does work and it creates controls, but is there a way to loop this, but delay it so that variable I is incremented after the asynctask completes?
I've read through using the get() method, but I can't seem to make it work.
Can anyone advise how to either wait till a background task is complete or some other way to dynamically create controls based on a variable number?
package com.example.dynamicallycreatecontrols;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.Log;
import android.view.Menu;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;
public class MainActivity extends Activity {
Integer i = 0;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
while (i < 5) {
new createControl().execute(i);
i++;
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
//asynctask
public class createControl extends AsyncTask<Integer, Void, Button> {
Button btn = new Button(MainActivity.this);
LinearLayout ll = (LinearLayout) findViewById (R.id.llMain);
LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
protected void onPreExecute(Integer i) {
// nothing right now
}
#Override
protected Button doInBackground(Integer... arg0) {
// TODO Auto-generated method stub
// do the calculation
return null;
}
protected void onPostExecute(Button v) {
// build the controls here
btn.setText("Play" + i);
ll.addView(btn, lp);
SystemClock.sleep(1000);
}
}
}
I'm new to android development and java so i'm not sure if I'm just misunderstanding a concept of get() or if there is a better way to do this all together.
Thanks for any time allocated in assistance.
-nick
When doInBackground() done I move to onPostExecute(). I don't need any delays there. When I call task.execute(/**/) actually I invoke doInBackground() async task and I don't care when it finish but I know that I have callback onPostExecute() and I wait and update my main Thread from there.
To make it clearer lets say you have application where user wants to register to server and update GUI led to green color. User presses on button and calls method registerClient()
This method runs:
private void registerClient(){
...
dialog = ProgressDialog.show(LoginActivity.this, "", "Connecting. Please wait...", true);
HeavyTask task = new HeavyTask();
task.execute(user, password, domain);
}
So what we have in HeavyTask:
private class HeavyTask extends AsyncTask<String, Void, Void> {
private String username = "";
private String domain = "";
private String password = "";
// run async task
protected Void doInBackground(String... args) {
username = args[0];
password = args[1];
domain = args[2];
registerClientToServer(username, password, domain, null);
return null;
}
protected void onPostExecute(Void results) {
mHandler.postDelayed(new Runnable() {
#Override
public void run() {
updateGUI(username, domain);
}
}, 500);
}
}
Why not create an object and instantiate it? You can control if the object exists or if it already finished what he had to do.
Example:
public class MainActivity extends Activity {
private createControl cc = null;
Integer i = 0;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
while (i < 5) {
if (cc == null){
cc = new createControl();
cc.execute(i);
i++;
}
}
}
...
}
Then in onPostExecute just add cc = null;

Using AsynTask to show progress bar while attempting to SSH to Server

First of all, i have to state that i am new to Java in general & Android. I do however have the basics, or at least getting there.
The Purpose of my Application: At the company, we have a Remote server that we SSH to, and do some work. At some times, the server is unreachable and therefore disrupts our work.
My application is suppose to do the following:
1- Using Jsch, i SSH to the server, if there is a response, then, i will attempt again in 15 minutes, if there is no response, i want to notify.
i have successfully done the above in non android version of Java, and was able to do it in Android version, however on the main thread, thus i cannot update anything on the UI. In essence the Progress Bar..
In the regular version, the UI freezes, and in the AsyncTask version provided below. i get an exception as soon as i hit the button
Below is the code i am using, to be honest, i read all over that the best solution is AsyncTask, but since i am new to that, i am not sure were my wrong is. I honestly assume its may be in the AsyncTask and AsyncTask .
I am not sure what to use there...
Below is my code, hopefully someone can point out my mistake.
package com.example.myapp;
import java.io.IOException;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.HandlerThread;
import android.os.StrictMode;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Toast;
import android.os.Handler;
public class VedasServerMonitorActivity extends Activity {
/** Called when the activity is first created. */
Button button;
EditText IP;
EditText UserName;
EditText Password;
EditText Port;
ProgressBar progressBar1;
String UserStr;
String PassStr;
String IPStr;
int PortInt;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button = (Button) findViewById(R.id.button1);
IP = (EditText) findViewById(R.id.serverIp);
UserName = (EditText) findViewById(R.id.userName);
Password = (EditText) findViewById(R.id.password);
Port = (EditText) findViewById(R.id.port);
progressBar1 = (ProgressBar) findViewById(R.id.progressBar1);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
new asyncTaskUpdateProgress().execute();
}
});
}
public class asyncTaskUpdateProgress extends AsyncTask<Void, Void, Void> {
#Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
}
#Override
protected void onPreExecute() {
// TODO Auto-generated method stub
progressBar1.setVisibility(View.VISIBLE);
UserStr = UserName.getText().toString();
PassStr = Password.getText().toString();
IPStr = IP.getText().toString();
PortInt = Integer.parseInt(Port.getText().toString());
button.setClickable(true);
progressBar1.setVisibility(View.INVISIBLE);
}
#Override
protected void onProgressUpdate(Void... values) {
// TODO Auto-generated method stub
progressBar1.setVisibility(View.INVISIBLE);
}
#Override
protected Void doInBackground(Void... arg0) {
boolean ok = false;
try {
SSHTest sshtest = new SSHTest();
ok = sshtest.sshconnect(UserStr, PassStr, IPStr, PortInt);
}
catch (Exception e) {
e.printStackTrace();
Log.i("ERROR HERE", "doInBackground: IOException");}
if (ok) {
Toast.makeText(getApplicationContext(),
"Connection Susccessfull", Toast.LENGTH_LONG)
.show();
} else {
Toast.makeText(getApplicationContext(),
"Unable to connect", Toast.LENGTH_LONG).show();
notify(getApplicationContext(), true);
}
return null;
}
protected void notify(Context context, Boolean on) {
NotificationManager nm = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
ComponentName comp = new ComponentName(context.getPackageName(),
getClass().getName());
Intent intent = new Intent().setComponent(comp);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
intent, Intent.FLAG_ACTIVITY_NEW_TASK);
Notification n = new Notification(R.drawable.warning, "Message",
System.currentTimeMillis());
n.setLatestEventInfo(context, "Vedas Server Monitor",
"Port Un-rechable", pendingIntent);
nm.notify(22, n);
}
}
}
android× 194760
There are some correction that you need to make in the doInBackground(). But before that a small detailing about the AsyncTask.
AsyncTask is used when you have any non-UI back ground activity to perform. The function onPreExecute() is used to show any UI action
(in most cases its showing of a dialog) before you enter the background thread. The function doInBackground() is used to perform the non-ui action (in most cases fetching data from server). While doing the background activity in doInBackground() you may wish to show some progress which you do by using publishProgress() which will internally call the onProgressUpdate() method. On completion of the background activity in doInBackground() you return the result of the activity, if you have any. After you return from the doInBackground() method internally there is call made to the onPostExecute() which will receive the result you have returned in doInBackground() as a parameter. Now onPostExecute() will run on a UI thread and most of the UI action like dismissing of dialog which was shown in onPreExecute(), displaying the result on some UI component etc. happens in this method.
Now to the mistake you are doing in you code:
You are showing a toast or a notification based on the result of your server data fetch using a function notify but you are still in the background non-ui thread. Now this result should ideally be returned and checked in the onPostExecute() and based on its value you can show the UI component of toastor notification.
I hope this explanation helps you in solving your problem.
EDIT
In your case since you can send the boolean type result variable ok to onPostExecute(). For that you need to make the following changes:
in class declaration:
public class asyncTaskUpdateProgress extends AsyncTask<Void, Void, Boolean>
and
protected void onPostExecute(Boolean result){
if (ok) {
Toast.makeText(getApplicationContext(),
"Connection Susccessfull", Toast.LENGTH_LONG)
.show();
} else {
Toast.makeText(getApplicationContext(),
"Unable to connect", Toast.LENGTH_LONG).show();
notify(getApplicationContext(), true);
}
}
and finally in
protected Void doInBackground(Void... arg0) {
boolean ok = false;
try {
SSHTest sshtest = new SSHTest();
ok = sshtest.sshconnect(UserStr, PassStr, IPStr, PortInt);
}
catch (Exception e) {
e.printStackTrace();
Log.i("ERROR HERE", "doInBackground: IOException");}
return ok;
}
You can try this
in your protected void onPreExecute() need to add
progressBar = new ProgressDialog(v.getContext());
progressBar.setCancelable(true);
progressBar.setMessage("File downloading ...");
progressBar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressBar.setProgress(0);
progressBar.setMax(100);
progressBar.show();
//reset progress bar status
progressBarStatus = 0;
then
protected void onProgressUpdate(Void... values) {
progressBarStatus= progressBarStatus + x; // x means any value
progressBar.setProgress(progressBarStatus);
}
after that you need to finish your progressBar in onPostExecute(). like
protected void onPostExecute(Void result) {
progressBar.dismiss();
}

Multithread management in view?

I have 3 button and 3 textview.When i press first button i want to see 10 sec later which is writing in the first textview.i press second button i want to see someting 5 sec later which is writing in the second textview .i press third button,i want to see textview which is writing immediately.
My question how can i work all multithread in the view without lock other view? I tried ASCYNTask but it doestn work.
Can anybody give me any suggestion?
My Activity:
package com.example;
import android.app.Activity;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MyActivity extends Activity
{
Button a,b,c;
TextView ta,tb,tc;
Ascyn ascyn,ascyn2,ascyn3;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
a=(Button)findViewById(R.id.ba);
b=(Button)findViewById(R.id.bb);
c=(Button)findViewById(R.id.bc);
ta=(TextView)findViewById(R.id.ta);
tb=(TextView)findViewById(R.id.tb);
tc=(TextView)findViewById(R.id.tc);
ascyn=new Ascyn(this);
ascyn2=new Ascyn(this);
ascyn3=new Ascyn(this);
a.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
ascyn.execute();
SystemClock.sleep(5000);
ta.setText("ok");
}
});
b.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
ascyn2.execute();
SystemClock.sleep(1000);
tb.setText("ozaman");
}
});
c.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
ascyn3.execute();
tc.setText("byby");}
});
}
}
Ascyn:
package com.example;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
/**
* Created by IntelliJ IDEA.
* User: duygukahraman
* Date: 20.02.2012
* Time: 15:44
* To change this template use File | Settings | File Templates.
*/
public class Ascyn extends AsyncTask<Void,String,Void> {
private Context ctx;
ProgressDialog dialog;
public Ascyn(Context context){
ctx=context;
dialog=new ProgressDialog(ctx);
}
#Override
protected void onPreExecute() {
// dialog.setTitle("Please wait");
// dialog.show();
}
#Override
protected Void doInBackground(Void... unused) {
// SystemClock.sleep(20000);
return (null);
}
#Override
protected void onPostExecute(Void unused) {
dialog.dismiss();
}
}
You have to create separate Async class for each thread like.
public class AscynThread1 extends AsyncTask<Void,String,Void> { // }
public class AscynThread2 extends AsyncTask<Void,String,Void> { // }
public class AscynThread3 extends AsyncTask<Void,String,Void> { // }
You don't need threads, if you simply want to write some text in a textview. Use a handler instead.
Handler handler = new Handler();
public void method() {
handler.postDelayed(new Runnable() {
public void run() {
textView.setText("Your text");
}
}, 5000);
}

Changing Text Alignment in ProgressDialog

I have problem that how to change text inside the progressdialog (basically having STYLE_HORIZONTAL as in figure) (Using Android 1.6)
to text shown in figure.
Please help out in this case.
My code about the progressdialog refers like this:-
mProgressDialog = new ProgressDialog(PDFActivity.this);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgressDialog.setTitle(R.string.msgDownloadingWait);
mProgressDialog.setMessage(getResources().getString(
R.string.msgDownloading));
// User is not allowed to cancel the download operation.
mProgressDialog.setCancelable(false);
mProgressDialog.setMax(serverFileCount);
mProgressDialog.show();
Thanks in advance.
I got the answer related to this stuff some days back(but updating it today as got some free time).
Here the code that I have used for making this stuff best.I achieved above thing by Custom Dialog.Firstly here the code of activity from which I called the class of Custom Dialog.
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.widget.ProgressBar;
import android.widget.TextView;
public class ProgressThread extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MyDialog dialog = new MyDialog(this);
dialog.show();
}
}
Now the code related to the Custom Dialog. Here I have used ProgressBar & TextViews in CustomDialog & made calculations on basis on download which in turn updates TextViews.The example used here updates the textviews & progressbar in dummy manner.You change that as per your need.
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.os.Handler;
import android.os.Message;
import android.widget.ProgressBar;
import android.widget.TextView;
public class MyDialog extends Dialog {
public static final int STATUS_UPDATE = 101;
public static final int STATUS_COMPLETE = 100;
ProgressBar progressBar;
TextView textView;
TextView percent;
int increment;
int progress;
public MyDialog(Context context) {
super(context);
setContentView(R.layout.progressbar);
setDialog();
}
private void setDialog() {
setTitle("Downloading Files....");
textView = (TextView) findViewById(R.id.textProgress);
progressBar = (ProgressBar) findViewById(R.id.progress_horizontal);
percent = (TextView) findViewById(R.id.textPercentage);
percent.setTextColor(Color.WHITE);
textView.setTextColor(Color.WHITE);
progressBar.setProgressDrawable(getContext().getResources()
.getDrawable(R.drawable.my_progress));
progressBar.setIndeterminate(false);
// set the maximum value
progressBar.setMax(1315);
launcherThread();
}
private void launcherThread() {
LoaderThread loaderThread = new LoaderThread();
loaderThread.start();
LauncherThread launcherThread = new LauncherThread();
launcherThread.start();
}
private class LoaderThread extends Thread {
#Override
public void run() {
try {
while (progressBar.getProgress() < progressBar.getMax()) {
// wait 500ms between each update
Thread.sleep(100);
increment++;
// active the update handler
progressHandler.sendEmptyMessage(STATUS_UPDATE);
}
progressHandler.sendEmptyMessage(STATUS_COMPLETE);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
// handler for the background updating
Handler progressHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case STATUS_UPDATE:
progressBar.setProgress(increment);
float value = increment / 1315F;
percent.setText(" " + ((int) (value * 100)) + "%");
System.out.println(value * 100);
textView.setText(String.valueOf(progressBar.getProgress())
.concat(" / " + progressBar.getMax()));
break;
case STATUS_COMPLETE:
dismiss();
}
}
};
private class LauncherThread extends Thread {
#Override
public void run() {
progressHandler.sendMessage(progressHandler.obtainMessage());
progressHandler.sendEmptyMessage(0);
}
}
}

Showing ProgressDialog while a Service is being started

I'm having serious problems when showing a ProgressDialog while a service is getting ready... The service takes time to get ready as it's a bit heavy, so I want to show the ProgressDialog meanwhile it's started.
The thing is that it shows the ProgressDialog right before the next activity starts... I really don't find what it is...
package org.pfc;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
public class ConnectActivity extends Activity {
// FIELDS------------------------------------------------------------------
protected LocalService mSmeppService;
private ProgressDialog progressDialog;
private Thread tt;
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
// Gets the object to interact with the service
mSmeppService = ((LocalService.LocalBinder) service).getService();
}
public void onServiceDisconnected(ComponentName className) {
// This is called when the connection with the service has been
// unexpectedly disconnected -- that is, its process crashed.
// Because it is running in our same process, we should never
// see this happen.
mSmeppService = null;
}
};
// For getting confirmation from the service
private BroadcastReceiver serviceReceiver = new BroadcastReceiver() {
#Override
public void onReceive(Context context, Intent intent) {
Log.i(TAG, "receiver onReceive...");
if (progressDialog.isShowing())
progressDialog.dismiss();
// Change activity
Intent groupsActivityIntent = new Intent(ConnectActivity.this,
GroupsActivity.class);
startActivity(groupsActivityIntent);
}
};
// METHODS ----------------------------------------------------------------
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (LocalService.isRunning) {
// TODO start ListActivity
Log.i(TAG, "Starting GroupsScreen");
Intent i = new Intent(ConnectActivity.this, GroupsActivity.class);
startActivity(i);
} else {
setContentView(R.layout.connect_screen);
// Add listener to the button
Button buttonConnect = (Button) findViewById(R.id.button_connect);
buttonConnect.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
processThread();
}
});
}
}
// PRIVATE METHODS --------------------------------------------------------
private void processThread() {
progressDialog = ProgressDialog.show(ConnectActivity.this, "",
"Loading. Please wait...", true, false);
tt = new Thread() {
public void run() {
// Register broadcastReceiver to know when the service finished
// its creation
ConnectActivity.this.registerReceiver(serviceReceiver,
new IntentFilter(Intent.ACTION_VIEW));
// Starts the service
startService(new Intent(ConnectActivity.this,
LocalService.class));
Log.i(TAG, "Receiver registered...");
}
};
tt.start();
}
}
The service executes by the end of the onStart method this:
// Send broadcast so activities take it
Intent i = new Intent(Intent.ACTION_VIEW);
sendOrderedBroadcast(i, null);
So the onReceive method runs and we go to the next activity
The problem is that you are not running ProgressDialog in a UI thread.
Add a handler that will handle messages in your UI thread.
private static final int UPDATE_STARTED = 0;
private static final int UPDATE_FINISHED = 1;
private Handler handler = new Handler(){
#Override public void handleMessage(Message msg) {
switch (msg.what) {
case UPDATE_STARTED:
progressDialog = ProgressDialog.show(ConnectActivity.this, "",
"Loading. Please wait...", true, false);
break;
case UPDATE_FINISHED:
if(progressDialog.isShowing()){
progressDialog.dismiss();
}
break;
}
}
};
private void processThread() {
Message m = new Message();
m.what = UPDATE_STARTED;
handler.sendMessage(m);
//Your working code
m = new Message();
m.what = UPDATE_FINISHED;
handler.sendMessage(m);
}
good luck!

Categories

Resources