by Business Talk » Wed, 06 Jan 2010 22:50:40 GMT

Sponsored Links
 I am using ListActivities to drill down into a hierarchy; artist,
album and song. One activity per hierarchy. So, from the main
activity  I start the ArtistActivity with the StartActivityForResult
method and when the an artist is selected I call the

protected void onListItemClick(ListView l, View v, int position, long
id) {

setResult(Activity.RESULT_OK, results);


to return the results. Than the main activity receives results from
the ArtistsActivity in the onActivityResult method and starts the next
hierarchy activity, AlbumActivity, in the same way as the previous
activity, on so on. It works fine except that when calling finish
method the hierarchy activity is removed from the stack. So, it makes
it impossible to backtrack to the previous hierarchy since it not
there anymore. For example, I can backtrack from AlbumActivity to
the ArtistsActivity since it has been removed from the stack.  My
question is; is there any way to leave the hierarchy activities on the


by Mark Murphy » Wed, 06 Jan 2010 23:05:28 GMT

 > I am using ListActivities to drill down into a hierarchy; artist,

Instead of calling setResult()/finish() in a list item click,
startActivityForResult() the next level down in the hierarchy. Only the
leaf should call setResult()/finish() in a list item click. All branches
of the hierarchy should call setResult()/finish() in their
onActivityResult(), forwarding the leaf's result Intent along.

Mark Murphy (a Commons Guy) 
Android App Developer Books: 

Sponsored Links


by Business Talk » Wed, 06 Jan 2010 23:38:03 GMT

 Thanks Mark, it will work. I was considering this approach. I was
hesitant for it establishes a dependency among the hierarchy
activities. I thought I might have a need to reuse the activities in
other scenarios in which I might have to select the artists/albums/
songs only without drilling down the hierarchy. I will go with your
suggestion thought.


> - Show quoted text -


by Pierre Henry » Sun, 28 Feb 2010 05:41:11 GMT

 Encoutered a tricky result using startActivityForResult from an

In the called Activity , I set result like that:
setResult(RESULT_OK, getIntent().putExtra(getPackageName()+"values",

When running the on ActivityResult, the extra has disappeared from
intent in the method *onActivityResult*

In the api doc, it is telling that package name must be used , so I
used it (see code upwards ).

So why is that ?



by Mark Murphy » Sun, 28 Feb 2010 07:08:25 GMT


Create a fresh Intent (via new Intent()) and see if that helps.

Mark Murphy (a Commons Guy)  | 

Warescription: Three Android Books, Plus Updates, One Low Price!



by jarnaud » Mon, 01 Mar 2010 08:02:57 GMT

 Hi Pierre, I have release a set of video android tutorials on 
and the free/sample chapter is on Intents. It should answers your
questions and provide you
some guidance to go further with Intents.



by kypriakos » Thu, 19 May 2011 11:44:45 GMT

 Hi all,

I am writing apps for some old phones (Android 1.6). I can call
startActivity(intent) without issues but the
startActivityForResult(intent, int) fails on compile? Was this method
introduced after 1.6? How can one see what's been deprecated across



Re: startActivityForResult

by Giorgio Vespucci » Thu, 19 May 2011 12:17:05 GMT

 In the upper right corner of API page there is a scrollbox you can use to
filter the minimum API level you want to see.
Hope this helps. :)
 Il giorno 19/mag/2011 05:44, "kypriakos" <> ha scritto:


Re: startActivityForResult

by Our-Android » Thu, 19 May 2011 12:27:34 GMT


find the link below you will get complete code for



Re: startActivityForResult

by kypriakos » Fri, 20 May 2011 02:00:09 GMT

 Great thanks - much appreciated it. But I was also asking as to
whether the
startActivityforResult() is part of the Android 1.6 API since the
fails there. Any idea?

On May 19, 12:27am, Our-Android <>


Re: startActivityForResult

by kypriakos » Fri, 20 May 2011 02:04:41 GMT

 Excellent!  Thanks.

So the API level 4 (to which cupcake/1.6 is based on) does not have
the startActivityForResult -
which is in line with the fact that the compilation fails. Anyway
knows as to what provision
was available back then for allowing an activity to call back a
calling class? Or no such luck?
Will I need to use some kind of shared mem or a file method to pass
results back?


On May 19, 12:16am, Giorgio Vespucci <>


Re: startActivityForResult

by Nicholas Johnson » Fri, 20 May 2011 02:12:10 GMT

 startActivityForResult has been in the API since level 1.

1.6 has it.

Here's a link to the 
documentation< #startActivityForResult(android.content.Intent,


Re: Re: startActivityForResult

by Kostya Vasilyev » Fri, 20 May 2011 02:13:00 GMT

 Huh? #startActivityForResult(android.content.Intent, 

Since API level 1 - i.e. Android 1.0.

Perhaps you could post a code snippet showing the compile error.

-- Kostya

19.05.2011 22:04, kypriakos :
So the API level 4 (to which cupcake/1.6 is based on) does not have the startActivityForResult - which is in line with the fact that the compilation fails.
-- Kostya Vasilyev -- --

Re: startActivityForResult

by kypriakos » Fri, 20 May 2011 05:40:36 GMT

 That's what I said too - huh? ;)

        Intent intent = new Intent();
        intent.putExtra("from", "1");
        final int result=1;
        // androidContext.startActivity(intent);
        androidContext.startActivityForResult(intent, result);

The startActivity method (commented out) is found fine when used - the
one below it gives:

[ERROR][89,22] cannot find symbol
symbol  : method startActivityForResult(android.content.Intent,int)
location: class android.content.Context

It has to be something stupid I can't see right now ...


Re: Re: startActivityForResult

by Justin Anderson » Fri, 20 May 2011 05:51:18 GMT

 Where are you getting androidContext from?

Justin Anderson
MagouyaWare Developer 


Other Threads

1. Some pictures from web cannot display.

Hello, guys.

I have a problem about an ImageView in GridView.

My app has a click event  to get pictures from web.

On Emulator, the app can display all pictures properly.

But  on my Nexus One, the app cannot display some pictures.

I debugged, and found something not-display pictures have in common.

spect ratio is different between not-display pictures(16:9, 4:3...)
and ImageView(1:1).
ot-display pictures  takes a lot of time to get Image(0.1-0.2sec on
Wi-fi, while the other pictures takes 0.01-0.004sec)

If you know something about this problem, give me your advice.

Thanks in advance :-D



2. Maximum SQLite db size in Android web browser is only 15mb?

I'm trying to port a webapp from the iPhone safari web browser to the
Andoid 2.2 web browser. The web app uses client-side persistance via
SQLite. On the iPhone I set the database size to 50mb, which pops up
an alert to the use to allow/deny request. On the Android browser no
such alert is provided to the end user, and the max SQLite db size
that I can create is about 15mb. Is 15mb the max size of SQL
persistance on the Android browser? Why so low? Do I need to embed my
web app in PhoneGap (that's assuming that the webbrowser component of
an Android app is not subject to the same 15mb limitation)?



3. Samsung Galaxy S and Bluetooth Issues

4. How to install the .apk file into blackberry

5. Compile error in the new 鈥淗el lo Testing鈥?Tutorials program

6. java.lang.NullPointerException when trying to edit strings.xml

7. Build with SDK tool rev 7, gives error: if doesn't support the nested "istrue" element