Android : Multiple Handlers Design In An Activity Failed

May 14, 2010

This question is related to an existing question I asked. I though I'll ask a new question instead of replying back to the other question. Cannot "comment" on my previous question because of a word limit. Marc wrote - I've more than one Handlers in an Activity." Why? If you do not want a complicated handleMessage() method, then use post() (on Handler or View) to break the logic up into individual Runnable. Multiple Handlers makes me nervous. I'm new to Android. Is having multiple handlers in a single activity a bad design ?

I'm new to Android.My question is - is having multiple handlers in a single activity a bad design ? Here is the sketch of my current implementation. I've a mapActivity that creates a data thread (a UDP socket that listens for data).

My first handler is responsible for sending data from the data thread to the activity. On the map I've a bunch of "dynamic" markers that are refreshed frequently. Some of these markers are video markers i.e., if the user clicks a video marker, I add a ViewView that extends a android.opengl.GLSurfaceView to my map activity and display video on this new vide.

I use my second handler to send information about the marker that the user tapped on ItemizedOverlay onTap(int index) method.The user can close the video view by tapping on the video view. I use my third handler for this. I would appreciate if people can tell me what's wrong with this approach and suggest better ways to implement this.

Android : Multiple Handlers Design in an Activity failed


Android : Multiple Handlers In A Single Activity

May 13, 2010

I've more than one Handlers in an Activity. I create all the handlers in the onCreate() of the main activity. My understanding is the handleMessage() method of each handler will never be called at the same time because all messages are put in the same queue (the Activity thread MessageQueue). Therefore, they will be executed in the order in which are put into the Queue. They will also be executed in the main activity thread. Is this correct ? Code...

View 1 Replies View Related

Android :: Activity Bind To Service - Multiple Thread Design

May 28, 2010

A new question about android and services. Currently I'm developing a App that should send images to a server. It should also be possible to send more images parallel. I made a service that creates for every image a new image. The activity can bind to that service and gather information about the progress. I want to show the current status for every image in a notification (and when the user clicks a notification, an activity with the progress for that image should be shown). But I get several problems with that approach. There are errors with binding, the notification pending event starts the activity completely new, so I lose information about currently sending images and so on. How I could design in a appropriate way.

View 1 Replies View Related

Android :: General Direction For Bluetooth SPP App With Multiple UI Activities - Multithreading - Handlers)

Sep 15, 2010

I am writing an Application that has multiple layouts with buttons. I have set up onClickListners for the buttons. Some buttons will change the activity and bring up a new layout with new buttons, and others will send outgoing SPP strings over Bluetooth. The strings will be defined in an XML file and will not change (serial commands).I can hard code the MAC address of the Bluetooth Server and only need to send data, not receive.

I am looking for some general guidance on the direction to go as far as setting up my Bluetooth connection and outgoing transmissions. I have looked at the BluetoothChat example extensively but do not have any good resources in the case of multiple activities.

-Do I use a separate activity to manage all Bluetooth transmissions and connections and create handlers for every case where I would send a Bluetooth message?

-Should I add Bluetooth connection+transmission threads in every activity (seems like i would run into issues losing the connection when changing activities)?

-Can I use handlers that are not class specific where the BluetoothService Activity could send whatever was prompted by the active/current activity?

-Could I just hard code all strings to be sent in the BluetoothService Activity and the UI activity could prompt the BluetoothService Activity to send the requested string based on the button click?

View 1 Replies View Related

Android :: Starting Activity With FLAG ACTIVITY MULTIPLE TASK To See Multiple Instances

Feb 2, 2009

I am trying to launch an activity from another activity .. Within the com.android.SingleLauncher..

I have activity launch code as ..

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

I have set the android:multiprocess="true" in the AndroidManifest.xml of TargetSL I don't seem to see the multiple instances of TargetSL, which i am expecting ..

All i see is 2 process, where i was hoping to see an instance of TargetSL, for each launch that was invoked by the singleLauncher!

View 3 Replies View Related

Android :: App Design For Multiple Data Connections

Oct 18, 2010

I am working on developing an application that requires me to establish multiple client-server based connections. Connection can be of two types where the Android device can be a server or a client. I can have up to 6 - 8 connections. Once the connections are set-up they need to be running in the background and are not typically affected by UI actions.Since each connection can be blocking, I am wondering what is a good away to design this app. Should I have two services for handling the server and client connections? Each service could have a "connection manager" that can spawn new threads when necessary. Or does creating two services even help? I presume spawning new processed would not be good as they will be expensive. Is this correct? I would appreciate any suggestions. Also, if this use case is not typical please let me know if you need more information to make any recommendation.

View 2 Replies View Related

Android :: Supporting Multiple Screens / Most Optical Way To Design Application?

Jun 9, 2010

I have read the topic about supporting multiple screen size as well as different DPI. I am wondering which of the following way is better in supporting multiple screens:

1. Have different layout for different screen size (stretch the images)
2. Have different set of graphics for different screen (use the same layout)
3. Have different set of graphics and different set of layout for each of the screen

Which way is the easiest? And which way is the most optical way to design? Or is there another better way?

View 2 Replies View Related

Android : UI Design Suggestions For Display And Switching Between Multiple Layouts

Jun 26, 2010

I'm trying to create an app that offers the user 3 different kinds of layouts. The only common portion for all 3 would be the TextView (located at the top) that would display information specific to the currently displayed layout and 3 buttons to select the required layouts.

Is there some way we can create this UI in XML to keep only one constant part(the upper TextView) and dynamically display any one of the 3 layouts below it?
Would it be better to create separate XML's for each of the layouts (each including the upper TextView in them)?
OR would doing this via code be better?

Fast switching between the 3 layouts is important. TIA

[EDIT 1]
Actually they are 3 different layouts, with several "child" layouts and views within each of them. Could a ViewFlipper be used for switching between these? I was thinking that a ViewFlipper was only for switching between View elements?

I do have them in individual XML's right now but am looking for some way to load and unload them fast. Not sure how to do the hiding thing, will try reading up on that. [/EDIT 1]

View 2 Replies View Related

Android :: Activity Design Advice

Mar 3, 2010

I have a service running that grabs the users attention with a notification. What i would like to happen when the user clicks on the notification is for it to launch a dialog box. The "proper" thing to do is to launch an activity in this way, so is there a way to get an activity to launch with out filling the screen? So it looks like a dialog box?

View 5 Replies View Related

Android :: Design Clarification In Android List Activity Vs Activity

Mar 25, 2010

I have a simple question. I am trying to design a simple Android app, which based on keywords searches something and shows a listing view of results. Currently it merely searches SMSes in the cellphone.Here are some of the things I am faced with: I have a simple first page with a textbox and a submit button. It's rendered by "Activity" inherited class call SMS Finder.once I have the results present with me, I want them to be binded to a list view. Showing preview text to limited characters, say 20 chars. Clicking on the same should "ideally" open the inbox (or outbox or whatever) and open the SMS, however that meant I cannot come back to my app easily. So I would rather open the whole SMS in my own app. So clicking on the app should open the SMS in a new screen with complete message, sender info etc. Few questions here, For generic Android phone apps, what are the best practices to make UI as compliant to as many phones? Like what kind of views should I use?

View 1 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 :: How To Design Activity And Service Writing To Same Table?

Jun 14, 2010

I have an activity which starts a (intent)service. Both access the same DB and potentially write to the same table. What design pattern would you recommand to avoid concurrency?

View 2 Replies View Related

Android : Design - Launch An Activity Based On Type Of A View

Nov 4, 2010

Should I create a Listener within a BaseAdapter or should I pass it in? I have 4 classes that inherit from a base class. I pass the Adapter a list objects.

The Adapter is eventually used with a ListActivity I want to create a View based on the derived class and I want them to launch an Activity based on the type of a View. Currently I create the intent and Listener in the BaseAdapter. Is what I'm doing a good pratice?

View 1 Replies View Related

Android :: How To Clear Activity Stack If Using Same Activity Multiple Times?

Mar 3, 2010

So I have an app with Activity A. The layout on the activity is dynamic genearted. So it's possible that on Activity A a user hits a button that goes to "A" and the new page looks different, then a user clicks another button to go to "A" again. Now I have 2 Activities in the history stack. A, A, and currently on A. Is it possible that if a user clicks a button that the whole Activity stack is cleared in a scenario such as this?

View 5 Replies View Related

Android :: Android Service Design - Start With Activity Or When Needed?

Nov 24, 2010

I'm an android noob that is looking for some advice on how to properly use a service in Android. I am building an app that will connect to a server on the Internet to get a data stream via TCP. That data then needs to get send out to another device that is connected via a bluetooth serial port. I want this to continue to function in the background while the user looks at a different activity. The app will be a NTRIP client, which pulls real time RTK correction data from the Internet and sends it to a RTK GPS receiver that I connect to via bluetooth. The data rate will be about 500 bytes/second. The user interface is a single button to connect or disconnect the data stream and some text to show status of the GPS receiver. There are also a few settings that will need to be configured by the user such as the IP/port of the server to connect to and the bluetooth device to communicate with.I think I need to have the main activity spawn a local service, and then have the service spawn a thread for the TCP stream and another thread for the bluetooth connection. Does this sound right? What is the best model for the service in this scenario?-Start(bind) the service every time the activity starts, and have the connect/disconnect button send commands to the service to start/stop the threads. If I go this route, the service will continue to run after the user disconnects and goes to another app. The service would need an inactivity timer to terminate itself.-Start and stop the service when the user presses the connect/disconnect button. The service only runs when data is moving. If I do this, the activity will need to see if the service is running when the activity starts, in order to know if it should bind to the service or tell the user that the link is disconnected.

View 2 Replies View Related

Android : NewInstance Failed / Cannot Instantiate A Sub Activity

Jan 22, 2010

I cannot instantiate a sub activity. In the logcat I see this line: 01-22 15:14:38.906: DEBUG/dalvikvm(411): newInstance failed: no <init>() This is the line in dalvik that generates that logcat. Here is the action I take to activate the activity in a timer handler. Code...

View 1 Replies View Related

Android :: String Failed / Bundle It Correctly To Other Activity In Droid?

Aug 15, 2010

The integers pass successfully but string is failed. What's the problem?

Result:
http://img580.imageshack.us/img580/2079/app2v.jpg

View 1 Replies View Related

Android :: Design Of Android Activity

Jun 27, 2010

Alice has to answer three questions. After she answered the questions she gets a dialog that lists the question and answers and there's a button to save the answers to a database.

At the moment I think that the design should be three classes: Master, Question, Summary.

Master calls Question with an intent that includes the question text of question 1.
After Alice inputs her answer the Question returns the answer to master via an intent.

Repeat two times.

Then Master does processing of the questions and calls Summary via an intent.

Is this kind of design recommendable in Android? Is it possible to have such an Master activity. If so, how can I allow a running master activity to listen to intents?

View 1 Replies View Related

Android :: Sorting Out Different Handlers ?

Nov 2, 2010

I want to create multiple handlers that gets triggered based on users selection, but this handlers implement the same runnable method. the only difference is that they call different postDelayed() method. how do i go about achieving this without rewriting the same code for the runnable? i am still not clear about how the handleMessages() works and if it can be used for this?

View 1 Replies View Related

Android :: GUI Design - Mockup Design Tool For Android Application

Nov 23, 2010

I am going to develop an Android Application but before developing it i needs to have MockUp for the Android Application,so is there any way to design MockUp/GUI Design tool for the Android Application?

I know about DroidDraw tool , but i think it is not the exact way to prepare Mockup for the android application.

I have already referred this SO Question , but overthere i just found all the tools for the I-Phone only. So please feel free to share with me if you have/found any !

View 3 Replies View Related

Android :: Want To Use Handlers To Display Images One By One?

Jul 16, 2010

I want to display the imageviews one by one that means if image1 is displayed after 2 sec another image is displayed .but i don't want to use threads why because my application is small.I want to use handlers.So give me some suggestions.

View 1 Replies View Related

Android :: On What Thread Event Handlers Executed?

Nov 7, 2010

On what thread are event handlers (like onAnimationEnd, onTouchEvent, onKeyEvent, onClick) executed? Are they called sequentially or can two handlers may execute simultaneously?

View 1 Replies View Related

Android :: ExpatReader DTD Handlers Aren't Supported

Aug 31, 2009

I seem to be having a weird issue when parsing XML from a server. In LogCat the following warning is displayed:08-31 12:05:28.870: WARN/ExpatReader(2031): DTD handlers aren't supported.The parser then seems to stop. I can't figure out what is causing this problem, my approach doesn't seem any different in this instance with regard to parsing XML. Does anyone have any recommendations to fixing this issue?

View 3 Replies View Related

Samsung I7500 :: Handlers In Android Programming

Sep 8, 2010

I have got to know that the Handlers are basically used to Run the Small Section of Code and etc...But I didn't got the exact scenerio about when particularly It is Ideal to use the Handlers. Code...

View 2 Replies View Related

Android : Way To Attach Event Handlers To Activities?

May 12, 2009

Which is the way to attach the custom event handlers for the activities, in case they support one, when the activity is started using Intent and startActivity() methods. Does intent has a special way to take up the handler callback references. Basically, I wish to handle call end activity after invoking the call activity.

View 2 Replies View Related

Android :: Preference Activity / Multiple Preferences

Nov 4, 2010

Is it possible to use the PreferenceActivity and PreferenceScreen to manage multiple instances of preferences fro a single app? It seems that they store preferences as "default" preferences only. I would like to use a PreferenceScreen as my configure activity for an AppWidget, but I need to be able to store distinct preferences for each widget.

View 2 Replies View Related

Android :: Multiple Contact Selection Activity

Aug 30, 2010

Is it possible to get a multiple contact selection activity in Android?

View 1 Replies View Related

Android :: Activity With Multiple Repeating Backgrounds

May 13, 2010

I'm having trouble creating a layout with two backgrounds that tile in the x direction but not y.

I've mocked up what I'm trying to create here...

http://img153.imageshack.us/img153/6008/cnbackground.png

So the top section repeats horizontally, then there's a flat creen section in the middle in which I will center my content, then there's some horizontally repeating grass along the bottom.

View 1 Replies View Related

Android :: How To Create Multiple Instances Of An Activity

Feb 19, 2010

I want to create multiple instances of an activity in the same process. Should I use FLAG_ACTIVITY_NEW_TASK flag like the code below?

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

This code is executed in class A to create another instance of activity A.

This question, will this code create another task? As I understand is a process can only have one task. Does it mean the two activities will exist in different tasks? That's what I want. I want the two activities to be in the same process.

View 1 Replies View Related

Android :: Same Activity Called Twice - Multiple AsyncTasks?

May 8, 2010

I have three simultaneous instances of an AsyncTask for download three files. When two particular ones finish, at the end of onPostExecute() I check a flag set by each, and if both are true, I call startActivity() for the next Activity.

I am currently seeing the activity called twice, or something that resembles this type of behavior. Since the screen does that 'swipe left' kind of transition to the next activity, it sometimes does it twice (and when I hit back, it goes back to the same activity). It's obvious two versions of the activity that SHOULD only get called once are being put on the Activity stack.

Could this be from both onPostExecute()s executing simultaneously and both checking the flags each other set at the exact same time? This seems extremely unlikely since two processes would have to be running line-by-line in parallel...

A lot removed from this question since I was way off in what I thought was wrong. Nonetheless I found the answer here quite useful, so I have edited the question to reflect the useful parts.

View 1 Replies View Related







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