My application is full of Activities that are absolutely dependent on a connection to a financial data server (trading system). The Activity has the following requirements:
- a user needs to be logged into the server in order to have permission to view data - the Activity has to query methods on the loggedOnUser to find trading permissions - the Activity has a large amount of UI view code that depends on extracting values from trading orders If the connection to the server, which I hope to implement in a Service, is down or not connected yet, what is the best practice for implementing the Activity, for login permission purposes, and also to avoid NullPointerExceptions when asking for data through methods that may return null? And what is the best practice for publishing Service data to the Activity? I see a couple of solutions - write the Activity so that it starts up no matter what the status of the connection/Service, and in all of the Activity methods that deal with data to guard agains NullPointerExceptions (i.e. assume anyhing coming from the server could be null at any time - or, in the onCreate() of the Activity, check for the existence of a fully connected Service. IF it's there, allow the Activity to start and assume that all data is non-null. if the Service disconnects, finish() the Activity and go to an interim Activity saying, "reconnecting please wait...' restart the Activity when Service is connected again. IF the Service is NOT viable on Activity onCreate(), finish() the Activity in onCreate() and start the temporary "connecting please wait" Activity, and when Service is viable again, start the main Activity back up. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

