Android :: Pausing / Stopping And Starting / Resuming Java TimerTask Continuously?

Jan 20, 2010

I have one simple question regarding Java TimerTask. How do I pause/resume two TimerTask tasks based on a certain condition? For example I have two timers that run between each other. When a certain condition has been met inside the task of first timer, the first timer stops and starts the second timer, and the same thing happens when a certain condition has been met inside the task of second timer.how do I pause timer1 while running timer2 and vice versa while timer2 is running? Performance and timing is my main concern as this needs to be implemented inside another running thread. By the way I am trying to implement these concurrent timers on Android.

Android :: Pausing / stopping and starting / resuming Java TimerTask continuously?


Android :: Pausing And Resuming Tutorial

Apr 7, 2010

I'm having some difficulty figuring out the best ways to pause and resume my application. Is there any comprehensive tutorial or something similar that would help me make sure that I'm not missing any important steps?Mostly I'm just worried about not dealing with the memory being used by my application. There's a few apps I own that when you minimize them slow down the rest of the phone to a stand still and I want to make sure to avoid that.

View 1 Replies View Related

Android : Avoiding An Activity To Destroy - Just Stopping Or Pausing It When Pushing The Back Button

Mar 19, 2010

I would like to pausing or putting the application on background when pressing the back button, I don't want the application to go through the destroy state. Things are when I override onKeyDown and when I force to pause or stop the application by using onPause, I have some issuees with the wakelock and application crash, but when I press home button I go through onPause method and I have no exception, it's weird!

View 1 Replies View Related

Android :: Java.util.TimerTask

Jan 15, 2010

Can I rely on Timer and TimerTask to work properly on Android?

I have a background Service with a single Timer, and I schedule (possibly multiple) TimerTask's via Timer.schedule()

At the beginning of each implemented TimerTask.run() method, I check the TimerTask.scheduledExecutionTime() and compare it with the current time. Sometimes things are fine, and the difference is a small number of ms. But sometimes things are nowhere near fine, and the invocation of my TimerTask is *way* late -- like multiple hours late.

Can an Android phone go into some deep sleep mode when it doesn't think anything is going on that would cause a TimerTask to be so late? Can I not reliably use TimerTask for scheduling events, and should I be using some Android-specific means (e.g. the AlarmManager, or a Handler) instead?

I have not found anything that says that java.util.TimerTask shouldn't be sufficient, the Android docs include no kinds of qualifiers, and this post (from Mark Murphy, who's written several good Android books) specifically mentions it as being available:

http://groups.google.com/group/android-developers/browse_thread/threa...

View 5 Replies View Related

Android :: Starting And Stopping Services

Aug 14, 2010

I have a service running (Socket), this is how i start the service.

CODE:.......

But this doesn't seem to stop my service? Am i missing something? I need to destroy my service as soon as the home button is clicked.

View 1 Replies View Related

Android :: RotateAnimation - Stopping And Starting Again After Every Rotation

Mar 29, 2010

I am rotating a view using rotateAnimation with this code new RotateAnimation(0, 360, w / 2, h / 2); I want to rotate this view infinitely, so i put setRepeatCount(RotateAnimation.INFINITE);

But the problem is after every one complete rotation, its stopping and starting again, means by default rotateAnimation have AccelerateDecelerateInterpolator(). I feel because of this. So if i put setInterpolator(null), its throwing null pointer exception. How to solve this.

I want to rotate my view without any lag.

View 4 Replies View Related

Android :: Framework Support For Detecting Starting And Stopping Of Activities

May 13, 2009

To support usability studies on what applications are used, i want to write a service that logs when an activity is started and also when it has finished. This is to understand how the users are using the device:

One straightforward option is to have the applications modify, to write this out. But this is tedious having to modify all applications and will not work esp with third party or built in applications.

Is there any alternatives that makes this simpler and easier?

BTW: Looking at the android framework source ActivityManagerNative seems to be invoking a Binder interface when an Activity is started and finished. Any information on what this service is? Is this something i can tap into?

View 8 Replies View Related

Android :: Stopping And Starting Service Based On Application State

Oct 28, 2010

I have a Service which tracks the location of the user. Currently, the Service boots when the application starts and stops when the application terminates. Unfortunately, if users keep the application in the background, the Service never stops and drains battery.

I would like the Service to stop when my application is not in the foreground. I was hoping the Application class would let me Override onPause and onResume handlers, but it does not have them.

View 1 Replies View Related

Android :: Lock Layer Error Intermittently When Stopping And Starting A Opengl SurfaceView

Jul 13, 2009

I'm writing a game using the drawing method from Chris Pruett's opengl spritemethodtest demo. The Activity running my opengl view works fine on initial load, and about half the time after turning off the phone and turning it back on. However, the other half, it locks up. I'll get a "lock_layer timed out (is the CPU pegged?)" warning that keeps repeating. I tried running the debugger to find the exact line that the error is occurring on, but the strange thing is that this error won't occur if I'm running the debugger on my G1. It only happens under normal operating conditions. Any help would be appreciated, as this bug really has me stumped.

Here are my onPause and onResume activity methods:

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

Here's a stack trace, running from the initial onCreate call to the lockup (I added some extra Log warnings to illustrate when different lifecycle methods are being called):

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

View 2 Replies View Related

General :: Stopping Unwanted Apps From Automatically Starting?

May 8, 2012

I have an Acer A100 tablet that I've upgraded to ICS (the upgrade went very smoothly, by the way). But under both ICS and the original Honeycomb, the Android OS has an annoying habit of starting a bunch of apps automatically. Facebook, Google Maps, media players and a whole host of apps that I do NOT want to start all by themselves. I found an "Advanced Task Manager" that will check every 5 minutes and kill unwanted apps automatically. But every time I check it there are still half a dozen apps running in the background that I don't want.

If it were just one or two apps, I would simply uninstall them. But it seems like half the factory apps are intent on restarting themselves no matter how many times they're turned off. My Acer has a very small battery, and I suspect I'd get much better battery life if it would only run the apps that I start manually.

Other than email and the system update manager, I really don't want any apps running in the background. And when I turn an app off, I want it to stay off until I restart it. Is there a way to edit the list of programs that start automatically? Do they all have to be disabled individually? I've checked a few of the apps, and don't see any way to disable the "automatic log-in", "check for new data" or whatever each program might call it's annoying insistence on starting whenever it wants to.

View 3 Replies View Related

Android :: Starting - Java Or Python - SL4A

Jul 27, 2010

I just ordered an Android smartphone and want to start playing around with creating my own applications. Now the question is which language to use, the native Java or Python using SL4A (former ASE).

I tend to Python, as I know it much better than Java, but I'm wondering what I would be missing using a "second class" language on Android. On the SL4A website it is also stated to be alpha quality software, which is not exactly encouraging.

I'm also not quite sure what the limitations of the scripting environment are and if they would be problematic.

View 3 Replies View Related

Android :: Starting Subactivity For Second Time Causes Java.lang.OutOfMemoryError

Apr 10, 2010

I am developing a simple app which does a little bit of image-processing. It's divided in two activities; the main one with some display elements and the second one which is used to capture images off the phone's camera.

To discribe my problem: I start the app, capture an image (by starting a new Intent with the subactivity) and all data is displayed correctly. If I capture another image after this, I run in an java.lang.OutOfMemoryError - bitmap size exceeds VM budget

I dont store the captured bitmap, in the second activity I just extract some data from it and pass it to the main-activity; finishing (finish()) the sub-activity afterwards.

View 1 Replies View Related

Android :: How To Use Java Runtime Class For Starting Another Application From Mine

Mar 12, 2010

Basically i want to start Notepad application in android from my application , can i do this in android using runtime.exec() method of RuntimeClasss and assign it to a process and kill the process later.

View 8 Replies View Related

Android :: What Is The System Effect Of Starting Large Quantities Of Timers In Java

Jul 14, 2009

I have had to program some applications that require large amounts of timed tasks to occur. However, I'm afraid to create so many timers because I haven't been able to figure out how they are handled by Java. Is there a problem with starting large quantities of scheduled tasks? If so, what is the better alternative?

View 2 Replies View Related

Android :: Update A View From A TimerTask?

May 21, 2009

Is it a no-no to try to update a View from a TimerTask? My initial experiments indicate it doesn't work. Is there a way to make it work?

View 3 Replies View Related

Android :: Possibility To Pause&resume A TimerTask ?

Jul 30, 2010

I'm calling this tasks:

CODE:.........

And here are the two TimerTasks:

CODE:........

As you can see, I just call a method after 5 resp. 10 seconds. From time to time I would like to pause the "countdown". This means i want that the time until the 5 seconds are passed isn't running anymore. And then in a later point in time, I would like to resume it. How can I achieve that?

View 1 Replies View Related

Android :: Have TimerTask (or Equivalent) That Executes Even While Display Is Sleeping?

Feb 9, 2010

I have noticed that when display goes to sleep, my TimerTask is also freezed, until display is waked up. I need my TimerTask to execute (a BlueTooth operation every few minutes) even while the display is sleeping.

How do i achieve this (eventually using something else instead of a TimerTask)?

View 3 Replies View Related

Android : Pausing Game On Pop-ups

Oct 7, 2010

I am working on an application and I want to be able to detect when a pop-up (e.g Charger notification, task switcher or the dialog that pops up when you hold the power button) is obscuring the game so that I can bring up the pause menu. These notifications do not produce an "onPause" event. Does anyone know the correct way to do this? I know it can be done by detecting the focus loss from the surfaceview, however views can be added and removed I was wondering if there is a better way of doing this than adding a focus handler to each one and trying to keep track.

View 2 Replies View Related

Android : Pausing & Reuming Game

Nov 14, 2009

I have a game in android platform. I want to implement pause game function but I don't known stop current threat and resume it when re-play. Please help me solution!

View 3 Replies View Related

Android :: Inside Service Class / Executing Method For Toast From Scheduled TimerTask

Apr 30, 2010

I am trying to execute a {public void} method in Service, from scheduled TimerTask which is periodically executing.This TimerTask periodically checks a condition. If it's true, it calls method via {className}.{methodName};However, as Java requires, the method needs to be {pubic static} method, if I want to use {className} with {.dot}.The problem is this method is for notification using Toast(Android pop-up notification) and Status Bar.But for this to work, the method must not have {static} modifier and resides in Service class.So, basically, I want background Service to evaluate condition from scheduled TimerTask, and execute a method in Service class.Can anyone help me what's the right way to use Service, invoking a method when certain condition is satisfied while looping evaluation?

View 1 Replies View Related

Android :: Pausing Main Game Thread Until Activity Started

Aug 13, 2010

In my game when the user completes a stage, I want the main game thread to pause/sleep/wait and a new activity to be launched called StageClear that displays information about points scored etc. After this has been displayed and the user has pressed continue I want the original game thread to resume where it left off. I have tried to implement this but have so far been unsuccessful, probably because I'm new to dealing with multiple threads and also the idea of synchronizing them. I most recently tried to implement a shared package-visible object that could notify after wait was called on itself, but I am getting errors in eclipse so it won't even compile, I think because though the object is declared public in an inner class, it cannot be seen or recognised by my activity elsewhere in a file in the package. I have already built both activities but my issue is getting the main game one to launch the other, and pause whilst it waits for this activity to finish, before the main game thread continues execution.

View 1 Replies View Related

Android :: Pausing A Thread - Activity Pause Timeout For HistoryRecord

Jun 30, 2010

I'm trying to write a game engine in Android, but I don't have much familiarity with threads.

My thread has an attribute, mSurfaceHolder, which holds the surface that I'll be drawing to. The run() method for my thread looks like this:

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

STATE_RUNNING represents the state when the activity is in the foreground and the game should be running.
STATE_PAUSED represents the state when another activity has come into the foreground. I'm not completely sure why I need to still draw while it's paused, but that's what I seem to have gathered from the LunarLander example.

What I'm hoping is that while I'm looking at the activity, the game will update and draw (which I test by using LogCat). And then when I go back to the home screen or another activity appears over the top, it will just draw.

Well it does draw and update while I'm watching the activity, so the game loop itself works. But when I leave the activity, it has no effect. Here is the thread's pause() method that is called from the activity's onPause():

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

As you can see, to test this method I have logged some messages. Now what I find when I leave the activity is that "Here" is logged, but "There" is not. Now with my limited knowledge of threads (I hardly know what synchronized actually does), I believe this will happen because my thread can't get synchronized with the surface holder. But I don't know WHY it doesn't synchronize. A few seconds after I've left the activity, I see the following warning in LogCat:

Activity pause timeout for HistoryRecord

Any idea why this would happen? There are no problems if I try to start the activity again, the thread just keeps running as it was.

Just discovered something else. The thread pauses just fine if I leave the activity within about a second of having started it. And then it will resume and pause again with no problems at all while the same task is still running. I have no idea why for a short period of time it will work, but if I leave it too long, it won't.

Okay... I fixed it. But I don't think I'm supposed to do what I've done. I've basically removed any synchronization with mSurfaceHolder from both the pause() and the setState() methods (which is used by pause()). No it works as it's supposed to, but I'm thinking the synchronization is there for a reason.

Perhaps the best question for me to ask is this: WHEN should you synchronize a thread with an object by use of a synchronized block? And in this case, what is the purpose of synchronizing with the SurfaceHolder?

View 1 Replies View Related

Android :: Out Of Memory Resuming Application

Feb 22, 2010

My application uses a single activity to switch between different views. I premise I'm loading a good amount of bitmaps in one of this view (say the gamescreen view) constructor but I recycle everything on the onDetachedFromWindow method.All the Bitmaps are static and most of them loaded with BitmapFactory. decodeResource method.Furthermore I'm using a gallery wich content is a simple layout with eight imagebuttons.I know all the complications using this widget and all the risks of using static bitmaps, but, I guess my problem does not entail them because my application is running well if I try to switch between these two view (and I've tried to do it about 30 times without crashes!!!) but when I pause and resume the application two times (pause->resume->pause->resume) I run out of memory, and often without the crash message (it just stays on the actual view).

View 13 Replies View Related

Android :: Difficulty Resuming SurfaceView

Apr 24, 2009

I am stuck.My main activity creates and starts a SurfaceView.My app needs to access a listview via the options menu to change properties of the items shown in the view.Two strange things occur:

1.) When I scroll the listview quickly, the list sometimes gets farklempt.Words overlap each other.

2.) When I select the item and the app returns to the main activity, the thread is no longer alive.

If someone out there can offer help I will post the code.This will take a little effort.My code is loosely based upon LunarLander and the GLSurfaceView examples.If there is a good example (more recent example) someone can point me to, that would be boss.

View 8 Replies View Related

Android :: Resuming An Activity From Notification

Mar 5, 2010

I have a notification in the status bar for my app.The problem with this is that when you press the home button from the app (pushing it to the background) then press on the notification in the list accessed from the status bar, it starts a fresh copy of the activity. All I want to do is resume the app (like when you longpress the home button and press on the app's icon). Is there a way of creating an Intent to do this?

View 1 Replies View Related

Android :: Suspending And Resuming Threads

Nov 17, 2009

We are developing an application that needs to suspend and resume threads like a debugger (meaning in a non-safe way like Object.wait() and Object.notify()).In the Java SDK the methods Thread.suspend() and Thread.resume() are deprecated but we can still use them. Also there is the Java debugger API which allows one to do that if you connect to the VM as a debugger. Is there some API for android we can use? Is there a published Java Debugger API we can apply for Android?

View 2 Replies View Related

Android :: Pausing VideoView When Launching A New Intent / Resume It To Starts Up Activity Again?

Jul 23, 2009

I have an activity that is showing a video and when the user clicks a button, a new activity is launched. When the video activity stops, I pause the video view. When the video activity starts up again, I try to resume the video view videoView.start(), however, the video starts over from the beginning. I'm thinking that the buffer must be lost somewhere, so I now try to capture the current position via videoView.getCurrentPosition(), however, this is always returning 0.

Anybody know how to resume video playback when an activity starts up again?

View 5 Replies View Related

Android :: Resuming Large File Download

Sep 17, 2009

I am trying to implement the functionality to resume a large file download, but have not found how to start downloading from a position that is not at the beginning of an InputStream.I am currently using the InputStream.skip() method to go to the position where I want to resume the download, but have found that this method actually reads all the data over the network and then throws it away.I would appreciate some help in learning the correct way to start reading from the resume offset of the internet file being downloaded, so that I can avoid wasting the phone network bandwidth, and also avoid the extra time delay caused by re-downloading all the data that was already previously downloaded.

View 2 Replies View Related

Android :: Home Button Not Resuming Last Activity

Sep 23, 2010

I am trying to solve an issue sort of similar to what was done here (link text)Except in my case where Activity A, started Activity B, started Activity C, when the user resumes the app after pressing the home button - I want C, the last Activity, to be displayed. Instead what is happening is I am back to A.Also on a side note I have discovered that even when I exit the application, if I hold down the Home button, my app is still listed as an active app even though in the LogCat I can see that it exited OK.Also, in case it matters, I did recently add android:launchMode ="singleTask" in order to make some notification logic work correctly. I was seeing the Home button behavior before that though.

Activity B actually has several Activities that it chooses from (it has a list of Intents) to display based on input it receives but launches them all the same way as Activty A launched B. Once the first Activity is displayed the user swipe the screen to navigate to the left or right screen. When the user swipes left or right, the current activity puts info in its return Intent that Activity B uses to display the next Activity. Also since logic outside of the user's control could prompt a change in the screen displayed, each Activty calls finish on itself in onStop to avoid back-button issues.

View 2 Replies View Related

Android :: Broken OpenGL Texture Output After Resuming App

Jul 28, 2009

I've run into a very strange problem regarding OpenGL texture outputs, which only occurs when the app is resumed (particularly when leaving after pressing Home, and going back into the app).I'm not sure how or why, but it appears to be that it's reading bitrate of the pixels incorrect, or something else entirely. Furthermore, this issue only occurs on the device itself (testing on my G1/Dream), not on the emulator.Code as well as example screenshots in the zip file show exactly what I'm talking about. And to completely replicate the issue I've included the 2D sprite object framework I've developed for OpenGL so the situation is exactly the same as what I've run across when developing my game, so if it's somehow an issue in my framework you may be able to spot it.

View 6 Replies View Related







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