Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7417145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:38:32+00:00 2026-05-29T07:38:32+00:00

How do I pass an intent from an activity to a class extending surfaceview?

  • 0

How do I pass an intent from an activity to a class extending surfaceview?

Heres the code that sends out the intent:

btnCutOutter.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            //Send intent to cut image from user selection path
            //See designCanvas.java for details

            String optionSelected = "Yes";
            Intent myIntent = new Intent(view.getContext(), designCanvas.class);
            myIntent.putExtra("id",optionSelected );

        }
    });  

When I try to retrieve the intent data :

public class designCanvas extends SurfaceView implements SurfaceHolder.Callback {
//Create shape using Path
    Path mPath = new Path();
    private drawThread _thread;
    private ArrayList<GraphicObject> _graphics = new ArrayList<GraphicObject>();

    public designCanvas(Context context, AttributeSet attributes) {
        super(context, attributes);
        getHolder().addCallback(this);
        setFocusable(true);
        _thread = new drawThread(getHolder(), this); 
        String optionSelected = getIntent().getStringExtra("id");

                                         . . .

I am informed by eclipse that :

The method getIntent() is undefined 

I would be very grateful if someone could give me so guidance on this 🙂

Many thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:38:33+00:00Added an answer on May 29, 2026 at 7:38 am

    Any view in an android is contained within an activity, therefore the activity has a reference to the view (in this case a SurfaceView). So its simply a matter of getting the intent data in the Activity then using a setter for the data you want to pass to the SurfaceView

    So in the Activity that holds the SurfaceView call getIntent like you have in your question then call a setter in the SurfaceView eg. mySurfaceView.setSomeValue(someValue)

    EDIT

    You are calling getIntent() in the designCanvas class it needs to be called in the Activity thats holds SurfaceView

    public SomeActivity extends Activity{
    
    public void onCreate(Bundle b){
         super.onCreate(b);
    
         //give that the constructor for your surface view has an attributeset i assume    
         //you are creating it in xml
         designCanvas dc = findViewById(someid);
    
         String s = getIntent(.getStringExtra("id");
         dc.setId(s);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my code to pass the value from activity class to my service
I am trying to create an Activity class from a string and pass it
Suppose you want to start a new activity and pass it some data from
I'm looking for the best way to start an intent from a class that
I'm trying to pass some data from one activity to a new one but
I'm trying to pass data from one activity to another via Intent.putExtras like this:
I would like to pass a new value for an integer from one Activity
I've used putExtra() to pass some data from one activity to other. I want
I have been trying for hours to pass a resource from one Activity to
When you are about to start a new activity, and want to pass a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.