0

我有一个在启动时调用远程服务器的活动。问题是,当应用程序在后台,并且服务器创建新内容时,在恢复我的应用程序时,除非应用程序被终止并重新启动,否则不会看到这些新内容。

我将从服务器获取所有这些信息的代码放在“onResume()”方法中,该方法在应用程序被终止并重新启动时起作用,但如果它只发送到后台按下主页按钮则不起作用。

为什么'onResume()'方法没有被调用?我该怎么做才能调用它?

提前非常感谢!

这是我的代码:

@Override
    protected void onResume() {
        super.onResume();
        Server server = new Server(this);
        server.GetHighlights(10, 0, null);
        server.GetNews(10, 0, null);
        server.GetBrands(12, 0, null);
        Log.i("XS2", "Resume");
    }

    public void onCreate(Bundle icicle) {
        Log.i("XS2", "Create");
        super.onCreate(icicle);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.splash_media_player);
        mPreview = (VideoView) findViewById(R.id.surface);
        if (mPreview != null) {
            mHolder = mPreview.getHolder();
            mHolder.addCallback(this);
        }

//      Server server = new Server(this);
//      server.GetHighlights(10, 0, null);
//      server.GetNews(10, 0, null);
//      server.GetBrands(12, 0, null);

        // google analytics set up
        AnalyticsHelper.initializeTrackerInstance(getApplicationContext());
    }
4

1 回答 1

3

是的,问题出在我身上:我的活动重定向到一个片段(它是一个飞溅活动,当它完成时,它将启动片段)。我应该在这个片段中放置“onResume()”。

感谢大家的帮助!

于 2012-11-13T14:56:37.763 回答