Android :: Any Best Practices For Starting / Handling Activities

Oct 23, 2010

Understanding how to declare activities in the manifest file, how to set the appropriate flags when starting them through intents, is quite challenging in all but the default cases. The combination of all these settings and flags is daunting. I've been developing for Android for over a year now, have read the application fundamentals and the reference guide for 'Intent' quite a few times and still I don't have a good grasp of which manifest settings or intent-flags should be used for starting activities in many situations (workflows). Is there some source/document that can explain certain work-flows (ways of navigation through activities and tasks), that shows examples of how to configure and start activities?

Android :: Any Best Practices for Starting / Handling Activities

Android :: Best Practices For Handling Passwords / Keys In Open Source Projects?

Sep 9, 2009

In my app, I'm taking advantage of a web-based API (the Sunlight Labs API) that requires an API Key.The project is also open source, hosted on Github. I want to avoid committing my API key into the codebase.I'd be fine with creating some other .xml file of special string values, and git-ignoring that file (while providing a .xml.example file to copy into its place), but I don't know the best way of doing that with the Android SDK.

View 4 Replies View Related

Android :: Practices On Droid To Keep Data Between Activities Deathes / Restarts For Whole App Session?

Jan 9, 2010

We're designing an Android app that has several activities which are working in a wizard like way - user should pass from the activity #1 to activity #5 to get to the final activity (#6).

Since we know an activity can be suddenly terminated by OS on low memory we used Application class as a static storage for keeping the data the user inputs on "wizard" activities and other data our app needs for the whole session.

Unfortunately we've discovered this approach fails - looks like the Application class instance is also can be killed by OS (this was specifically discovered on Android 1.6 versus 1.5). Are our expectations wrong on this approach (we think Application class instance always lives for the whole app session)?

So the question is - what is the best practices on Android to keep data between activities deathes/restarts for the whole application session?

View 2 Replies View Related

Android :: Handling Events From One Service For Multiple Activities

Jun 10, 2010

I have a class A which extends TabActivity and creates Activities B, C and D as tabs in its onCreate() function. Also, class A initializes another service handler class S which is responsible for establishing a connection to a service and implementing callback handlers for the service. Any of the Activities B, C and D should be able to receive events from the service and update accordingly. If I receive any event in class S from the the service then I want to call a function in Activity B which would be responsible to update the UI elements in Activity B based on the event received. You can assume that the user is in Activity B when the event arrives.

Can I call an activity function like the following in the stub handler for the callback in my class S -


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 :: Starting One Activity Brings All Other Activities In Same Process To Front

Apr 20, 2010

I have an application consisting of two activities (call them Display and Preferences) and one service which listens for incoming phonecalls. When it detects one it launches the Display-activity with a delay of 3sec in order to let the PhoneApp launch first. The Display- activity is transparent so the user can still use the PhoneApp as normal (ie answering the call) even though my Display-activity is "on top". So far so good

Now to my problem. Lets say that the Preferences-activity is active when there is an incoming call. The PhoneApp is launched on top of the Preferences-activity as expected. However when the Display-activity is launched the Preferences-activity pops up as well, hiding the PhoneApp. My question is if it is possible to work around this in some way? Since I do not want my Preferences-activity to block the PhoneApp and hence making it impossible for the user to answer the incoming phone call.

View 3 Replies View Related

Android :: Starting Activity Through Notification - Avoiding Duplicate Activities

Feb 24, 2010

I am currently showing a notification. When the user clicks this noticiation, the application is started. The notification persists, to indicate that the service is running in the background.


However, I have detected a case where a bug appears. If the user starts the application through clicking the normal icon, and while the activity is running clicks the notification, then a new activity is started without the earlier one exiting, the later being on top of the earlier. And that is not all: Further clicks on the notification will create additional activities and place them on top of those already running. How can I prevent this? Is there a nice check to do to see if a certain activity is currently being shown or is loaded?

View 1 Replies View Related

Android :: Switching Activities / Passing Data Between Activities

Jun 30, 2010

how to call BarCodeScanner, and return the value to a now, i have a toast that says "successful scan" and then i want to pass the result to a new activity. when i comment out my intent, everything works (minus the passing of data/switching of screen, obviously) but when i run my project as is, it FC's no errors reported by eclipse in code or xml. any insights?

View 2 Replies View Related

Android :: Best Practices In App UI Navigation

Jun 2, 2010

I am trying to learn how to do stuff in Android, and I'm not sure of the best way to build the interface.I've been working on porting an iPhone app, which uses navigation controllers and table views for looking at the different sections: basically, someone touches a cell in the table, which drills down to another table. when they touch a cell on that table it drills down to a webview that displays the information.I want to do something similar for the android app, but I don't know how, or if there is a better way native to Android. I've figured out how to use the webview to my purposes, but moving forward and backward in the table tree is unclear.

View 3 Replies View Related

Android :: Using MediaPlayer Best Practices

Nov 3, 2009

What is the best way to use the MediaPlayer when needed multiple times?

Reuse the instantiated MediaPlayer throughout the session? Or constantly stop() release() and instantiate a new MediaPlayer() ?

If I reuse I'm afraid the player could be in a bad state? What about performance wise? what's better? reuse or renew?

This is for using as a music player so one audio be present at one given time...

View 4 Replies View Related

Android :: Best Practices For Library With UI Component

Jun 26, 2009

My company is in the process of evaluating if we can add support for Android to our product. I am currently working on porting our existing J2ME library to the Android framework and I have a question regarding our UI component. Right now, we have a custom menu that we allow our developers to bring up on the device. On J2ME, we simply have a single call that the developer makes to enter into the menu and then we handle the rest. On Android, it seems the best way to handle this is an Activity. But I have a few questions regarding this approach including is the really the best way to do something like this? Second, if it is, if there are multiple applications on the device that are using our library, are there going to be conflicts with them all having the same Activity embedded in them? Is it possible to create an Actvity at runtime and use it directly? Would there be any side effects of going about it this way?

View 2 Replies View Related

Android : Best Practices To Be Followed When Designing Database?

Aug 30, 2010

I have to create a number of tables for caching some amount of textual data, obtained by reading XMLs. These tables need to be created only once - on the initial run of the application. The data in the tables should be cleared after fixed time period. There should be a class exposed to other classes that would allow CRUD operations on this database. Googling found me some links to tutorials for creating databases and Data Access logic.

I have some questions, please help:

How many DataBaseHelper(DBAdapter) classes should I have, I am guessing only one? Is it okay to have all the SQL DDL and DML statements, DB name, Table Names as static strings of this class?
How do I ensure that the tables are created only once?
Is it possible to clear the DataBase after a fixed time interval?
Are there any best practices to be followed when designing the database?
The data in the database is to be displayed in Lists. I have data in ArrayLists(created when parsing XML) as well as Database(after these lists are persisted). What adapter should I use to back the list up? Should I use ListAdapter or CursorAdapter?

View 2 Replies View Related

Android :: Good Practices For Building Web Application

Sep 10, 2010

can you advice me a book or something else containing good practices about how to build/structure a web application in a way that will be easy to extend it with an Android/iPhone version later.I am currently trying to get into Django so it will be nice if the practices are related to it.

View 1 Replies View Related

Android :: SQLite & Concurrent Access Best Practices

May 8, 2010

I have an application with several tables, each being updated by AsyncTask fired by different Activities and used by UI with SimpleCursorAdapter. Though i am not developping a game, I would like to avoid to interrupt the user as mush as possible. Has SQLite is not multiaccess proof, what is the best way of handling such situation?

- I consider adding lock from each DB open and to each close sequence but this seems quite subject to bugs - The solution i am using now is that each DB access (read/write) is done in UI thread (when AsyncTask completes, DB write is done typically in onPostExecute), but that means user is blocked for several seconds during the DB write.

Is there any better solution for that? Should i use a ContentProvider? when i read "Content providers store and retrieve data and make it accessible to all applications", this does not seems to be what i need. Any idea?

View 4 Replies View Related

Android :: Best Practices To Integrate Tips In Application

Apr 22, 2010

What are the best practices people have used to integrate help/tips in their application? One way I can think of is having html snippets in resources or assets - perhaps as html files - maybe as formatted strings. However, I think it would break down once an html file linked to another html file or an image or icon. I'm sure some of you have apps that are so wonderfully intuitive that they don't need any help. And I admire that. But I'm not making that assumption for my app.

View 6 Replies View Related

Android :: Best Practices For SQLite DB And Content Provider

Nov 12, 2009

My Android app is reading and writing to a local SQLite DB from a few different Activities and a Service. Pretty standard. But I'm not happy with the way I've got all the DB details stored as constants that I then use anywhere I access the DB. I've been advised to wrap the DB in a ContentProvider. Sounds good to me. While I'm refactoring my code, I figured I'd ask: What are your best practices for local DB data storage in Android?

Where and how do you store "CREATE TABLE" statements, column names, other SQL? Would you mind sharing a list of the classes you instantiate and what goes into each (ContentProvider, DatabaseProvider, DatabaseHelper...)? How do you coordinate the structure of your local Android DB with a server-side DB available through a REST interface? I realize I'm getting at the perennial "where's the Android object-relation-mapping framework?" question. For now, I'm mainly curious to hear how you structure your Android apps with what's available in the standard SDK.

View 4 Replies View Related

Android :: What Are Application Update Feedback And Best Practices?

May 20, 2009

I've published an Android applications on the Android market and now have an update to do. I want to know if any of you have already done that, and what experience can you share about it:

- How to manage version conflicts?
- What to do with databases?
- Can you make appear a message with "what's new" if it's an update, but nothing it's a new installation?
- Should you backup old data before updating, and how?
- Did you run into any trouble and how did you solve it?
- Can update be partial (like, just a patch)?

View 1 Replies View Related

Android :: Help A Newbie Learn Eclipse / Debugging Best Practices

Jul 25, 2010

I am a newbie to Android and the Eclipse development environment and would like some advice on best practices for debugging my apps when they throw a Force Close.I have researched ADB, however, I can not get this to interact with my phone even though I have explicitly turned debug mode to true on my test handset.Obviously Android comes with a LOG method which I have seen utilized in many example apps, can someone please explain how to review these logs quickly and how to setup logging appropriately to determine the cause of a Force Close (always occurs when I push the Home button).Any advice on debugging effectively in Eclipse would be much appreciated!

View 2 Replies View Related

Android :: Best Practices For Snappy Mobile I / O On Slow Connections?

Aug 12, 2010

I have a mobile app, which is pretty data driven, though only through text and images. In the current version each click or touch requires pulling new data from the server (appache/php). With network delay this easily takes 1-2 seconds for the first content to appear, which is far too long. I have heard about and considered the following options, but are not sure if some of them might be counter productive, or if I have left something important out?

Download all data from the start, in a big bunch with a loading screen? Run a prefetching thread, predicting and downloading data the user might want, in the background? Keep the connection open to the server at all time? Load different parts of the data in different connections in parallel? (Similar to facebook) Use heavy data compression? A comprehensive article on the matter would also be a good answer.

View 1 Replies View Related

Android :: ListView Large Number Of Items - Best Practices

Oct 20, 2010

I am working with a ListView, custom adapter and a large number of items. I read in a book for Android that is was more efficient to use what it called the holder pattern. That is to create a wrapper class for each view in the list view that cached the objects in the view so as to avoid calls to findViewById because those are supposed to be expensive. My question is what is better? To have 50,000 objects GC'd every time the user scrolls or to make the 4 or five calls to findViewById per view? Below is my implementation of what the book suggested.

@Override public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView; if (view == null) {
final LayoutInflater inflater = (LayoutInflater)
view = inflater.inflate(R.layout.survey_item, null);
view.setTag(new SurveyItemWrapper(view));
} bindView((SurveyItemWrapper) view.getTag(), position);
return view; } private void bindView(SurveyItemWrapper surveyItemWrapper, int position)
{ final SurveyedItem surveyedItem = surveyedItems.get(position);
surveyItemWrapper.getCube().setText(String.format("%9.2f", surveyedItem.getCube()));
surveyItemWrapper.getShipping().setText(String.format("%d", surveyedItem.getShipping()));
surveyItemWrapper.getNotShipping().setText(String.format("%d", surveyedItem.getNotShipping()));
} private class SurveyItemWrapper { private TextView description;
private TextView cube; private TextView shipping;
private TextView notShipping; private View view;
public SurveyItemWrapper(View view) { this.view = view;
} public TextView getDescription() {
if (description == null) { description = (TextView) view.findViewById(; } return description;
} public TextView getCube() { if (cube == null) {
cube = (TextView) view.findViewById(;
} return cube; } public TextView getShipping() {
if (shipping == null) { shipping = (TextView) view.findViewById(;
} return shipping;} public TextView getNotShipping() {
if (notShipping == null) { notShipping = (TextView) view.findViewById(; } return notShipping; } }

View 2 Replies View Related

Android :: ListView ArrayAdapter Data Updates Best Practices

Aug 26, 2010

I have an activity with multiple list views that are continuously receiving new values form a socket thread, another thread parses the data and updates the array adapters, then the ui thread calls notifyDataSetChanged() to cause the list to refresh.

My issue is that im refreshing all the list a couple of time a second, this causes the UI to be very laggy when some animations need to happen.

I was wondering what the best way is to update multiple lists with multiple value changes every second?

View 3 Replies View Related

Android :: Best Practices For Creating Multiple App Versions From A Single Codebase?

May 4, 2010

Are there any viable approaches for creating multiple .APKs out of a single codebase? The apps may share the same code, but they could have different manifest files, different resources, or different external libraries (for example in an app with both free and paid versions, the free version could have a library for display ads). Ideally, this would be a single Eclipse project, with a way to specify which app to build/debug, and possibly a command line way to batch build everything.

View 16 Replies View Related

Android :: Background Practices (Interact With Network And Check Location)

Aug 27, 2010

My application needs to perform some activities in background (like interacting with the network and check the location and some other stuff), having or not the main activity visible. Which is the best way to achieve this? Should I write a service for each kind of job? Or just one service that performs everything? I am aware that I will need to launch threads / asynctasks in any case because the service runs on the same thread of the UI, but maybe having several services is a more clear and readable structure.

View 7 Replies View Related

Android :: Practices To Design Webservices For Mobile (particularly Droid) Apps?

Oct 13, 2010

What are the best practices to design webservices for mobile (particularly Android) apps?
Personally I'm focused on using JSON (and not XML) and I try to make it the less verbose I can. But I'm probably missing a lot of things.

View 4 Replies View Related

Android :: Good Practices For Organizing Files On Storage SD Card?

Jan 7, 2010

Are there any guidelines where should my app store resource files downloaded from Internet?

View 3 Replies View Related

Android :: Best Practices For Targetting A Wide Range Of Devices And Screen Sizes

Aug 31, 2010

As you know android today is many versions many constructors, many screen sizes,...

it's quite difficult for developers today to write programs that targets a big part of devices.

What would be THE developer must-know practices for this ?

View 4 Replies View Related

Android :: Best Practices For Developing Bigger Applications On Android

Nov 24, 2010

I've already written some small Android Applications, most of them in one Activity and nearly no data that should be persistent on the device.

Now I'm writing an application that needs more Activities and I'm a bit puzzled about how to organize all this. My app will download some data parse it show it to the user and then show other activities depending on the data and the user interaction. Some of that data could be cached, some of it has to be downloaded every time. Some of that data should not be downloaded freshly at the moment the orientation changes, but it should on the moment the activity is created...

Another thing I'm confused about are things like a httpClient. I now for example create a new httpclient for every activity, the same thing for locationlisteners.

Are there books, a blogs or documentations with patterns, examples and advice on organizing larger apps build on android? Everything I found until now are get startet tutorials leaving me alone after 60 lines of code...

View 2 Replies View Related

Android :: Best Way To Handling XML

Sep 2, 2010

Android device is much slower and have much lower memory compare to PC/server, So what is the best way to handling XML in Android? And I have a set of very complex xml needed to parse. both SAX or DOM will cause too much code. Anybody have good suggestion? I want to make it clean and fast.

View 4 Replies View Related

Android :: Exception Handling ?

Aug 9, 2010

I read somewhere not to exception handle when developing in Android, is that true?

If one does need to exception handle are there any logging tools for 2.1 and above?

If shouldn't exception handle, why is it not recommended to at least use the below?
try {body-code} catch (exception-classname variable-name) {handler-code}

View 3 Replies View Related

Android :: Try/except Handling For PostMethod?

Apr 6, 2010

I'm using a PostMethod, and wondering what try/except handling I should use.

The exception handling here seems to work okay in most scenarios, but is there anything I might be missing? In particular, I'm wondering whether this handles the network connection going down midway through the upload.


View 2 Replies View Related

Copyrights 2005-15, All rights reserved