Page MenuHomec4science

LauncherActivity.java
No OneTemporary

File Metadata

Created
Thu, Jan 30, 11:40

LauncherActivity.java

package ch.epfl.pharma;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
public class LauncherActivity extends Activity {
private final static String TAG = LauncherActivity.class.getName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_launcher);
AppInitializerAsyncTask initializer = new AppInitializerAsyncTask(this);
initializer.execute();
}
private class AppInitializerAsyncTask extends AsyncTask<Void, Void, Boolean> {
private Context context;
public AppInitializerAsyncTask(Context context) {
this.context = context;
}
@Override
protected Boolean doInBackground(Void... params) {
Log.d(TAG, "This is the async task handler");
try {
Thread.sleep(3000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
Log.d(TAG, "finished sleeping");
return true;
}
@Override
protected void onPostExecute(Boolean initialized) {
if (initialized) {
// start default activity
Intent intent = new Intent(context, MainActivity.class);
startActivity(intent);
} else {
// quit program
finish();
}
}
}
}

Event Timeline