0
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 string to it. But I have an error on(this,FotoActivity.class);

Any ideas?

Tim
  • 41,901
  • 18
  • 127
  • 145
  • 8
    Please, for the rest of your life as a computer programmer, never say "you have an error" without stating the type of error. Please. – pamphlet Jun 12 '14 at 17:40
  • 4
    Please, for the rest of your life as a SO user, don't post a question about an error without posting a full stacktrace as well :) – Nir Alfasi Jun 12 '14 at 17:41

3 Answers3

1

Change this:

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

to this:

Intent i = new Intent(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.

Valdrinium
  • 1,398
  • 1
  • 13
  • 28
0

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

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

you should use either:

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

or

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

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

camdroid
  • 524
  • 7
  • 24
  • Solving my problem, without knowing what it is. I am very new to this, and it is very confusing for me. THANK YOU. – user3134759 Jun 12 '14 at 17:59
  • When you ask a question on SO, remember to include the error message and stack trace - that makes it much easier for other members to figure out what actually went wrong, rather than guessing. For Android, the stack trace is just the LogCat output - you can save that to a text file, and then just copy-paste the error into your question. – camdroid Jun 12 '14 at 18:03
0

Make sure you have FotoActivity in your AndroidManifest.xml.

<activity android:name=".FotoActivity">
....
</activity>
Reto Koradi
  • 53,228
  • 8
  • 93
  • 133