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
Feb 7, 2012
i want to develop a android application named letC ,the main moto of the app is the user has to write c code and has to execute with in the application.
View 8 Replies
View Related
Aug 24, 2010
So basically I would like my app to read info from a database, this info would be a string that is valid java code. Once read, I would like my app to execute this string as if it were code. Is there any functionality packaged with the android sdk that supports this?
Essentially I want the phone to populate some data with information queried from a database. One of these pieces of information would be a statement like: "return data.ZombieKillTotal >= 100000;"
Which would be used inside a statement like:
CODE:......
I just don't know what to use for 'ExecStringAsCode':
View 3 Replies
View Related
Jul 15, 2010
Are Activities in the background considered "running" (and can execute code) or are they in a suspended state?
View 1 Replies
View Related
Jul 29, 2010
I'm trying to execute code from Android's help page, but it doesn't work for me:
CODE:..........
When I execute task, doInBackground is invoked fine, but onPostExecute is never invoked. Tested on Milestone with 2.1 OS
View 1 Replies
View Related
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
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
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:..................
View 3 Replies
View Related
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
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
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
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
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
Apr 12, 2010
In my application I want to create a directory xyz in sdcard at the runtime from the my Application. But it doesn't work.
Here is my code...............
View 1 Replies
View Related
Nov 19, 2010
I would like to know how to execute a system command from an android application?
For example :
I would like to create a directory while I am running an application, so i need to execute the command "mkdir -p /x/y".
View 2 Replies
View Related
Jul 28, 2010
I am trying to execute a shell script from application using
java.lang.Process API.
The script file is executing properly as i am able to get logs but the line
*$SETPROP net.if.default rmnet0* * * is not getting executed.
has anyone able to execute .sh file from application succesfully.
Code Snippet: *//* *str={"/system/bin/sh","/sdcard/test.sh"};* *Process p = Runtime.getRuntime().exec(str);* * * *//* * * test.sh: LOG=/system/bin/log SETPROP=/system/bin/setprop $LOG -t test"++Setting up default iface"
$SETPROP net.if.default rmnet0 $LOG -t test"++Setting done "
View 5 Replies
View Related
Jun 28, 2012
I would like to execute adb commands from my Java application. At the moment I use Runtime.getRuntime().exec(command), is there a better way? Maybe even a library?
View 5 Replies
View Related
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
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
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
Aug 12, 2010
This is my target:
I need an Android application which should be able to fetch data from the web (maybe an .apk or a .jar) and launch "something" from it.
If it's a "trivial" class there's no problem at all. This is my Loader
CODE:.............
The problem is that the code I want to execute looks very like an application, which should have a "simple" view and some interaction on it.
I'm not able to invoke the "onCreate" method of my downloaded class.
I guess I've three streets:
I look for a method which silently install the application and then runs it (is it possible?) I understand how to initialize a second "application" inside my own one (with its own R and all stuff) I write my master program to fetch data from the web and construct pages dinamically.
View 2 Replies
View Related
Jun 20, 2010
I've been researching the OS a bit and I can't really tell what happens to programs when you hit the home button to leave them. Do they stay running in the background? After a little bit of time does the system close them out? What happens to them? I have a Sprint Evo and I don't see a way to close them out. I know that battery life can always be helped, and I would hate to leave them running all day just sucking the life out of the phone if they don't have to be.
View 18 Replies
View Related
Jan 28, 2010
Are there any apps that would allow me to write a message, convert it to a QR code, then save that graphic to the phone, or even share it via email? Bar scanner is great for sharing links as QR codes, but a notepad I could type in would be cooler.
View 1 Replies
View Related
Jun 5, 2010
For all of you android devs out there that have the Android simulator running on your computer, you know that there are a few built in apps that are already installed on your 'phone'. I had an idea for an app that would utilize a function that is already being done in the spare parts app that comes already installed. I went on to the android developer site, dug through the source code files, and found the spare parts app, and am now trying to set it up so that running it from eclipse on my machine actually runs the app in the simulator.
In other words, I want to be able to make changes to and adjust some of the things in that app for my own needs. But it won't compile, because of a number of different errors. How do I get that source code running on my local machine? Is there some special trick that I just don't know about? I thought that if I could get the source code than the rest would be easy, but it isn't being too easy.
View 1 Replies
View Related
Apr 9, 2010
I'm wondering if it's possible to have an app that has a portion of its code implemented using Android 1.5 (API Level 3) and part using 1.6. (For example maybe implementing one of the app's activities in 1.6 while the overall app is in 1.5)?
View 3 Replies
View Related
Nov 19, 2010
I have two applications with two different application package names.
I want to use first application GUI code in the second one with out rewriting entire code.
But my first application using resource import statements in so many places.
Even i am able to compile it, i am getting runtime exceptions.
How to prevent these exceptions and make use one application GUI code in another?
View 5 Replies
View Related
Nov 9, 2010
I have downloaded the Source code of Android 2.2. Where can I find the default application source code of Android (Calculator,Calender etc on pressing Home Button).
View 1 Replies
View Related
Jul 7, 2010
Where can I find the source code for the Android Twitter Application?
View 4 Replies
View Related
Jul 30, 2010
I want to add <uses-permission> via programatically .I want to telephone number of the device.For that i need to access the phone state.But i need to add that permission only with Java code at runtime. Is it Possible to do so. (or) Can you suggest any alternative way to read the telephone number .?
View 4 Replies
View Related
Oct 16, 2010
I have an Android app and some company is interested in using part of it and rebranding it for its customers. One of the options would involve licensing the code to them for use in this specific case. Would you recommend doing that as a good option? What is the cost of licensing code in comparison to the cost of the original development. Should the license be for any use of the code, for using the codebase/year?
View 1 Replies
View Related