Skip to content Skip to sidebar Skip to footer

Creating New Activity, Intent Error

String url = getOutputMediaFile().getName(); Intent i = new Intent(this, FotoActivity.class); i.putExtra('yourkey', url); startActivity(i); I want to start new activity, and send

Solution 1:

Change this:

Intent i = newIntent(this, FotoActivity.class);

to this:

Intent i = newIntent(getApplicationContext(), FotoActivity.class);

I thik the problem is that you are using this as the context, but this is not a reference to that activity in that case. This is just speculation, as you haven't posted more code or a stacktrace.

Solution 2:

Can't tell without at least knowing what the error is, but my guess is that instead of

Intent i = newIntent(this, FotoActivity.class);

you should use either:

Intent i = newIntent(getApplicationContext(), FotoActivity.class);

or

Intent i = newIntent(MyActivity.this, FotoActivity.class);

where "MyActivity" is the name of the Activity that you're creating the intent in.

Solution 3:

Make sure you have FotoActivity in your AndroidManifest.xml.

<activityandroid:name=".FotoActivity">
....
</activity>

Post a Comment for "Creating New Activity, Intent Error"