Trying to integrate Localytics, step 6 assumes you extend FragmentActivity
:
In onResume, open a session, start an upload, and register the activity for marketing.
public void onResume()
{
super.onResume();
Localytics.openSession();
Localytics.upload();
if (activity instanceof FragmentActivity)
{
Localytics.setInAppMessageDisplayActivity((FragmentActivity) activity);
}
Localytics.handleTestMode(activity.getIntent());
}
In my class, MainActivity.java
, we're extending a class that extends a class that extends a few more classes, finally ending with class that extend FragmentActivity
. This is causing the following exception in MainActivity.java
: cannot resolve symbol 'activity'
Edit
Localytics.openSession();
Localytics.upload();
if (FragmentActivity.class.isAssignableFrom(this.class))
{
Localytics.setInAppMessageDisplayActivity(this);
}
Localytics.handleTestMode(this.getIntent());
...where are you declaring the
activity
variable?Replace
activity
withthis
in your code. UseMainActivity.this
if you need to access a reference to yourActivity
from within an inner class.Fix for the new issue: