Android :: Process Dialog For Long Operation - Thread Object

May 29, 2010

In the code showed as below I create a process dialog for doing some long
operation (in this case waiting 4 seconds). It runs as it should. And shows the "Starting" and "Done" message but when it finishes and I click Button1 again it terminates.

public class main extends Activity { public ProgressDialog dialog = null;
final Handler handler = new Handler(){ public void handleMessage(Message msg){
dialog.dismiss(); TextView tv2 = (TextView) findViewById(R.id.TextView02);
tv2.setText("Done"); } };
Thread runlongjob = new Thread(){ public void run(){
SystemClock.sleep(4000); handler.sendEmptyMessage(0);
} };
/** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.main);
} public void clickhandler(View v){ switch(v.getId()){
case (R.id.Button01): TextView tv1 = (TextView) findViewById(R.id.TextView01);
tv1.setText("Starting...");
dialog = ProgressDialog.show(main.this, "Please wait", "Doing Job...",
true); runlongjob.start(); break; } }

Android :: Process Dialog For Long Operation - Thread Object


Android :: MemoryFile Object From Other Process?

Apr 1, 2009

I have created a MemoryFile object in my client application, and how can I get it in my server application? The object is large enough that I can't tranfer it by Intent or aidl interface.

View 2 Replies View Related

Android :: How Can I Pass A Context Object To A Thread On Call?

May 12, 2010

I have this code fragment: Code...

View 3 Replies View Related

Android :: Is There Only 1 Main UI Thread Per App Process?

Jul 21, 2010

Are the UI threads for each Activity and Service in an app separate threads, or is there actually 1 underlying UI thread per app that processes the UI message queue for each Activity and Service?

View 2 Replies View Related

Android :: How To Update View Object On Main Thread By Background?

Mar 3, 2009

My purpose is very simple : each 1second, I want to redraw an object on different place on background. I do not know where my error on this code below. Here is my code:
public class My_View extends View{ private Bitmap mBackground_img;
private Drawable mMoveObject; private int mObjectw,mObjecth; private int Dx,Dy;
private Handler myHandler = new Handler(); private long lasttime;
public My_View(Context context,AttributeSet ats,int ds) {
super(context,ats,ds); init(context);
} public My_View(Context context,AttributeSet ats) { super(context,ats);
init(context); } public My_View(Context context) { super(context);
init(context); } public void change() { invalidate();
} private void init(Context context) {
Resources res = context.getResources();
mMoveObject = res.getDrawable (R.drawable.lander_firing);
mBackground_img = BitmapFactory.decodeResource(res, R.drawable.my_pic);
mObjectw = mMoveObject.getIntrinsicWidth();
mObjecth = mMoveObject.getIntrinsicHeight();
Dx = Dy = 0; lasttime = System.currentTimeMillis() + 1000;
Thread mthread = new Thread(null,doBackground,"Background");
mthread.start(); } private Runnable doBackground = new Runnable() {
public void run() { long now = System.currentTimeMillis();
if(lasttime < now ) { Dx = Dx + 10; Dy = Dy + 10;
lasttime = now + 1000; myHandler.post(change_view);
} } }; private Runnable change_view = new Runnable() {
public void run() { change();
} };
@Override public void onDraw(Canvas canvas) {
canvas.drawBitmap(mBackground_img,0 ,0 , null);
mMoveObject.setBounds(Dx, Dy, Dx+mObjectw, Dy+mObjecth);
mMoveObject.draw(canvas);
} }

View 7 Replies View Related

Android :: Progress Dialog With A Second Thread

Sep 26, 2009

I've created ProgressDialog with a second thread according to the DevGuide,changes screen orientation or 2) hits the back button twice (first to hide the dialog, second to hide the app) to hide the application and run the app again after a while.Then, onCreate() is called (for the second time), and progress bar stops responding properly. My thread may work for a few minutes and I want to give the user possibility to hide it and do sth else. After a while he might want to run the app again in order to check the progress.I found a few articles concerning this topic, but I couldn't find the exact solution I should chose for this problem. So, could you tell mi what is the proper way to handle this? Should i save the handler and dialog state with "onRetainNonConfigurationInstance()"? If so, how to do it properly and is it safe?

View 11 Replies View Related

Android :: Show A Dialog In Thread.run()?

Sep 21, 2009

How to show a dialog in thread.run() .My code...

View 4 Replies View Related

Android :: Button Inside List Item - How To Process Long Presses?

Jul 20, 2010

I got a ListView item that contains a button inside. Currently the long press of a ListView item does not get processed. I thought that by setting the Button.setLongClickable(false) would allow the long press to be passed along to the ListView item and it's not happening.

View 5 Replies View Related

Android :: Progress Dialog And Thread Error

Apr 15, 2010

i had made an application which download a huge list from the internet and display in a listview. The Listview class is supported by my own Class which is extension of the BaseAdapter base class. In the display list adapter getView method I use simple_list_item_multiple_choice. When I would like to insert an progress dialog with a Thread, the System is die with NullPointer Exception in the last row: *public View getView(int position, View convertView, ViewGroup parent) {if(convertView == null) convertView =inflater. inflate (android .R. layout.simpl e_list_item_multiple_choice, parent,false); try {ViewHolder vh = new ViewHolder(); vh.check TextView = (Checked TextView) convertView.findViewById(android.R.id.text1); vh. check TextView. setEnabled (true);* BUT if I don't use the Thread all going to right, there will no NullPointer Exception Can anyone tell me why ? Any solution?

View 2 Replies View Related

Android :: 2.2 Progress Dialog Freezing In Second Thread

Oct 17, 2010

I have recently experimented with creating an easy way to open a ProgressDialog up in a second thread, so if the main thread freezes the dialog will keep working. Here is the class: public class ProgressDialogThread extends Thread
public Looper ThreadLooper;
public Handler mHandler;public ProgressDialog ThreadDialog;
public Context DialogContext;
public String DialogTitle;
public String DialogMessage;
public ProgressDialogThread(Context mContext, String mTitle, String mMessage)
{ DialogContext = mContext;
DialogTitle = mTitle;
DialogMessage = mMessage;
} public void run()
{ Looper.prepare();
ThreadLooper = Looper.myLooper();
ThreadDialog = new ProgressDialog(DialogContext);
ThreadDialog.setTitle(DialogTitle);
ThreadDialog.setMessage(DialogMessage);
ThreadDialog.show();
mHandler = new Handler();
Looper.loop();
} public void Update(final String mTitle, final String mMessage)
{ while(mHandler == null)
synchronized(this) {
try { wait(10); }
catch (InterruptedException e) {
Log.d("Exception(ProgressDialogThread.Update)", e.getMessage() == null ? "MISSING MESSAGE" : e.getMessage());
mHandler.post(new Runnable(){
@Override
public void run() {
ThreadDialog.setTitle(mTitle);
ThreadDialog.setMessage(mMessage);
public void Dismiss()
{ while(ThreadDialog == null || mHandler == null)
synchronized(this) {
try { wait(10); }
catch (InterruptedException e) {
Log.d("Exception(ProgressDialogThread.Dismiss)", e.getMessage() == null ? "MISSING MESSAGE" : e.getMessage());
mHandler.post(new Runnable(){
@Override
public void run() {
ThreadDialog.dismiss();
public void Continue()
{ while(ThreadLooper == null || mHandler == null)
synchronized(this) {
try { wait(10); }
catch (InterruptedException e) {
Log.d("Exception(ProgressDialogThread.Continue)", e.getMessage() == null ? "MISSING MESSAGE" : e.getMessage());
mHandler.post(new Runnable(){
@Override
public void run() {
ThreadLooper.quit();
However it sometimes work perfectly but other times the application simply freezes and crashes eventually.Here is an example of use:ProgressDialogThread thread = new ProgressDialogThread(this, "Loading", "Please wait...");
thread.start();
// Do Stuff
thread.Dismiss();
thread.Continue();It generates a lot of warning and even some crashes sometimes: eg. Handler: Sending message to dead thread.and exceptions like ANR

View 1 Replies View Related

Android :: Progress Dialog Working In Thread

Jul 27, 2010

Trouble is, that ProgressDialog show only after loading run(), but I need to show it on start and showing it while loading some data. I put: "dialog = ProgressDialog.show(CategoriesListActivity.this,"Working...","Loading data", true);" in method run(), but the same. I print in Log.i() some info (int i++) and put title of ProgressDialog. Method work correctly, but don't show ProgressDialog. I have read some info that some thread block another thread (my created), that's why doesn't show progressDialog, but can't do anything.

View 2 Replies View Related

Android :: PopUp Dialog From Background Thread

Jun 22, 2009

I need to popup dialog to be showed when i get a message from differnt thread but the dialog should be not dependent on Activity i.e, it should display the dialog wherever the screen focus is .can it be done ..because the dialog is handled per Activity ,i thought of using service but again it would be one more thread added so want to avoid that.

View 2 Replies View Related

Android :: Resulting Thread Id Scoped Per Process / Current Activity / Service?

Jul 21, 2010

When you do a Thread.currentThread().getId(), is the resulting thread id scoped per process or scoped to the current Activity/Service?

View 1 Replies View Related

Android :: User Thread To Update UI But Dialog Still Come After Task

Jul 31, 2010

I'm trying to learn AsyncTask and Thread but Thread first. I am trying to display a Dialog before "DoSomeTask()" but seems like the Dialog always come after DoSomeTask(). Did I do something wrong here?

--- code---
@Override public void onClick(View v) {
// TODO Auto-generated method stub mainProcessing();
DoSomeTask(); } private void mainProcessing() {
Thread thread = new Thread(null, doBackgroundThreadProcessing, "Background");
thread.start(); }
private Runnable doBackgroundThreadProcessing = new Runnable() {
public void run() { backgroundThreadProcessing();
} };
private void backgroundThreadProcessing() {
handler.post(doUpdateGUI);
} private Runnable doUpdateGUI = new Runnable() {
public void run() { updateGUI();
} };
private void updateGUI() {
final ProgressDialog dialog = new ProgressDialog(CloseVault.this);
dialog.setMessage("Please wait...");
dialog.show();
}

View 5 Replies View Related

Android :: Progress Dialog Thread Stops When Closing G1

Mar 6, 2009

have a Progress Dialog in an extra Thread running. Normally the user will have the keyboard open, because something is to insert! So when the Progress Dialog appears and the user close the keyboard, the dialog dissappears and the application crashes. In the debugger i saw the exception "View not attached to window manager". May because the Dialog is not longer shown but the application want to remove it after the calculation? Here is the code where i start the dialog and the thread:Does somebody know how to solve this?

View 6 Replies View Related

Android :: Displaying Progress Dialog From Open GL Thread

May 9, 2010

Does anyone have expirience with opengl-ui-opengl threading interraction? I'am developing a small opengl application. I'am a little bit confused with separate opengl thread. Currently, my application is logically separated in two parts - the controlling one and the rendering one. The controlling part interracts with user - accepting user input, changing activities, dealing with files and so on. The rendering part - just render everything it should. Ok, so when I need to load new texture to opengl (unfortunatelly its large and I cant reduce its size), I'd like to show a ProgerssDialog dialog. Trying to show it from the open gl thread brings me an exception: "Can't create handler inside thread that has not called Looper.prepare()". Because the initiator of loading is in the ui thread (for example - user selected a menu option), I'am opening the dialog, adding the load Runnable to stack on Runnables that will be called in Render.onDrawFrame and passing there a callback that will be executed after texture is loaded.

View 2 Replies View Related

Android :: How To Intent A Dialog When The Thread.run() Finish Running

Aug 11, 2010

I'm develop a download manager function which the dialog will popup when the the item was finished download. the download function was running at background.

My question is how can I know when the downloading was finished and the project is intent other activity?

For example:

CODE:............

The above method where should I put? i try put it at onResume(), onStart() in every activity which will open by user. but unlucky it won't work.

View 1 Replies View Related

Android :: Update Text When Dialog Open And Dismissed In Thread

Aug 18, 2010

Look at my code.
- code -
private Handler handler = new Handler(); private ProgressDialog dialog;
final Runnable runInUIThread = new Runnable() { public void run() { dialog.dismiss();
} };
private void DoThis() {
dialog = new ProgressDialog(Main.this); dialog.setTitle("Title");
dialog.setMessage("Text"); dialog.show();
Thread newTask = new Thread() {
@Override public void run() { Looper.prepare(); DoThat();
handler.post(runInUIThread); Looper.loop();
); newTask.start(); } }

Is it possible to use test.setText("something") in this thread to update a Button text or TextView in the LinearLayout after the dialog is dismissed? I try cheating placing:
test.setVisibility(View.INVISIBLE);
test.setText("something");
test.setVisibility(View.VISIBLE);
after dialog.show();
It kind of updated the text when the dialog open. I want to do it after the dialog was dismissed. What is the correct way to implement this in my thread?

View 3 Replies View Related

Android :: Find Table Leyout In Thread (Because Of Progress Dialog)

Jun 5, 2010

On my activity, im getting some big data from web, and while getting this data i want to show the user a ProgressDialog with spinning wheel. That i can do only with putting this code into a thread, right? the problem is that after im getting this data i need to insert it into my tableLayout as TableRows and it seems impossible to access the TableLayout from the thread. What can i do to show this progress dialog and to be able access the table layout from the thread ? is there any event that happens on the end of the thread ?
My code fails for : _tableLayout.addView(_tableRowVar, new TableLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));My full code is : final ProgressDialog dialog = ProgressDialog.show(MyActivity.this, "","Getting data.

View 1 Replies View Related

Android :: Dialog Activity To Return Before Continuing Executing Of Main Thread

May 22, 2010

How would I force the current thread to wait until another has finished before continuing. In my program the user selects a MODE from an AlertDialog, I want to halt executing of the program before continuing as the mode holds important configuration for the gameplay.

new AlertDialog.Builder(this)
.setItems(R.array.game_modes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case 0:
setMode(TRAINING_MODE);
case 1:
setMode(QUIZ_MODE);
default:
setMode(TRAINING_MODE);
break; ............
//continue loading the rest of onCreate();
contineOnCreate(); } })
.create().show();

If this is impossible can anyone give a possible solution?

View 1 Replies View Related

Sprint HTC Hero :: Message Thread So Long It Creates Lag

Dec 19, 2009

My text thread with my girlfriend is over 4000 messages long, causing significantly noticeable lag-time. I've tried to delete the entire thread with her, but it just freezes up the program and I have to force quit it, and it won't delete the thread. Is there any way to erase all text messages at once, preferably from outside the program?

View 35 Replies View Related

Android :: ASync Task Progress Dialog Not Showing Until Background Thread Finishes

Apr 24, 2010

I've got an Android activity which grabs an RSS feed from a URL, and uses the SAX parser to stick each item from the XML into an array. This all works fine but, as expected, takes a bit of time, so I want to use AsyncActivity to do it in the background. The line items = parser.getItems() works fine - items being the arraylist containing each item from the XML. The problem I'm facing is that on starting the activity, the ProgressDialog which i create in onPreExecute() isn't displayed until after the doInBackground() method has finished. i.e. I get a black screen, a long pause, then a completely populated list with the items in. Why is this happening? Why isn't the UI drawing, the ProgressDialog showing, the parser getting the items and incrementally adding them to the list, then the ProgressDialog dismissing?

View 3 Replies View Related

Android :: How To Handle Screen Orientation Change / When Progress Dialog And Background Thread Active?

Jul 10, 2009

My program does some network activity in a background thread. Before starting, it pops up a progress dialog. The dialog is dismissed on the handler.This all works fine, except when screen orientation changes while the dialog is up (and the background thread is going). At this point the app either crashes, or deadlocks, or gets into a weird stage where the app does not work at all until all the threads have been killed.How can I handle the screen orientation change gracefully?

View 9 Replies View Related

Android :: How Can I Get Current Activity Object In Instrumentation Object?

Sep 9, 2009

I want to do some automated testcase with Instrumentation . Suggest that my AUT has 2 Activity. After clicking the button in ther first Activity, the second one will be shown with new content base on what we enter in the first Activity.) Instrumentation provides us the function called startActivitySync() and return the Activity object for processing. My question is how we can get the pointer of the second Activity after the it is shown by clicking the button on the first activity.?

View 2 Replies View Related

Android :: Cast Picture Object To Bitmap Object

Jun 8, 2009

I would like to convert a Picture object to Bitmap object in memory, without writing data to disk.

View 2 Replies View Related

Android : Get Activity Object From Intent Object

Sep 21, 2009

I have an Activity that running on system. I can get the Intent that is used to start the activity. But i don't know how to get the Activity object from the Intent object or something else. Can anyone tell me how to do this??? Note that, I don't use Instrumentation object.

View 11 Replies View Related

Android :: DDMS Not Listing Process - Via Command Line To Attach Process To Debug

May 21, 2010

Sometimes the DDMS in the Eclipse not listing the process.

To do the debug in this condition,

1) Is their any way force the DDMS to list the process?

2) Any command to attach the process from the command line?

View 2 Replies View Related

Android :: Remote Service Process Persists - I.e. Won't Disappear From Process Table

Feb 21, 2009

At a certain point in my program, when I'm completely done with my service, my activity executes unbindService() and stopService() -- yet the process persists. I can tell that it persists because I run "ps" in "adb -e shell":

CODE:.............

"adb logcat", I can show you the sequence of events:

ACTIVITY: context.unbindService(serviceConnection);

SERVICE: onUnbind();

ACTIVITY: stopService(serviceIntent); & returns true!

SERVICE: onDestroy();

First, my activity calls unbindService(serviceConnection). According to the documentation, unbindService() will "Disconnect from an application service. You will no longer receive calls as the service is restarted, and the service is now allowed to stop at any time." So that is fine, and it is happening.

Appropriately, we see the onUnbind() call happen on the service side. According to the documentation, onUnbind() is called when "all clients have disconnected from a particular interface published by the service." So this confirms the correct service connection is being passed, and that the service is responding accordingly.

Next, my activity calls stopService(serviceIntent), and returns true. According to the documentation, stopService() does the following: "If there is a service matching the given Intent that is already running, then it is stopped and true is returned; else false is returned." Again, this is happening and returning true.

In response, the service's onDestroy() method is called. According to the documentation, onDestroy() is "Called by the system to notify a Service that it is no longer used and is being removed. The service should clean up any resources it holds (threads, registered receivers, etc) at this point. Upon return, there will be no more calls in to this Service object and it is effectively dead."

At this point I expect the process to disappear from the process table. Yet it remains indefinitely. But why?

Also, the process is so persistent that I can bind to it again, and I see that it is the same exact process responding because the PID (process ID) is the same!

View 4 Replies View Related

LG Ally :: Process' Won't Open - Pop-up - The Process Com.android Phone Has Stopped Unexpectedly

Nov 24, 2010

So, I decided to give Tridents ROM a try about 10-minutes ago.

I used ROM Manager, backed-up my old ROM, then downloaded Velocity 0.2.

Now, my phone will do nothing, it turns on and shows the red Droid eye, then when it's time to go to the home screen I get pop-up after pop-up saying that "The process com.android.phone has stopped unexpectedly. Please try again."

I have no way of getting on my phone at all, what can I do?

View 11 Replies View Related

Motorola Droid :: Update App - Message Process Android Media Process Stopped Unexpectedly

Nov 12, 2010

I Just installed a new theme (Live Wire) for my Lithium Mod Rom. Don't know if there is a connection, but when I need to update an app, I get the message something like "process android media process stopped unexpectedly" and it will not allow the update. Everything else works well. I have turned it off for awhile, and have done a battery pull.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved