Simple questions: switching from Activity to ListActivity

Last Updated:

  1. gcinzh

    gcinzh New Member This Topic's Starter

    Jan 2, 2009
    Likes Received:

    I'm totally out of my depth but persistently wading and learning as I go.
    I'm really unfamiliar with the Java paradigm, so please bear with me and don't assume I know anything (because, really, I probably don't :-( ).

    A few questions:

    1. Could someone point me to, or explain to me, the intended flow of an Android application? eg. if I want to:
    "do X; get results from X; then display Y to user; then get input; then do Z"
    I've gleaned so far that I have my main Activity class, in which I set a listener for X, then call X, and that's the end of that class;
    Then, when my listener is called, I set a listener for input from the user, and display Y to user, and that's all for that class;
    then, in yet another new class, I have the code that is called if the user presses the button.

    Is that right ?
    Seems rather disjoint, and coming from a perl/python background I'm used to systematic flow: "Do X, then display content to user, then loop or block until user enters", so please correct my thinking above if it's erroneous.

    2. I have a class "extends Activity" which is the first class of my application. I then want to display a list, and have a class that "extends ListActivity". The ListActivity class is called from a BroadcastReceiver (basically, I'm scanning SSIDs, the listener is called when scan is complete, and then I want to display a list of SSIDs to the user for selection). When I attempt to transfer to a method inside the ListActivity class, my program crashes; I understand that this is due to the different type of view (from TextView to ListView, I suspect). I also have the feeling that I need to set an intent to transition from the first class type to the second... however I don't have sufficient knowledge/background/experience to understand how to get this done (My attempt to create an intent and call startActivity failed because startActivity is not available from within a BroadcastReceiver class) ... :-o

    Many thanks

  2. RabydDonkey

    RabydDonkey Member

    Dec 17, 2008
    Likes Received:
    Hi Gary,

    I might be able to assist here. I think everything seems disjoint because Android manages the UI/main execution thread for you. The callbacks are running in that thread, but the management/waiting is handled on their end for efficiency purposes.

    They definitely encourage separation, preferably following MVC. If the controller part seems to have poor flow, you could always collect those callbacks in a single controller class (or whatever makes sense). As far as I can see, you seem to be doing things correctly.

    I'm having a little trouble understanding your second part. What exception does the log give you when it crashes? You can get the exception easily in the emulator in dev tools->exception browser or by opening ddms in the tools folder. If you want to start another activity in a BroadcastReceiver, you can use the context in the callback.

    Sorry if that wasn't much help. If you give me the exception I might be able to help further :D

Share This Page