I have my first class, its a loading screen.
public class Loading extends Activity {
public int switchscreensvalue = 0;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.loadinglayout);
new Loadsounds().execute(switchscreensvalue);
if (switchscreensvalue == 1)
{
Intent myIntent = new Intent(Loading.this, main.class);
startActivityForResult(myIntent, 0);
}
}
}
Then I have my asynctask class.
public class Loadsounds extends AsyncTask<Integer, Void, Void> {
@Override
protected Void doInBackground(Integer... params) {
SoundManager.addSound(0, R.raw.rubber);
SoundManager.addSound(1, R.raw.metal);
SoundManager.addSound(2, R.raw.ice);
SoundManager.addSound(3, R.raw.wind);
SoundManager.addSound(4, R.raw.fire);
return null;
}
protected void onPostExecute(Integer...params){
int switchscreensvalue = 1;
}
}
I want it to start the asynctask, which loads 5 sounds into a soundboard, and when its done, change the int "switchscreensvalue" to 1. Then, the loading screen is supposed to change to the main screen when "switchscreensvalue" = 1. It does not work though. Please can anyone help me, just learning asynctasks for the first time. Still fairly new to Java in fact. I need the asynctask to load 5 sounds and then change the activity from loading to main activity.