Reputation: 589
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);
}
}
Upvotes: 2
Views: 7601
Reputation: 157447
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
Upvotes: 3