1

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

以下解析推送通知教程

以上错误显示

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();
    }
4

3 回答 3

0

我有同样的问题。在 setDefaultPushCallback 中,您应该指定用户按下后退按钮时要显示的活动。我可以通过改变这一行来编译:

PushService.setDefaultPushCallback(this, MenuActivity.class)

对于这个:

PushService.setDefaultPushCallback(this, MainActivity.class)

我希望这有帮助。

于 2014-07-06T07:04:10.397 回答
0

您应该使用getApplicationContext()oryourActivity.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();
    }

希望这可以帮助..

于 2013-06-19T05:18:28.927 回答
0

查看android的版本号parse-xxx.jar(xxx为版本号),如果使用旧版本,方法setDefaultPushCallback不适用,我在使用parse1.4.4.jar时遇到了这个错误

于 2015-08-13T18:59:20.917 回答