0

I have problem in my code in the commented lines:

 bouton.setOnClickListener(new OnClickListener()
 {
 public void onClick(View v)
 {
 url=edit.getText().toString();
 System.out.println(url);
 // this line and
 Intent Activite=new Intent(this, Main1.class);
 Activite.putExtra("param", url);
 /// this line
 this.startActivityForResult(Activite, 1000);
 }
 });

Can you help me to correct my code

asked Mar 28, 2011 at 10:27
1
  • 1
    What problem? What error? What is Main1.class, does it exist? What is edit? Give us more to go on, we can't help you this way. Commented Mar 28, 2011 at 10:30

2 Answers 2

2

either remove this from the line where you are starting the next activity.

OR

use:

ClassName.this.startActivityForResult(Activite, 1000);

Basically when you are saying this : this.startActivityForResult(Activite, 1000); "this" is corresponding to the context of OnClickListener and not of the Activity you are in. As you already know that startActivityForResult is a method on Activity class and not of android.view.View.OnClickListener class.

Hope this helps!!

answered Mar 28, 2011 at 10:34
Sign up to request clarification or add additional context in comments.

Comments

0

In addition to mudit, replace

Intent Activite=new Intent(this, Main1.class);

with Intent Activite=new Intent(ActivityClassName.this, Main1.class);

But Levisaxos was right, you could give us more info, at least your stack trace

answered Mar 28, 2011 at 10:38

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.