Thanks for that information, that makes a lot of sense.  I will give
that a try!

On Sep 19, 3:07 pm, Dianne Hackborn <hack...@android.com> wrote:
> Your process is getting killed, for whatever reason.  When you are not in
> the foreground this can happen at any time.  Typically when you start
> another activity the new activity will be full screen so the previous
> activity is no longer in the foreground.  And if you are using
> startActivityForResult() to launch an activity in another app (as you are
> doing here), then your app's process is no longer in the foreground and may
> get killed.
>
> Also I think probably 99% of the time that you would be using a static or
> Application instance to store state related to startActivityForResult() is
> wrong.  This method is about making a call to another activity, whose result
> will be delivered back to the caller's activity.  There is no global state
> here -- the result goes back to the original activity.  The wrinkle is that
> this may be a new instance of the activity...  but if you save your current
> state (including whatever state you need about a result you are waiting for)
> in onSaveInstanceState() and restore it in onCreate(), this will all work
> correctly.
>
>
>
>
>
>
>
>
>
> On Sun, Sep 19, 2010 at 12:37 PM, GregAZ <ggur...@gmail.com> wrote:
> > That's what I thought.
>
> > Any ideas why the value is getting lost from the application?
>
> > I created a class that I called BaseClass that inherits Application.
> > That class contains:
>
> >        private String uploadUrl;
>
> >          public String getUploadUrl(){
> >            return uploadUrl;
> >          }
> >          public void setUploadUrl(String url){
> >                  uploadUrl = url;
> >          }
>
> > In my activity, I'm setting it:
> > public void onPageFinished(WebView view, String url)
> > {
>
> >                BaseClass appState =
> > ((BaseClass)getApplicationContext());
> >                appState.setUploadUrl(new String(url));
>
> >        Intent i = new Intent(Intent.ACTION_PICK,
> > android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
> >         startActivityForResult(i, 1);
> > }
>
> > Then in the onActivityResult I'm trying to read it back out, but on
> > Droid phones it's NULL.  Works perfect on my HTC Hero (and the
> > emulators).  I know the url getting set is correct because I'm
> > checking it (I left that part out) and only show the image picker
> > intent if they are at a specific page.
>
> > protected void onActivityResult(int requestCode, int resultCode,
> > Intent intent) {
>
> >        if (requestCode == 1)
> >        {
> >                BaseClass appState = ((BaseClass)getApplicationContext());
> >                String uploadUrl = appState.getUploadUrl(); // NULL on Droid
> > phones
> >        }
> > }
>
> > I added
> > android:name=".BaseClass"
>
> > to the manifest.
>
> > On Sep 19, 2:05 pm, Mark Murphy <mmur...@commonsware.com> wrote:
> > > On Sun, Sep 19, 2010 at 2:59 PM, GregAZ <ggur...@gmail.com> wrote:
> > > > I think I'm missing something.  If I add the string as an extra to the
> > > > image picker intent, then show that intent, that extra is gone in the
> > > > onActivityResult.
>
> > > Correct.
>
> > > > Even with setResult it's still gone.  This is on my
> > > > HTC Hero:
>
> > > >        Intent i = new Intent(Intent.ACTION_PICK,
> > > > android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
> > > >        i.putExtra("url", url);
> > > >        setResult(1, i);
> > > >        startActivityForResult(i, 1);
>
> > > You do not call setResult() here. That is for use in the activity that
> > > is *started* by startActivityForResult().
>
> > > > In the onActivityResult:
> > > > String url = intent.getStringExtra("url");
>
> > > > It's null.
>
> > > Correct.
>
> > > If you are implementing the activity being started by
> > > startActivityForResult(), in that activity, you can use extras with
> > > setResult(). In this case, somebody else wrote that activity. Extras
> > > you put on the requesting Intent will not automatically be copied to
> > > the response Intent.
>
> > > --
> > > Mark Murphy (a Commons Guy)http://commonsware.com|
> >http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> > > _The Busy Coder's Guide to Android Development_ Version 3.1 Available!
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com<android-developers%2Bunsubs 
> > cr...@googlegroups.com>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to