I want to set up analytics for my app and it says The method getActivity() is undefined for the type MainScreen. I have setted up the 'MyAplication, and there I'm getting no errors, so this is the mainscreen code:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Tracker t = ( (MyApplication) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
// Set screen name.
t.setScreenName("MainScreen");
// Send a screen view.
t.send(new HitBuilders.ScreenViewBuilder().build());
}