尝试集成Localytics,步骤6假设您扩展了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());
}


在我的类MainActivity.java中,我们正在扩展一个类,该类扩展了一个类,该类又扩展了几个类,最后以扩展了FragmentActivity的类结尾。这导致MainActivity.java中的以下异常:无法解析符号“活动”

编辑

 Localytics.openSession();
 Localytics.upload();

 if (FragmentActivity.class.isAssignableFrom(this.class))
 {
     Localytics.setInAppMessageDisplayActivity(this);
 }
 Localytics.handleTestMode(this.getIntent());

最佳答案

...您在哪里声明activity变量?

在代码中将activity替换为this。如果需要从内部类访问对MainActivity.this的引用,请使用Activity

解决新问题:

if (FragmentActivity.class.isAssignableFrom(MainActivity.class))

关于java - 整合局部语言-FragmentActivity,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30738929/

10-12 03:04