0

是否可以使用来自网络服务器的图像作为斜线屏幕。我想从 url 指定启动画面而不是本地文件。或者是否可以从网络服务器动态下载图像并替换当前的启动画面?

4

2 回答 2

1

这是使用图像制作飞溅碎石的一些技巧,图像是下载表单服务器。

首先从服务器下载图像,本教程

http://getablogger.blogspot.com/2008/01/android-download-image-from-server-and.html

然后在初始屏幕上设置下载的图像

public class SplashScreenActivity extends Activity {

 @Override
 public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);

 // Set Image download from server, which is already defined above link.

  /** set time to splash out */
final int welcomeScreenDisplay = 3000;
/** create a thread to show splash up to splash time */
Thread welcomeThread = new Thread() {

int wait = 0;

@Override
public void run() {
try {
super.run();
/**
* use while to get the splash time. Use sleep() to increase
* the wait variable for every 100L.
*/
while (wait < welcomeScreenDisplay) {
sleep(100);
wait += 100;
}
} catch (Exception e) {
System.out.println("EXc=" + e);
} finally {
/**
* Called after splash times up. Do some action after splash
* times up. Here we moved to another main activity class
*/
startActivity(new Intent(SplashScreenActivity.this,
MainScreenActivity.class));
finish();
}
}
};
welcomeThread.start();

}
}

有关从服务器获取图像的更多信息:

从 URL 加载图像

一些用于制作启动画面的代码

http://www.codeproject.com/Articles/113831/An-Advanced-Splash-Screen-for-Android-App

于 2012-05-18T15:23:30.820 回答
0

将默认的初始屏幕图像内置到应用程序中,以便在应用程序首次运行时不会延迟显示它。该应用程序的启动速度肯定比您通过移动连接下载图片的速度要快。

在某个时候,在后台线程中下载新图像并将其存储在某个地方,如果它很大,可能在 SD 卡上。

然后显示此图像而不是默认图像。每周重复此操作,因为您每周都需要一个新图像。

或者,最好只是加快启动速度,这样您就根本不需要启动画面了。

于 2012-05-18T15:01:09.367 回答