2

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);
    }
}
chaoskreator
  • 889
  • 1
  • 17
  • 39
robigroza
  • 559
  • 1
  • 5
  • 22

1 Answers1

3
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

Blackbelt
  • 156,034
  • 29
  • 297
  • 305