Android :: Service Won't Stop When Exiting Application

Jul 13, 2009

I have a service receiving and sending data to a server in separate threads each. The service lifecycle methods look like this:..................

Android :: Service won't stop when exiting application


Android :: Cannot Stop Soundpool Loop Even After Exiting Application

Nov 4, 2010

I have a timer thread setup to play a loop using soundpool, but for some reason I cannot get _soundPool.stop(_playbackTimer); to stop the loop. even if I exit the application the loop keeps running. I have to physically power off the phone to get it to stop. am I missing something here? Does anyone have any experience with this? I have searched with no resolution. below is a snippet.

if(timeLeft>0 && timeLeft<20 && ticking == false){ _soundPool.play(_playbackTimer, 0.3f, 0.3f, 0, -1, 1); ticking=true; }
if(timeLeft==0 || timeLeft>20){ _soundPool.stop(_playbackTimer); ticking=false; }

View 2 Replies View Related

Android :: Warning Before Exiting Application?

Jul 29, 2009

I have an app that receives and stores SMS messages. The main use is to run in the background, although it does have a full GUI when running in the foreground. I'm using a notification with the FLAG_ONGOING_EVENT flag so users can tell the application is running, even if it's in the background. However, the user could easily close the app by viewing the main screen and clicking the back button. The notification icon goes away, but I would like to be able to warn the user that closing the app would prevent it from capturing the SMS messages. Is there any way to prompt the user if they really want to exit the application when they hit the back button, and prevent the exit if they say no? Or should I take a different approach? And a bonus question: is there a way of receiving an SMS message, but prevent it from passing on to, say, the Messenging app?

View 5 Replies View Related

Android :: Process Died After Exiting Application

Jan 14, 2010

I am seeing a curious behaviour in my app. I have a widget that gets updated by a service every # hours, when the service finishes I stop it, using "stopService(new Intent(this, MyService.class));", the widget if pressed launches an Activity. Now it gets interesting, while im on the activity everyting works fine, then when I exit the app(by the back key or a button I designed which simply calls this.finish() ) the ActivityManager would tell me that my process has died, I do not see any error of any kind, just that the process has died.

Why I am seeing that message and what does it mean exactly? That is having a side effect on my service regarding static variables getting set to default. Could my code be the cause of this? Is there any way to know that your process has died? I have tested my app on a HTC Hero running 1.5, it always works well on the emulator and I never get that message. I know android kills processes to reclaim memory but Im always careful to close apps heavy on resources.

View 4 Replies View Related

Android :: Execute Code Before Exiting Application?

Nov 18, 2009

I would like to know how to execute code before exiting application. My application is composed of several activities. When the user starts the application (from the launcher menu or from a notification in the status bar), he goes in an InitActivity where I process some initializations. From user experience, application always restarts. One of these initializations is to init a network manager and start a thread that periodically sends a network request to notify a server that application is active.

I need to process some end operations, like stopping this thread when user quits application, for example by pressing the HOME key or BACK key when he's in the root activity. However, when the user press the HOME key, application is still running in background.

Q1 : is it possible to execute code when exiting application (I see the onTerminate() method of the class Application but it seems not to be always called)?

Q2 : Is it possible to force application exit (activity method finish () only destroy the current activity, not the application)?

Q3 : Is it possible to handle HOME key press (onKeyDown() is not called when this button is pushed)?

View 3 Replies View Related

Android :: Different Behavior When Exiting Application Using BACK And HOME?

Mar 5, 2009

Say a user runs my app from the HOME screen. The app has 3 tabs. Say he/she selectes a different tab, so he/she is in a different screen (same task). Now - if the user presses BACK - the device returns to the HOME screen. If the user launches my app again - the default tab is shown. BUT - if the user presses HOME - the device returns to the HOME screen (same). If the user launches my app again - the OTHER tab is shown.

I understand (sort of) the logic - BACK returns to previous app, popping my app from the history stack, so when launched again - it is started from scratch. But this is confusing my customers - they say it's a bug ! They dont understand the different between two keys doing the same thing as far as they see (returning to HOME). Moreover - I see a different behavior with the built-in DIALER app - I change tabs, press HOME, launch the app again - and it starts with the default tab.

View 11 Replies View Related

Android :: Application Manager Not Exiting Properly In Eclair 2.1

Feb 9, 2010

With Android Eclair 2.1 on ARM-based target, we are executing Instrumentation test application from command line:

am instrument -e class android.app.foo. -w com.android.cts.foo.MyTestApp/android.test.InstrumentationTestRunner

Test application executes fine, showing result of the sub-tests in the MyTestApp. But, Application Manager is not exiting properly. This is observed from "ps" command output:

1114 0 52328 S app_process /system/bin com.android.commands.am.Am in....

Due to this issue, we are not able to execute the test applications in shell script.

View 3 Replies View Related

Android :: Application Restarts When Exiting With Back Button

Dec 30, 2009

Does anybody have any insight as to why a game appliction would restart when exiting with the back button. It does not automatically restart when using the Home button to exit and this only occurs one time (after the second attempt to exit with the back button, it exits cleanly). Also, I can reproduce this consistently on the Motorola Droid, but have not been able to reproduce on the G1 or the emulator running 2.0. I've tried changing the launchMode of my activities, but have not found something that works. These are my activities:

1. Splash Screen, Single Instance, Main/Launcher 2. Help, Single Instance 3. High Score, Single Top 4. Preferences, Single Top 5. Options, Single Top 6. Game, Single Top, with SurfaceView

The steps to reproduce the problem are: 1. User starts application, launching Splash Screen Activity 2. User starts game, launching Game Activity 3. Game Activity launches Options Activity (for result) 4. Game Activity restarts with result and game begins. 5. Pressing Back Button returns to Splash Screen Activity 6. Pressing Back Button again, briefly shows home screen, then relaunches Game Activity which starts Options Acitivity 7. Pressing Back Button again finally shows the home screen

View 2 Replies View Related

Android :: Any Way To Kill Threads Those Are In Sleep Mode / While Exiting Application

Feb 18, 2009

the thread sleeped not killed and it wakes up after 10 sec and try to post message and it causes exception. is there any way to kill the threads those are in sleep mode while exiting the application?

View 5 Replies View Related

Service Doesn't Stop When Asked To Stop

Aug 2, 2012

Okay when user presses log out button what's supposed to happen is:

Code:
stopService(myIntent);
unbindService(mConnection);
mIsBound = false;

I need to shut down the service on background.Except the service restarts itself over and over again! Even if I kill the program from task manager the service restarts itself. Other programs aren't using the service. when I uninstalled the program the foreground program information popped up indicating it was STILL there(albeit this I solved by rebooting phone).

When user says he's finished with the program 'least he can expect is for the program to stay down rather than keep eating battery by acquiring GPS signal and sending them to server. The program is not intended to be "once you log in you need to Uninstall me and reboot phone to get rid of me!" type of program!

View 6 Replies View Related

Android :: Start And Stop Music On Application Launch And Stop

Jan 5, 2010

In my application i have several activities and i want to start background music whenever my *Application* is launched and stop music whenever *Application* is paused or stopped.

View 4 Replies View Related

Android :: Make Service Stop Itself?

Dec 11, 2009

I start a service in an activity then I want the service to stop itself after awhile.

I called stopSelf() in the service but it doesn't work.

how to make the service stop itself?

View 3 Replies View Related

Android :: Way To Correctly Stop Camera Service?

Jun 1, 2010

Is there any way to correctly stop the camera service? This does not seem to work: After doing that the camera does not work, even if I use the program that is pre installed in my handset.

View 2 Replies View Related

Android :: How To Stop Service - When All Activities Are Finished

Jan 26, 2010

I am programming a game. I have a service for the background-music. When I press the home-button and leave my activities, the service still runs in background. How can I stop the service, when there is no more visible activity in my program and restart it, when the user goes back to my game (some activity of it)?

View 8 Replies View Related

Android :: Stop Service After AsyncTask Finished

Jun 26, 2010

I have a service, that requests another class, which launches an AsyncTask

Service->Weather Class->Execute Method->Asynctask->Execute

this is launched in the service by

new Weather(this).execute(); // the execute is a method of the class, not of the AsyncTask

how do I detect in Service that the AsyncTask finished so I can call stopSelf?

View 1 Replies View Related

Android :: Stop Service Only When There Are No Other Activities In App Running

Mar 13, 2010

Is there a way I can test if there are any other activities in my app still alive? I am looking to stop a service in an onDestroy method, but only want to do this if there are no other activities from my app still alive on the stack.

I have the call stop the service in the main activity's onDestroy() method. This works perfect EXCEPT that if a user launches my app, then launches a few activities in my app, then hits the home screen and RELAUNCHES my app, they will subvert my order and the main activity will now be above other activities of my app. From this state, if they hit the back button and 'back out' of my home screen they will trigger the onDestroy() method and kill the service even though there are other activities open on the stack. I want to avoid this by stopping the service ONLY if I am sure there are no other activities of mine open on the stack.

View 1 Replies View Related

Android :: How To Stop Location Manager Service?

Jul 2, 2009

I have a location manager: mLocationManager01 = (LocationManager)getSystemService (Context.LOCATION_SERVICE); because i want to stop the gps service, but when i use mLocationManager01.removeUpdates(mLocationListener01); that's not working to stop gps. how can i stop it?

View 4 Replies View Related

Android :: Running Service On Start Up And Stop Before Shut Down

Jan 30, 2010

Is there an API, or a registry I can do in the manifest to make sure my service is being run at the device start up and being shut down before the device shuts off?

View 3 Replies View Related

Android :: Service Stop When Pressing Back Button

Mar 19, 2010

I created and binded a service in an activity and I would like to know how I can avoiding the android application to stop when I press the back button. When the back button is pressed the onDestroy method is called and I unbinded the service in this method. I try to prevent it by taking care of the back button event and manually call for onStop() method but it always called onDestroy after, why?

View 1 Replies View Related

Android :: Force Service To Stop After Fixed Time?

Oct 14, 2010

I have a service which runs in the background when the user starts using my app. I am using it to do some posts to our server. I always close my service by calling stopSelf as soon as the posts have been made or failed.

But I recently observed two times that my service did not stop. I saw that in the running services in settings on my device that it has been sitting there for over a few hours.

So I was trying to see if I can alternatively set a timer using which I can force the service to stop after a few minutes no matter what.

View 3 Replies View Related

Android :: How To Stop Service Method Of Calling Activity Class?

Jul 2, 2010

I am trying to call my service class's stopService() method from my activity. But I don't know how to access stopservice method from my activity class. I have the below code but its not working. This is HomeScreen class:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
enablecheck = (CheckBox)findViewById(R.id.enablecheck);
enablecheck.setOnCheckedChangeListener(new OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
if(enablecheck.isChecked()){
startService(new Intent(HomeScreen.this, AutoService.class));
} else {
stopService(new Intent(HomeScreen.this, AutoService.class));
} } });
}
This is Service Class:
public class AutoService extends Service {
private static final String TAG = "AutoService";
private Timer timer;
private TimerTask task;
@Override
public IBinder onBind(Intent intent) {
return null;
} @Override
public void onCreate() {
Toast.makeText(this, "Auto Service Created", Toast.LENGTH_LONG).show();
Log.d(TAG, "onCreate");
int delay = 5000; // delay for 5 sec.
int period = 5000; // repeat every sec.
timer = new Timer();
timer.scheduleAtFixedRate(task = new TimerTask(){
public void run() {
System.out.println("done");
} }, delay, period);
}
@Override
public boolean stopService(Intent name) {
// TODO Auto-generated method stub
timer.cancel();
task.cancel();
return super.stopService(name);
} }

View 3 Replies View Related

Android :: Droid Screen Locked - Service Stop / Can I Solve It

Sep 18, 2009

I had the program I wrote a service, and in service has written a timer, change the timer for one minute cycle time, but why the program in the phone standby (screen lock) were time, I have the timer will be stop running, when I click the menu, get back to normal mode when the timer will automatically have to run? What is the reason, how to solve?

View 2 Replies View Related

Android :: Where To Stop / Destroy Threads In Droid Service Class?

Mar 25, 2009

I have created a threaded service the following way. code...

After I close the application the phone works really slow and I guess it is due to thread termination failure.

Does anyone know what is the best way to terminate all threads before terminating the application?

View 3 Replies View Related

Android :: How To Stop Service Started By BindService() With Bind_auto_create Option

Nov 18, 2010

I start service by using:

private ServiceConnection _serviceConnection = new ServiceConnection() {...}
bindService(new Intent(this, MainService.class), _serviceConnection, Context.BIND_AUTO_CREATE);

I want to 'restart' the service. (Let's not argue why I want to do that)
I do that by:

unbindService(_serviceConnection);
// Do some initialization on service
bindService(new Intent(this, MainService.class), _serviceConnection, Context.BIND_AUTO_CREATE);

I noticed service doesn't die(onDestroy doesn't run) until I call next bindService();
So some static initialization I did on service got cleared by onDestroy() implementation.

Question: How do you make sure unbindService() will stop service (run onDestory()),
so that I could do initialization after and re-run bindService()?

View 3 Replies View Related

HTC Incredible :: How To Stop Obex Service

Jun 24, 2010

I saw this in the "running services".. and i stopped it, what the hell is it and should i not have stopped it?

View 2 Replies View Related

Motorola Droid :: GTalk Service Starting All By Itself / Stop It?

Nov 23, 2009

So sometimes I'll go into my contacts and notice that some of them have the green ball lit up telling me that they are online in gtalk. Now I am not signed onto gtalk... but yet somehow I see that in my running services that GTalkService is running.

I can only assume that its eating away battery trying to see how is online and not. I certainly don't need this info unless I wish to go online myself... in which case I would actually go into the gtalk app.

ANyways, obviously i've been killing it in the running services, but it just comes back all on its own. ANy idea why or how to stop it?

View 9 Replies View Related

Samsung Epic 4G :: Hotspot Service Running / Stop It From Starting?

Sep 18, 2010

Ok, so i go to check running services and i see that sprint hotspot is running. i have not started it since the day i bought the phone. i have no intention of using it, for now. why is it running and how can i stop it from starting? is it supposed to be running?

View 2 Replies View Related

Android :: ADB Shell Exiting Abnormally

Oct 13, 2009

I find that when I am running 2 android devices connected to 1 linux machine, I find I can get ADB shell to exit abnormally. If I start a shell on Device 1, then on Device 2 start a shell and type reboot. Device 2 resets like expected, but the shell on device 1 will exit. I find that functionality of running controlling multiple devices with ADB very useful for testing. My question is can anyone reproduce this? Has this been fixed upstream? Is ADB planning on first class support for multiple devices, or was this an after thought feature? Any help debugging this, or possible just a little information in the right direction so I can make a patch myself.

View 5 Replies View Related

Android :: Getting Crash When Exiting Activity?

Sep 4, 2009

I am experiencing a crash in my app when I quit (via the back button) out of my Activity. So far as I can tell this is happening in the Android codebase and not mine, but I'm not completely convinced of that.

AndroidRuntime E Uncaught handler: thread main exiting due to uncaught exception
AndroidRuntime E java.lang.RuntimeException: Unable to stop activity {MyApp/MyApp.MainActivity}: java.lang.NullPointerException
AndroidRuntime E at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3097)
AndroidRuntime E at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3159)
AndroidRuntime E at android.app.ActivityThread.access$2400(ActivityThread.java:112)
AndroidRuntime E at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1724)
AndroidRuntime E at android.os.Handler.dispatchMessage(Handler.java:99)
AndroidRuntime E at android.os.Looper.loop(Looper.java:123)
AndroidRuntime E at android.app.ActivityThread.main(ActivityThread.java:3948)
AndroidRuntime E at java.lang.reflect.Method.invokeNative(Native Method)
AndroidRuntime E at java.lang.reflect.Method.invoke(Method.java:521)
AndroidRuntime E at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
AndroidRuntime E at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
AndroidRuntime E at dalvik.system.NativeStart.main(Native Method)
AndroidRuntime E Caused by: java.lang.NullPointerException
AndroidRuntime E at android.app.Activity.performStop(Activity.java:3575)
AndroidRuntime E at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3092)
AndroidRuntime E ... 11 more

View 1 Replies View Related

Android :: Exiting From Xml.parse When Match Found

Aug 18, 2010

I'm using the Android SAX parser to search for entries in a rather large (6MB) XML file. I'm basically using a derivative of the code shown in listing 8 here. The question I have is how do I stop parsing once my match has been found? The code shown continues parsing through the end of the file but I want to stop before then. Is this possible or do I need to use something other than SAX

View 1 Replies View Related







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