Note that there are some explanatory texts on larger screens.

plurals
  1. POSplash Screen on Android not working
    primarykey
    data
    text
    <p>I'm developing an Android app. The app should show a Splash Screen at startup while checking if a file is updated. If the file is not updated, it launches an Async Task to update the file. The problem is, the image of the Splash Screen only shows when the file actually needs updating. Else, a black screen shows while performing the check.</p> <p>My SplashScreen activity:</p> <pre><code> public class SplashActivity extends Activity { private final static String placesFile = "places"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_splash); } @Override protected void onResume() { super.onResume(); if(!isFileUpdated()){ new PlacesService(this).execute(); }else{ intentAndFinish(); } } private void intentAndFinish() { finish(); Intent mainIntent = new Intent(this, MainActivity.class); startActivity(mainIntent); } /** * * @return false if Places Data is too old */ private boolean isFileUpdated() { int daysOld = 0; File f = new File(this.getFilesDir().getAbsolutePath() +"/"+placesFile); if(f.exists()){ System.out.println("existe"); } Date d = new Date(); Date currentDate = new Date(System.currentTimeMillis()); d.setTime(f.lastModified()); if(currentDate.compareTo(d)&gt;0) daysOld = determineDifferenceInDays(d, currentDate); return daysOld &lt; Consts.PLACES_DAYS_OLD_QTY_PERMITTED?true:false; } private static int determineDifferenceInDays(Date date1, Date date2) { Calendar calendar1 = Calendar.getInstance(); calendar1.setTime(date1); Calendar calendar2 = Calendar.getInstance(); calendar2.setTime(date2); long diffInMillis = calendar2.getTimeInMillis() - calendar1.getTimeInMillis(); return (int) (diffInMillis / (24* 1000 * 60 * 60)); } public void onResultFromAsyncTask(boolean finished) { if(finished){ intentAndFinish(); } } } </code></pre> <p>activity_splash.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;ImageView android:src="@drawable/splash_es" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; &lt;/LinearLayout&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload