The Time
The Time

Reputation: 737

The method getIntent() is undefined for the type GetLRL

I am trying to pass data from createCheckboxList method to the getLRL class but when I try to call getIntent in the post_selected GetLRL class I am getting this error The method getIntent() is undefined for the type GetLRL

How can I fix it?

createCheckboxList in the MainActivity:

private void createCheckboxList(final ArrayList<Integer> items) {
        this.items = items;
        final ArrayList<Integer> selected = new ArrayList<Integer>();
        ...

            btn.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {       
                    Intent intent = new Intent(MainActivity.this, GetLRL.class);
                    intent.putIntegerArrayListExtra("selected_route", selected);
                    startActivity(intent);
        }
    }

post_selected method in the GetLRL:

public void post_selected() {
//  here is the error
    Bundle extras = getIntent().getExtras();
    if (extras != null && extras.containsKey("selected_route")) {

        ArrayList<Integer> routeList = extras
                .getIntegerArrayList("selected_route");

    }

    //new MyAsyncTask(context).execute(jSONString);
}

Upvotes: 0

Views: 293

Answers (1)

Alex Lord Mordor
Alex Lord Mordor

Reputation: 3050

GetLRL class must be an Activity (extends Activity), if it is not, then the undefined method exception will be thrown

Upvotes: 1

Related Questions