Android :: Keep Threads And Views Alive Between Activities

Sep 13, 2010

Trying to understand the Android framework model. I have an application that needs to have several threads running. On thread gets GPS fixes, another picks up GPS fixes and pushes them to server, and yet another occasionally polls a server for dispatched orders. Some of these threads update status Views as well.

Since I am new to Android, the application framework model hasn't clicked for me. Where are these threads started? Right now I start the threads in the initial Activity, but if I understand it right, once that Activity goes invisible it is stopped. Furthermore, I have to track GPS and network statistics so that I can have a View which may (or may not) be the active View.

Android :: Keep threads and views alive between Activities


Android :: Keep FTP Connection - Or Any Connection Object - Alive Between Activities

Oct 27, 2010

I'm coding a very basic FTP client on top of my application and I have 2 activities. The first one is the file explorer and the second one is the image viewer. Once I click on the image filename on the explorer, I want to pass the connection to the other activity to handle extra stuff. Basically, I want to keep the same org.apache.commons.net.ftp.FTPClient object (which handles the connection) alive in-between the 2 activities. I know I can't pass an object inside an intent so I don't know what my best bets are.

View 1 Replies View Related

Android :: Activities Vs Views

Jul 8, 2010

I am working on an Android app that has multiple screens the user will need to navigate between and I am curious what the best practices are when switching between those screens. I am torn between creating a new Activity for each screen and simply changing the view (setContentView(R.layout.whatever)). The screens all share at least some variable values so I'm leaning toward changing views and using class level variables, but I'm worried a single activity could become very large and confusing with logic for multiple screens in a single file. I'd like to keep the code clean and separated, but I also don't want to be passing several variables around between views if that isn't needed.Being new to Android development, I'm hoping some more experienced members of the community could share their thoughts and let me know how best to handle it

View 2 Replies View Related

Android :: Activities And Multiple Views

Aug 3, 2010

I start a browser and from the browser,I start a video which occupies only a small part of the screen,say the bottom right corner.

Now the browser will be pushed to the 2nd position in the window order and Video will come to the first position. Is it possible that browser can have the control for active window and receive the key events though the video is the Top Most window.

View 4 Replies View Related

Android :: Caching Views And Activities

Apr 24, 2009

I've got a activity showing the user a list of songs to play, and when he opens a song I launch an activity which embed a player.

My problem is that when i finish playing i call "this.finish()", but when the user reopen the player, the "onCreate" is launched and it seems that the GUI is building itself "again".

I've tried to not call "this.finish()" and call the Activity.startActivity on the father, but with this way, when I clic on the "back" button on the emulator, I get all the players playing in the same time (they still exist).

So my question, is there a way to make an activity "a singleton" or to freeze it to be retrieved later (It can't be able to retrieve it with "back" button) or a way to cache all the constructions so to not have to do it again ?

View 2 Replies View Related

Android :: Using Different Activities For Different Views In ViewFlipper

Jul 16, 2010

I am developing a Music Player and I have a view flipper to control all the artist view, album view, so on and so forth. What I am doing now is that I have list view in each view of the view flipper. However, I do not want to put all my codes inside one activity but rather, to have different activities for each view. Is that possible to implement?

View 1 Replies View Related

Android :: How To Use Multiple Map Activities / Views?

Jul 31, 2010

My situation is the following: I have written one MapActivity class that is able to display a set of places as well as single places. On startup, the application creates an instance of this MapActivity and displays multiple places. If the user clicks on a certain place, then a new Activity is launched that shows the details of the selected place. This activity has a menu item that allows the user to view the place on a map - this causes that a new instance of the MapActivity is created, except that now only this single place is displayed.

The problem now is that if the user navigates back to the first MapActivity (the one that shows multiple places) the tiles won't be loaded anymore + sometimes OutOfMemoryErrors are encountered. According to the Android JavaDocs, it is only possible to have one MapActivity per process. However, I don't want to define my MapActivity as a singleInstance/singleTask, since the user should always be able to navigate back to the first MapActivity that shows multiple places. I have seen that the Google Places app (which has come with Google Map 4.4) for Android uses multiple MapActivity instances. How is this possible?

View 1 Replies View Related

Android :: Activities And Views Related In Platform

Jun 10, 2010

I am attempting to learn how to develop on the Android platform but do not quite understand the relationship between Activities and Views, because according to the documentation an Activity is almost always linked to a UI object that the user can interact with, but if this is the case where does the whole idea of Views come in?

View 1 Replies View Related

Android :: Multiple Activities Or Switching Views Manually

Jan 15, 2010

I have developed some apps for Android, and this questions stays always:

How should I structure my UI? Should I launch activity after activity and leave the phone to make the "back" button, or should I choose more optimized, but more complex to implement, way with switching manually Views and then manually doing the "Back" button functionality?

View 4 Replies View Related

Android :: Why Add Child Activities To TabActivity Instead Of Simply Using Views

Mar 17, 2010

I've been programming in Android for two years now and just joined an Android project where they are using a TabActivity to host multiple Activities. It's unclear why this is better than rewriting the TabActivity to simply use Views instead.

TabActivity extends ActivityGroup which means TabActivity can host both Activities and Views. But what's the use of this capability? I was under the impression that Activities should be treated as individual screens of an application.

In short, what is an example use case where it's recommended that TabActivity should host multiple Activities rather than multiple Views?

View 4 Replies View Related

Android :: Updating Views Of Sub Activities Of TabActivity From Background Process

Jul 25, 2010

I am using a TabActivity (Main) with 3 TabSpecs

I am using Intents for the content of the 3 Tabs

TabA, TabB, TabC for example.

All these tab activities use common data that is stored in SharedPreferences

In the Main TabActivity I have an options menu which has a refresh option.

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

This refresh uses an AsyncTask (updateCommonDataFromWeb) to reload the common data from the web.

I need a way to tell the 3 tab activities to refresh their views and rebuild their content from the newly downloaded data.

When the tab activities are first created they load the data from SharedPreferences like so:

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

I thought about making a common method on each of the tab activities
like.... reloadViewData()

I thought maybe I could use the activity manager from the Main TabActivity to get the activity of the current tab like so:

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

Unfortunately i cant get this approach to work, whilst activity is the correct instance its an Activity instead of a TabA,TabB or TabC

Maybe i've completely taken the wrong approach to the whole thing.

I have also read alot about not using Activities for tab content instead using views.
However I dont know what view to use to replace my <RelativeLayout /> as i cant use my R.layout.* as views.

View 2 Replies View Related

Android :: Pros - Cons Of Multiple Activities In An App Vs One Activity - Multiple Views

Aug 16, 2010

Are there design guidelines to help decide if an application with multiple views should be designed with multiple activities or just one activity and control the back button itself.

I've tried both. My most complex applications using one activity per screen. However, now that I'm successfully written an app with just one activity and handling the back button myself, I don't see any compelling reason to use multiple activities. The one activity application is much simpler and more straightforward.

What advantages of multiple activities am I missing?

View 8 Replies View Related

Android :: Use Multiple Activities Or Multiple Content Views

Feb 18, 2010

I'm working on an application using xml layouts.

I wish to know which is better:
1. Use few activities and change its contentview
2. Use an activity for each 'view' needed

If both works, in which case which option would be better?

View 1 Replies View Related

Android :: Views And Their Child Views - How To Avoid The Ugly - Boxes - When Child Views In A View Has Another Color Than Background

Jan 6, 2010

I have a simple ListView and on that ListView I have placed a number of custom defined Views. The CustomView has ImageView and two TextViews.

The CustomView also has a "stateful drawable" as background, so that the background image (a 9-patch) changes if you press the Row in the ListView. When pressing the Row, the background image changes to a Red-ish thing.

The problem is that when the background changes from the default greyish, all the Views in the CustomView (ImageView and TextViews) still have their greyish background and thus creates very ugly greay boxes on top of the now redish background.

What is the best way to solve that problem? I hoped that such things were handled automatically (as it is done in for example .NET), but I was wrong it seems.

View 1 Replies View Related

Android :: Application Threads Vs Service Threads

Apr 13, 2010

What are the advantages/disadvantages in placing a lengthy network access code in a thread in an activity or a thread in a service? How would it affect the application? I am writing a streaming audio player and from what I've read so far putting the code in a service will still end up blocking the application so a new thread is needed, does anyone know if it makes more sense to put this piece of code in a service.

View 1 Replies View Related

Android :: How Can Update The All The Views Inside A TabHost When Pressing On A ContextMenu Item From Within One Of The Views

Nov 16, 2010

I am implementing a music player application in Android. My play list selection screen is implemented as a tab selector widget which contains a ListActivity inside each of the tabs: Artist, Albums, Songs.
I want to update the ListView in each of the ListActivity when I delete an item from any of the lists.

i.e. When I long press an item in the Artists list a context menu is drawn with "Delete Artist"
And it should delete all the songs from this artist in the Songs ListView, delete all the albums by this artist in the Albums ListView, and finally delete the entry for the artist in the Artist ListView.

Each of the ListActivity has its own fillData() method, which updates the ListView when the button in the context menu is pressed.

How can I call the fillData() method of the Albums ListActivity after I update the ListView inside of the Artists ListActivity?

View 1 Replies View Related

Android :: How To Make Use Of Views Defined In Layout XML File As Template To Create Views Programmatic Way

Feb 28, 2010

I want to populate a table, defined in layout xml file through the programmatic way. I have define Table with a single row defining its header, with all the attributes set. Now i want to know a way so that i can just replicate that header row in the table with new content.

I tried using inflator inflate(int,view) method, but at runtime it showed up with error.

Here is the XML code for the layout file defining the table

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

View 1 Replies View Related

Android :: Switching Views With RadioButton And Saving Views In Bundle

Mar 6, 2010

I have the following XML code:.................

The idea is to change the views, whenever I press one of the radio buttons. When I press a button the first time everything works out fine, but the second time I press a button, I get an IllegalStateException, and I can't quite see why I'm getting this.

Also, the Activity seems to set all my global variables to null, which is why I have to create them every time I switch from portrait to landscape or vice versa. So I would like to know if there is a way I can save my views in the Bundle, or any other way in which I can permanently save my views, so I don't have to add or create them every time, I flip the phone. And whenever I flip the phone, it seems that it rereads the main XML file, causing the RadioGroup to be set to 2D even if the 3D button is checked. This is because I've said the 2D button to be checked from when the app is first created, but I would like to also save the state of that RadioGroup.

View 5 Replies View Related

Android :: How To Align Views In The Middle Of Another Views Baseline

Jun 16, 2010

How do you align views relative to the "middle" part of another view? I think it is best explained with a pic of the UI I'm trying to create in android.

View 2 Replies View Related

Android :: Switching Activities / Passing Data Between Activities

Jun 30, 2010

how to call BarCodeScanner, and return the value to a field.so 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 :: Do Root Views Of An Activity In Android Have Any Prior Knowledge Of The Child Views That Will Be Loaded Into Them

Jan 25, 2010

Is there any way to query a root view of an activity for all of its child views even before the root view or its children have been inflated? I guess what I'm looking for is whether a view knows ahead of time what children it will have before it gets inflated, and can I get that list in some way. Bizarre I realize, but I think it will help me with some unconventional automation testing I'm working on. I haven't found anything in the API like this.

View 1 Replies View Related

Android :: Programmatically Add Views To Views

Mar 7, 2010

Let's say I have a LinearLayout, and I want to add a View to it, in my program from the Java code. What method is used for this? I'm not asking how it's done in XML, which I do know, but rather, how can I do something along the lines of (One View).add(Another View) Like one can do in Swing.

View 2 Replies View Related

Android :: Are Processes Kept Alive When Nothing Is Being Done?

Feb 8, 2010

I have an app which declares a BroadcastReceiver, the receiver gets the broadcast, does what it needs to, then ends ensuring that everything is tidied up as needed. When I examine the system through the DDMS view in Eclipse the process for the application is still running after the receiver has completed. I've even boiled it down to a simple test case which gets a shared preferences instance from the context, checks a random setting, and then exits, and, when run on the 1.5 emulator (which is the minimum supported OS level) the process is still hanging around.The reason this is an issue is memory usage (which shows under DDMS as around 2MB).I've had queries about why the application still uses up memory even when it's not doing anything, so, my question is; Is this behaviour normal, or have I missed something that would make the process exit?

View 9 Replies View Related

Android :: How To Keep Service Alive?

Jul 19, 2009

Is it possible to keep service alive even if the foreground app does not run anymore? My app consists of a foreground app (UI) and a service that should keep running in the background until it is being explicitly stopped by the user (similar to a music player). The problem is that if the user opens other apps, my foreground app is being killed by the system (makes sense) but then also the service is being killed by the system (does not make sense).

View 16 Replies View Related

Android :: TCP (XMPP) Keep Alive And TMobile

Apr 14, 2009

I just wondered which frequency is OK to send whitespace keep alive packets onto a TCP connection to keep it alive on a T-Mobile 3G connectivity (the use case is to maintain an idle XMPP session alive). On SFR in France, we are disconnected if idle for 3 minutes, but I guess T-Mobile's timeout is lower. By the way there is a bug in the Smack library, the "keep alive" setting is not enforced, e.g. if you set it to 30s, in the worst case the whitespace will not be sent until the double of this time (60s).

View 4 Replies View Related

Android :: Keep Connection Alive When Screen Goes Off?

Oct 22, 2010

is there any way to keep my connection alive when the screen goes off? my xmpp connection is disconnected due to ACTION_SCREEN_OFF event,

View 3 Replies View Related

Android :: Force Application To Alive?

Jul 13, 2010

I am writing an application to do fileobservation which can be done. Is there any way I can make the application to run in the background without killing it? Unless user restart the phone. Is there any way to do it?

View 9 Replies View Related

Android :: Phonestatelistener Dies After While - Kept Alive?

Dec 7, 2009

am developing an app that needs to track incoming calls. I have set up a phonelistener which is launched form a service like so

TelephonyManager tm = (TelephonyManager)getSystemService (TELEPHONY_SERVICE); tm.listen(mPhoneListener, PhoneStateListener.LISTEN_NONE);

This seems to work for a while but then fails to fire after - say an hour. I have tried relaunching the listening in a timertask every 60 seconds but this does not seem to work. Is there a way of keeping a listener alive for a long period of time. I can only assume the system is garbage collecting it.

View 2 Replies View Related

Android :: Make Service Always Alive?

Jun 30, 2009

How do I make my service always alive?? If my service gets killed because of an exception or if the VM kills my service on low memory, How do I make sure that my service is always running?

View 14 Replies View Related

Android :: How To Keep Mobile Network Alive Even If Screen Is Off

Dec 10, 2009

I want my service keeps network connection alive even if user presses the power button to shutdown the screen. As I have tested, socket will return exceptions and through CONNECTIVITY_ACTION intent, i know EXTRA_NO_CONNECTIVITY is true. So can current Android keep connection not closed when screen is off?

View 3 Replies View Related







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