Error in the navigation from splash screen to next screen
<p>I created splash screen to my android project, if i run it splash screen appears for a while and displays force close message, what should i do to navigate to the next page? any suggestions? </p>

<pre><code>public class LoadingScreen extends Activity implements LoadingTaskFinishedListener {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Show the splash screen
    setContentView(R.layout.activity_loading_screen);
    // Find the progress bar
    ProgressBar progressBar = (ProgressBar) findViewById(R.id.Progressbar);
    // Start your loading
    new LoadingTask(progressBar, null).execute("www.google.co.uk"); // Pass in whatever you need a url is just an example we don't use it in this tutorial

}

// This is the callback for when your async task has finished
public void onTaskFinished() {
    completeSplash();
}

private void completeSplash(){
    startApp();
    finish(); // Don't forget to finish this Splash Activity so the user can't return to it!
}

private void startApp() {
    Intent intent = new Intent(LoadingScreen.this, Rebuix.class);
    startActivity(intent);
}
</code></pre>

<p>}</p>

<p>My manifest file</p>

<pre><code>&lt;uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="15" /&gt;

&lt;uses-permission android:name="android.permission.INTERNET" /&gt;

&lt;application
    android:icon="@drawable/rebuix"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" &gt;
    &lt;activity
        android:name=".LoadingScreen"
        android:label="@string/title_activity_loading_screen" &gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.MAIN" /&gt;

            &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
        &lt;/intent-filter&gt;
    &lt;/activity&gt;
    &lt;activity
        android:name=".Rebuix"
        android:label="@string/title_activity_rebuix" &gt;
        &lt;meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.rebuix.com.Rebuix" /&gt;
    &lt;/activity&gt;
    &lt;activity
        android:name=".Login"
        android:label="@string/title_activity_login" &gt;
        &lt;meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.rebuix.com.Rebuix" /&gt;
    &lt;/activity&gt;
</code></pre>

<p>Logcat</p>

<pre><code>11-23 13:13:03.798: I/Tutorial(459): Starting task with url: www.google.co.uk
11-23 13:13:14.156: D/AndroidRuntime(459): Shutting down VM
11-23 13:13:14.156: W/dalvikvm(459): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
11-23 13:13:14.166: E/AndroidRuntime(459): FATAL EXCEPTION: main
11-23 13:13:14.166: E/AndroidRuntime(459): java.lang.NullPointerException
11-23 13:13:14.166: E/AndroidRuntime(459):  at com.rebuix.com.LoadingTask.onPostExecute(LoadingTask.java:68)
11-23 13:13:14.166: E/AndroidRuntime(459):  at com.rebuix.com.LoadingTask.onPostExecute(LoadingTask.java:1)
11-23 13:13:14.166: E/AndroidRuntime(459):  at android.os.AsyncTask.finish(AsyncTask.java:417)
11-23 13:13:14.166: E/AndroidRuntime(459):  at android.os.AsyncTask.access$300(AsyncTask.java:127)
11-23 13:13:14.166: E/AndroidRuntime(459):  at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
11-23 13:13:14.166: E/AndroidRuntime(459):  at android.os.Handler.dispatchMessage(Handler.java:99)
11-23 13:13:14.166: E/AndroidRuntime(459):  at android.os.Looper.loop(Looper.java:123)
11-23 13:13:14.166: E/AndroidRuntime(459):  at android.app.ActivityThread.main(ActivityThread.java:4627)
11-23 13:13:14.166: E/AndroidRuntime(459):  at java.lang.reflect.Method.invokeNative(Native Method)
11-23 13:13:14.166: E/AndroidRuntime(459):  at java.lang.reflect.Method.invoke(Method.java:521)
11-23 13:13:14.166: E/AndroidRuntime(459):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-23 13:13:14.166: E/AndroidRuntime(459):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-23 13:13:14.166: E/AndroidRuntime(459):  at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p>LoadingTask class</p>

<pre><code>public class LoadingTask extends AsyncTask&lt;String, Integer, Integer&gt; {

public interface LoadingTaskFinishedListener {
    void onTaskFinished(); // If you want to pass something back to the listener add a param to this method
}

// This is the progress bar you want to update while the task is in progress
private final ProgressBar progressBar;
// This is the listener that will be told when this task is finished
private final LoadingTaskFinishedListener finishedListener;

/**
 * A Loading task that will load some resources that are necessary for the app to start
 * @param progressBar - the progress bar you want to update while the task is in progress
 * @param finishedListener - the listener that will be told when this task is finished
 */
public LoadingTask(ProgressBar progressBar, LoadingTaskFinishedListener finishedListener) {
    this.progressBar = progressBar;
    this.finishedListener = finishedListener;
}

@Override
protected Integer doInBackground(String... params) {
    Log.i("Tutorial", "Starting task with url: "+params[0]);
    if(resourcesDontAlreadyExist()){
        downloadResources();
    }
    // Perhaps you want to return something to your post execute
    return 1234;
}

private boolean resourcesDontAlreadyExist() {
    // Here you would query your app's internal state to see if this download had been performed before
    // Perhaps once checked save this in a shared preference for speed of access next time
    return true; // returning true so we show the splash every time
}


private void downloadResources() {
    // We are just imitating some process thats takes a bit of time (loading of resources / downloading)
    int count = 10;
    for (int i = 0; i &lt; count; i++) {

        // Update the progress bar after every step
        int progress = (int) ((i / (float) count) * 100);
        publishProgress(progress);

        // Do some long loading things
        try { Thread.sleep(1000); } catch (InterruptedException ignore) {}
    }
}

@Override
protected void onProgressUpdate(Integer... values) {
    super.onProgressUpdate(values);
    progressBar.setProgress(values[0]); // This is ran on the UI thread so it is ok to update our progress bar ( a UI view ) here
}

@Override
protected void onPostExecute(Integer result) {
    super.onPostExecute(result);
    finishedListener.onTaskFinished(); // Tell whoever was listening we have finished
}
</code></pre>

<p>}</p>
