error: cannot find symbol method GetApplicationContext()

7.2k Views Asked by At

I had this error: "error: cannot find symbol method GetApplicationContext()" when I'm creating Fragments for Android app.

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void simple(View v){

        Intent intent = new Intent(intent.GetApplicationContext(), SimpleFragmentActivity.class);
        startActivity(intent);
    }
}
1

There are 1 best solutions below

0
On BEST ANSWER
intent.GetApplicationContext()

getApplicationContext is not a method of the Intent class but of context.

Change

  Intent intent = new Intent(intent.GetApplicationContext(), SimpleFragmentActivity.class);

with

  Intent intent = new Intent(getApplicationContext(), SimpleFragmentActivity.class);

or simply

Intent intent = new Intent(this, SimpleFragmentActivity.class);

where this refers to this object, the Activity, that extends ContextWrapper