我有一个在启动时调用远程服务器的活动。问题是,当应用程序在后台,并且服务器创建新内容时,在恢复我的应用程序时,除非应用程序被终止并重新启动,否则不会看到这些新内容。
我将从服务器获取所有这些信息的代码放在“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());
}