Let a app sleep or wait

Put your problem here if it does not fit any of the other categories.

Let a app sleep or wait

Postby Quelle » Mon Sep 06, 2010 2:37 pm

Hi Guys,

how can i let sleep or wait my application correct?

I tried a couple of things but nothing worked fine.

My last Idea was like this:

Code: Select all
//         //TODO: just a test
//             Object obj = new Object();
//
//             synchronized (obj) {
//              for(int i=0; i<5; i++){
//               try {
//               Log.i(TAG, "waiting object");
//                 obj.wait(10000);
//               }
//               catch (InterruptedException e) {
//                 // Ignore
//               }
//             }
Quelle
Developer
Developer
 
Posts: 34
Joined: Thu Mar 11, 2010 10:53 am

Top

Re: Let a app sleep or wait

Postby Quelle » Mon Sep 06, 2010 3:16 pm

09-06 16:07:39.191: WARN/ActivityManager(2247): Timeout executing service: ServiceRecord{4852f570 de.finder.anfinder/.AnChecker}
09-06 16:07:39.193: INFO/Process(2247): Sending signal. PID: 2832 SIG: 9
09-06 16:07:39.231: INFO/ActivityManager(2247): Process de.finder.anfinder (pid 2832) has died.
09-06 16:07:39.231: WARN/ActivityManager(2247): Scheduling restart of crashed service de.finder.anfinder/.AnChecker in 320480ms
Quelle
Developer
Developer
 
Posts: 34
Joined: Thu Mar 11, 2010 10:53 am

Re: Let a app sleep or wait

Postby achie1266 » Tue Sep 07, 2010 9:46 pm

If you are trying to do some background process and your app is waiting on the response then it has to be done in a background thread. You need to implement a handler also to communicate back to the main activity when the process is done and your activity is ready to resume.

Or alternatively you have to use AsyncTask to implement this process.

You may also want to consider showing a dialog with a message saying that your app is doing some background process.
achie
User avatar
achie1266
Master Developer
Master Developer
 
Posts: 223
Joined: Mon Nov 09, 2009 10:56 pm
Location: Denver

Re: Let a app sleep or wait

Postby Quelle » Wed Sep 08, 2010 5:44 pm

thank you.
if i have time to spare, i will take a look at and i will deal you my expreience.
Quelle
Developer
Developer
 
Posts: 34
Joined: Thu Mar 11, 2010 10:53 am

Re: Let a app sleep or wait

Postby achie1266 » Wed Sep 08, 2010 5:55 pm

np.

It is a easy thing but may take a little time if you are doing it the first time. There are also a bunch of posts regarding this and I believe there are some tutorials on this if you search for progress thread . [I don't remember exactly].
Let me know if you are struck.

gl
achie
User avatar
achie1266
Master Developer
Master Developer
 
Posts: 223
Joined: Mon Nov 09, 2009 10:56 pm
Location: Denver

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 22 guests