Everlastinf Everlastinf - 2 months ago 9x
Android Question

getIntent error, doesnt get recognized

getIntent does not get recognized, what I am doing wrong?

I get this error:

error: cannot find symbol variable getIntent

PS: at first I got this error cannot find symbol method getIntent.

My code:

package com.example.r.app;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.List;

public class MyAdapter extends ArrayAdapter<String> {

int i=0;

public MyAdapter(Context context, int resource, List<String> objects) {
super(context, resource, objects);

public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
TextView textView = (TextView) view.findViewById(android.R.id.text1);

Intent intent = getIntent;
int[] barva = intent.getIntArrayExtra("barva");

int[] bar = {1, 2, 3};

if (position == i) {
if (barva == bar){
else if (barva == bar){
else if (barva == bar){

return view;



error: cannot find symbol variable getIntent

First,getIntent is method instead of variable so call it as:

Intent intent = getIntent();

Second, getIntent() method is from Activity class instead of ArrayAdapter class so this method is not available in class which is extending ArrayAdapter.

Call getIntent() method from Activity in which creating object of MyAdapter and pass intent as parameter to constructor.