2012-05-18 131 views
0

是否可以使用Web服务器中的图像作为斜杠画面。我想从url中指定启动画面而不是本地文件。或者是否可以从网络服务器动态下载图像并替换当前的启动画面?从Web服务器加载启动画面Android应用程序

+1

雅一些代码,其可能的,但飞溅的目的是不是... –

+0

我怎么能这样做呢?不想一直加载,但如果能在一周内下载一次并替换旧的启动画面,会更好。在此先感谢 –

+0

最好不要有一个启动画面。显示有用的内容并延迟加载其他内容。应用程序启动越快,用户就会越坚持使用它。 – Intrications

回答

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

} 
} 

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

Load images from URL

制作闪屏

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

0

在应用程序中内置默认启动画面图像,以便在第一次运行应用程序时不会出现延迟。应用程序的启动速度肯定比您可以通过移动连接下载图片的速度快。

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

然后显示此图像而不是默认值。每周重复一次,因为你每周都想要一张新照片。或者,最好只是加快启动速度,所以你根本不需要启动画面。

+0

我如何下载和存储由于我对这个平台很陌生? –

相关问题