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 <[email protected]> wrote:
> On Sun, Sep 19, 2010 at 2:59 PM, GregAZ <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en