2012-05-18 130 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

我如何下載和存儲由於我對這個平臺很陌生? –

相關問題