I have a main activity [Activity A (displayed when the app is opened)] which consists a button( Button 1)
When button 1 is clicked , it opens up a new activity(Activity B) . Activity B consists of a listview which is loaded using Async task
Now i want to add a splash screen to my app so that the Async task performed in Activity B is done via Async task of the splash screen and when the user clicks on Button 1 , Activity B is displayed with the listview already loaded
Is this possible?
I know how to set the splash screen and use Async task in it
My code
onclicklistener of button 1 of activity A
btn.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v){
Intent i = new Intent(ActivityA.this, ActivityB.class);
startActivity(i);
)
});
Async task of Activity B to load listview
private class RemoteDataTask extends AsyncTask<Void, Void, Void> {
@Override
protected void onPreExecute() {
super.onPreExecute();
mProgressDialog = new ProgressDialog(ActivityB.this);
mProgressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
// Set progressdialog message
mProgressDialog.setMessage("Loading. Please wait loading ....");
mProgressDialog.setIndeterminate(true);
mProgressDialog.setCancelable(false);
// Show progressdialog
mProgressDialog.show();
}
@Override
protected Void doInBackground(Void... params) {
//my background process to load listview
}
@Override
protected void onPostExecute(Void result) {
istview = (ListView) findViewById(R.id.activityb_layoutListView);
adapter = new MyAdapter(ActivityB.this, delist)
// Binds the Adapter to the ListView
listview.setAdapter(adapter);
}
}
my doinbackground()
protected Void doInBackground(Void... params) {
// Create the array
delist = new ArrayList<CodeList>();
try {
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>(
"terActivity");
// Locate the column named "ranknum" in Parse.com and order list
// by ascending
query.orderByAscending("_created_at");
ob = query.find();
for (ParseObject inter : ob) {
Delist map = new Delist();
map.setIntroduction((String) inter.get("intro"));
delist.add(map);
}
} catch (ParseException e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return null;
}