Android :: Using Activity Lifecycle Methods / What's Best Strategy For Binding?

Sep 15, 2010

I'm binding to a local Service (that is, not using IPC and AIDL) from several activities. I want to ensure that I'm not holding references to this service from activities that the user isn't using. My options are: 1.) to bind to the service in onCreate() and unbind in onDestroy(). 2.) bind in onStart() and unbind in onStop(). 3.) bind in onResume() and unbind in `onPause(). Or some combination of these. Which is the best-practice way of binding and unbinding to a local service? Do I not need to be concerned with holding local connections from stopped activities? Additionally, once bound to this particular service I am retrieving a Cursor which is attached to my ListActivity via a CursorAdapter. The data retrieved by the Cursor may have changed while the Activity was out of view so I want to requery it when the Activity is shown again. If I bind in onCreate() I can requery in onRestart(). If I bind in onResume() each time the data will be fresh because I'll query it in the Service's connected callback.

Android :: Using Activity lifecycle methods / what's best strategy for binding?


Android :: Activity Lifecycle OnStart OnStop Possible?

Oct 5, 2010

In the Android Application Fundamentals it says that after the call to the onStart()-method of the activity lifecycle either the callback method Resume() or onStop() is called. In case of an "normal" Start of an activity the system calls onCreate(), onStart(), onResume().But does somebody know an example where onStart() - onStop() are executed one after another?

View 2 Replies View Related

Android :: Activity Lifecycle And Static Variables

Jul 14, 2009

I just ran into a situation where it looks like a static variable reference is persisted across activity sessions. I didn't expect that because I thought that when an activity exits, it's de-referenced and garbage collected. I am wondering if anyone can shed some (more) light on when the VM eliminates object references for Activities and Services and in particular when static variables get reset to default values?

View 7 Replies View Related

Android : Activity Lifecycle Cause Memory Leaking

Aug 7, 2009

http://developer.android.com/reference/android/app/Activity.html

The Activity Lifecycle could have implementation and or design bug: One case is to initialize a big image in onCreate(), try to reuse the image during the whole lifecycle, and then recycle the image in onDestroy(). Test showed that onCreate() is called every time one navigate away from the activity and back again, but onDestroy() is not called at all. This behavour causes memory leaking for the big image (size 960*1920). After 6+ times away and back to activity, the system runs out of memory and has to kill the process.

One workaround is to initialize the big image in onResume() and recycle in onPause(), but that's not so good reuse.

Could it be better to change the process (as shown in the diagram) a little bit such as: Call onDestroy() first when a process is killed?

View 3 Replies View Related

Android :: Activity Lifecycle On Nexus One - OnStop Not Called

Mar 4, 2010

I have a problem with the activity lifecycle specifically on Nexus One (2.1 running on emulator works fine). If I just create a simple empty Activity with no special launchModes that logs the calls on the onStart and onStop methods, this is what I see: - launch app: onStart called; - home button: onStop NOT called; - launch app: onStart NOT called; - home button: onStop NOT called: and so on. Sometimes if I press the back button then the onStop is not called, but the when i launch the activity again the onStart is called and right after the onStop is called. Similar results with different launchModes. What is going on? Can anyone confirm this?
i found an android issue for the problem here: http://code.google.com/p/android/issues/detail?id=6094 and a similar thread here http://groups.google.com/group/android-developers/browse_thread/threa.

View 24 Replies View Related

Android :: Rule That Relates OnMeasure To The Activity Lifecycle

Jul 12, 2010

I have a custom view on which I need to call a method from my activity after the view has been measured in onMeasure. I would like to know exactly when onMeasure is called in the View layout process. It looks like onMeasure is called after my activity´s onCreate, onStart, and onResume. I could override onMeasure and maintain a variable that contains whether the view has been measured or not. However it would be nice to know if there is a rule that relates onMeasure to the activity lifecycle?

View 4 Replies View Related

Android :: How To Handle Activity Lifecycle On Wake Up - Alarm App

Oct 4, 2010

I'm having a couple of problems with an alarm app I am developing.

The first thing that I think is a bit weird is that when an alarm goes of and wakes the phone up. These things happend.

oncreate
onresume
onpause
onresume

Why are they run in that order? The last two should not be called? And this is what's causes me big trouble, because when i press home or back on the phone, onPause is run, which I want to call finish() from. And that part works as it should, but that does not work when the phone wakes upp from sleep bacause of the onPause call...

View 2 Replies View Related

Android :: Get Information Of Activity Lifecycle Callbacks In Views Drawn?

Aug 3, 2010

I want to get the size of a view that is in my activity but I am not able to get that information in any of the activity lifecycle callbacks (onCreate, onStart, onResume). I'm assuming this is because the views have not been drawn yet. At what point are views drawn and is there a callback I can put my code so I can get the size of the view?

View 2 Replies View Related

Android :: Binding Service To Activity

Dec 16, 2009

I am working on an android application, where the activity binds to a local service to perform certain tasks.Now I am binding the service in the OnCreate method of the Activity, after which the activity has to use the service object to invoke the functionality defined in the servicein the OnStart method. The problem here is that once a call "bindservice" has been made, we might not get the serviceobject immediately, so my service object would be null till that time. So i cannot invoke the service functions.So is there a way to determine in the activity that the service has been bound and the service object is valid and could be used now. For reference i'm attaching a code snippet for the same.

View 2 Replies View Related

Android :: Activity Service Binding

Mar 13, 2010

Can an Activity be bound to two different Services at the same time or do I have to unbind one Service before binding to the other one?

View 2 Replies View Related

Android :: Activity / Process Lifecycle - Save / Load Data To / From Disk

Nov 26, 2009

My app is made of two activities, A and B. I'm considering this sequence of steps: Activity A is started. A launches B [A is paused, B is running]. B launches a map intent [A and B are both paused now]. Now the user is using the maps application and the system decides it needs more memory. Can the system kill only one of my activities for memory, or will it always kill all activities in a "process" in this situation?

Both activities share some static data like:

class Data {
public static String mName;
public void save() {
// write to file: mName;...................

View 1 Replies View Related

Android :: Binding Service To Activity Vs Application

Jul 1, 2010

Is there any fundamental difference in binding a service to an android.app.Activity vs binding it to an android.app.Application. I want to bind the service to an Application because I want to keep some global state/data in the Application instead of duplicating it in all my activities.

View 1 Replies View Related

Android :: Binding A Remote Service From An Activity

Nov 23, 2009

I am binding a remote service from an activity and unbind the same on the onPause of the Activity,when the activity again restarts i bind the service .It does bind with the remote service and i am also successful in getting the remote-service method getting executed after the restart.But when returning a message from the callback-RemoteCallbackList.the mCallbacks.beginBroadcast returns me 0 clients.Am i missing some thing here ?why am i am getting zero clients when I call mCallbacks.beginBroadcast.?

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

View 2 Replies View Related

View Lifecycle And Refresh When Returning From Activity?

Oct 26, 2012

I'm writing an application for Android and have multiple Activities, there are three to be exact. When a user drills down to the record they would like to view, they can modify it.

The issues is that when I click the back button to move to the previous screen, i'd like to refresh it to reflect the update performed by the end user. I can't figure out how to hook onto the appropriate event and then refresh my data on that view.

View 3 Replies View Related

Android :: Methods Of Intents Activity?

Jan 8, 2010

I have two applications A and B (in different packages,but it doesn't matter).Application B is an sms application that i have made and contains one activity.This activity has a method called sendSMS(String number,String text).I want to call this method from application A and send an SMS without opening the activity(the GUI) of application B but just send an SMS in the background by calling just the method of the activity.Any ideas?

View 10 Replies View Related

Android :: Want Call Methods Of A Activity From Service

Apr 27, 2009

Is it possible to call methods of a Activity from service. I am running a thread from a service and i listening to some external event from that thread. I am not able to call methods from that thread. Is there any way to call methods from a thread.

View 3 Replies View Related

Android :: Want Activity State Without Override Each Methods

Nov 22, 2010

I want see the state of my activity (Pause Stop Resume etc etc) without override each methods like this: Code...

View 3 Replies View Related

Android :: Accessing Activity Methods Inside Click Listener

Aug 25, 2009

I have a click listener:
private OnClickListener onMyListener = new OnClickListener() {
public void onClick(View v) {
myMethod();
} };

And my Method:
private String myMethod() {
TextView tv = (TextView) findViewById(R.id.TextView1);
return (String) tv.getText();
}

When it calls this method, at tv.getText() it breaks in the debugger.
With this in the stack --
ViewRoot.handleMessage(Message) line: 1571
ViewRoot(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 3948
Method.invokeNative(Object, Object[],
Class, Class[], Class, int, boolean)
line: not available [native method] Method.invoke(Object, Object...) line: 521 ZygoteInit$MethodAndArgsCaller.run() line: 782 ZygoteInit.main(String[]) line: 540 NativeStart.main(String[]) line: not available [native method]

View 2 Replies View Related

Android :: Detailed Android Activity Lifecycle - OnAttachedToWindow()

Jun 14, 2010

I'm interested in android activity lifecycle and I would like to get more detailed description/documentation/reference than widely available basic (onCreate->onStart->onResume) one.

My need comes from realizing that starting new activity (Theme.Dialog styled) from onAttachedToWindow() greatly improves response time if comparing to starting it from onCreate(). I wonder how this onAttachedToWindow() fits into whole android activity lifecycle. Official API ref description "Called when the window has been attached to the window manager" doesn't help a lot.

View 1 Replies View Related

Android :: How To Have Shared Menu In Each (List) Activity Without Re-writing The Overridden Methods

Jan 5, 2010

I know that Android provides some useful methods to be overridden in order to define a menu:

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

I would like to have this menu shared by each Activity and ListActivity of my Android application. This is for having a standard menu in each (List) Activity that lets the user jump to every part of the application within a click.

Right now, the easiest way to achieve this is to copy-and-paste both methods in every (List) Activity of the application. I don't like this redundancy of code written.

Is sub-classing a reasonable choice? I've already seen that sub-classing one of my ListActivity does not work very well (threads that retrieve objects from a database are giving problems). Are there other ways to share a menu though Activities?

View 2 Replies View Related

Android :: When Do Synchronize Methods Or Use Synchronized Blocks In Methods In Android Game

Mar 14, 2010

I'm looking into writing simple graphics code in Android and I've noticed some synchronized() blocks. What is the reasoning behind this and how do I know when I should be "synchronizing" my code?

View 1 Replies View Related

Android :: Lifecycle Of Activities ?

Apr 5, 2010

In my application I have several activities, the main screen has 4 buttons that each start a different activity. So one of them is a search activity, once it searches it shows you a result activity. This result activity can be reached from other activities, so in general something like this:

Main activity -> Search activity -> Result activity

Main acitivty -> someother activity -> Result activity

Now, if I have reached this result activity and press back once or twice, and after that press the Home key it will show the Home screen. But if I want to get back to my application by holding the Home button and clicking on my app it will always go back to the Result activity, no matter which activity was the last one I was using. And if I press again back it will take me back to the Home screen.

If I try it again it will take me again to the Result activity. The only way to avoid this is to start the application by clicking on the app's icon. And this takes me to the last activity I was using and it remembers the state so if I press back again it doesn't take me to the Home screen, instead to the activity before it. To illustrate this:

Main activity -> Search activity -> result activity --back--> Search activity --Home Button--> Home Screen --Hold Home and select the app --> Result activity --back--> Home Screen

--Click application icon--> Search activity --back--> Main activity

Another thing that happens is that if I press the Home button while on the Result activity, and start the app by clicking the icon, it will take me to the activity prior the the Result one.

View 2 Replies View Related

Android :: What Is Rendering Lifecycle?

Sep 10, 2010

There's a decent amount of information out there on the Activity lifecycle. But I'm surprised how difficult it is to find a comprehensive description of the rendering lifecycle. By that I mean the order and rules by which a tree of nested activities, views, and drawables get to be sized and drawn to the screen, and the points at which a developer can modify rendering behavior.

View 1 Replies View Related

Android :: Strategy For WCF Server With Net Clients?

Apr 15, 2010

I am using WCF to write a server that should be able to communicate with .Net clients, Android clients and possibly other types of clients. The main type of client is a desktop application that will be written in .Net. This client will usually be on the same intranet as the server. It will make an initial call to the server to get the current state of the system and will then receive updates from the server whenever a value changes. These updates are frequent, perhaps once a second. The Android clients will connect over the Internet. This client is also interested in updates, but it is not as critical as for the desktop client so a (less frequent) polling scenario might be acceptable.

All clients will have to login to use the services, and when connecting over the Internet the connection should be secure. I am familiar with WCF but I am not sure what bindings are most appropriate for the scenario and what security solution to use. Also, I have not used Android, but I would like to make it as simple as possible for the person implementing the Android client to consume my services. So, what is my strategy?

View 1 Replies View Related

Android :: OpenGL Lifecycle Ends With A Crash

Feb 7, 2010

I am having difficulties with the lifecycle of the opengl context. While rendering my scene and the user hits the back button, home button or another application opens in front of my application, my app is still running in the background.

So when my application comes to the foreground later on (user relaunches it or the app that was opened on top of it finishes), my application crashes and leaves me nothing but a GL stack trace which i can't properly decipher.

For rendering i use the GLSurfaceView and therefore delegate the onPause and onResume. The crash happens on the first call to glDrawElements(..).

I have tried to reload my resource (geometry/textures etc.) on onSurfaceChanged but with or without reloading... The problem persists.

This behavior can be observed on all AVD versions of the emulator as well as on the G1.

Here is the gl stacktrace i get.

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

View 3 Replies View Related

Android :: Sprint Plan Savings Strategy

Sep 8, 2010

I have two EVO's, and I'm on the absolutely unlimited everything plan for both phones, which means that on a monthly basis Now, if I moved down to unlimited everything plan except for calls to landlines, I could save a lot. As I understand that plan, all calls to any cell phone are unlimited, but I would have a minutes cap on land line calls during the day on weekdays. So, can I use some kind of App to make land line calls during the day on weekdays and avoid the charge to my limited land line minutes? I would want an App that allows calls to be received and placed. I think there is an App for that, but it requires a new number to be registered?

View 13 Replies View Related

Android :: Any Benefit In Centralized Contact Strategy?

Jul 8, 2010

I know that Android will help merge/link duplicates, but I keep wondering if I should consolidate my contact management in one place. That is your contact management strategy? Centralized? Distributed? Where do you keep your contacts? My gut is telling me to keep them all in MS-Exchange, and delete all contacts in the other places, and just keep them updated in MS-Exchange... At the same time, since Android is a Google based phone, perhaps consolidating in Google/Gmail is the right answer...

View 4 Replies View Related

Game :: Best Strategy To Implement This Behavior In Android App?

Jul 2, 2010

In my Android app, I have some data that needs to be synced daily but also needs to be updated every hour when a user is inside the app. I have already implemented a service that gets called from an alarm for the daily update. I'm having a problem with developing a strategy to do the hourly sync. I could use an hourly alarm too and fire the same intent, but since your app can be killed at any time, there would be no way to cancel it (and since they use the same Intent, doing a cancel would cancel ALL alarms including my daily sync, so that's probably not good). The other option is to use a Timer that's set when inside the app, and have that fire my Intent when inside the app. I'm assuming all Timers get canceled when an app is killed right? But my app consists of several activities and I want the timer to work across all activities, how do I do that? I dont want to duplicate code - we're already using a subclass for Activity and ListActivity.

View 2 Replies View Related

Android :: Just In Section - Only Viable Strategy For New Application?

Sep 3, 2010

So I've recently released an application on to the Android Market. Whilst it was in the "Just In" section I was seeing decent download numbers, but since then interest seems to have dropped off significantly. I think now people can only find my app through a specific keyword search, which doesn't make me particularly confident about it ever becoming popular.

What can you do when your app has passed the 'Just In' stage but has not reached the 'Featured' stage? The majority of applications seem to be in this middle stage so I think other people must have a similar problem. It seems like the 'Featured' section just makes the popular apps more popular, and makes it really difficult for newer apps to ever catch up with them. Does anyone know if the situation with the Apple App Store is any different?

It seems to be possible to refresh your app and make it appear in the 'Just In' section again if you update it sometime after, but I can't find any real guidelines on this. Is anyone familiar with the specific rules for this, and is repeatedly riding the 'Just In' buzz the only viable strategy for a new app?

View 1 Replies View Related

Android :: Trying To Create A Service With Application Lifecycle

Jul 8, 2010

I am trying to create a Servicefor my application which will negotiate Bluetooth connections and data. I want this service's lifecycle to start and end with the Application, but still be able to have specific Activities listen for events that occur within this service (in addition an Activty should be able to call specific methods of the Service to write data or query connection state).

I started by creating AIDL interfaces for my callbacks and service, but I can't figure out exactly what I'm doing.

How is the best way to go about this? EDIT: To be clear, I do not specifically need (or want) more than one process for my application. Right now I don't have more than one; I'm just using AIDL because it is the only way I know of for a Service to communicate with an Activity.

View 1 Replies View Related







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