是否有可能使用来自网络服务器的图像作为斜线屏幕。我想从一个url指定闪屏,而不是一个本地文件。或者,是否可以从the服务器上动态下载图像并替换当前的闪屏?
发布于 2012-05-18 23:23:31
这是一些技巧,使启动屏幕使用图像,这是从服务器下载。
首先从服务器下载图像,本教程
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();
}
}有关从服务器获取镜像的更多信息:
和
制作闪屏的一些代码
http://www.codeproject.com/Articles/113831/An-Advanced-Splash-Screen-for-Android-App
发布于 2012-05-18 23:01:09
在应用程序中内置一个默认的闪屏图像,以便在应用程序首次运行时没有延迟地显示它。这款应用的启动速度肯定比你通过移动连接下载图片的速度要快。
在某个时刻,在后台线程中下载新图像,并将其存储在某个地方,如果它很大,可能会存储在SD卡上。
然后显示此图像,而不是默认图像。每周重复此步骤,因为您希望每周都有一张新图像。
或者,最好是加快启动速度,这样就根本不需要闪屏了。
https://stackoverflow.com/questions/10654444
复制相似问题