PushService类型中的方法setDefaultPushCallback不适用

时间:2013-06-19 04:06:51

标签: android

错误:The method setDefaultPushCallback(Context, Class<? extends Activity>) in the type PushService is not applicable for the arguments (new Runnable(){}, Class<MenuActivity>)

关注parse push notifications tutorial

以上错误显示

try {
        runOnUiThread(new Runnable() {
            public void run() {
                GetOtherData getOtherData = new GetOtherData();
                getOtherData.execute();
                PushService.setDefaultPushCallback(this, MenuActivity.class);
                ParseInstallation.getCurrentInstallation().saveInBackground();
                ParseAnalytics.trackAppOpened(getIntent());

            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }

3 个答案:

答案 0 :(得分:0)

您应该使用getApplicationContext()yourActivity.this来获取背景信息。 像这样......

try {
        runOnUiThread(new Runnable() {
            public void run() {
                GetOtherData getOtherData = new GetOtherData();
                getOtherData.execute();
                PushService.setDefaultPushCallback(YourActivity.this, MenuActivity.class);
                ParseInstallation.getCurrentInstallation().saveInBackground();
                ParseAnalytics.trackAppOpened(getIntent());

            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }

希望这会有所帮助..

答案 1 :(得分:0)

我遇到了同样的问题。在setDefaultPushCallback中,如果用户按下后退按钮,则应指定要显示的活动。我可以通过改变这一行来编译:

PushService.setDefaultPushCallback(this, MenuActivity.class)

对于这个:

PushService.setDefaultPushCallback(this, MainActivity.class)

我希望这会有所帮助。

答案 2 :(得分:0)

检查android parse-xxx.jar的版本号(xxx是版本号),如果使用旧版本,方法setDefaultPushCallback将不适用,我在使用时遇到此错误parse1.4.4.jar

相关问题