Jerome Ansia
Jerome Ansia

Reputation: 6884

Android Start New Activity when AsynTask is finished

What's the best practice to start a new activity when AsynTask is finished,

I try to launch it on post execute like this :

    @Override
    protected void onPostExecute(Void result) {
        Log.d(TAG, "end flag game print recap");

        //launch activity flag game recap
        Intent myIntent = new Intent(context, FlagGameRecapActivity.class);
        context.startActivity(myIntent);

        super.onPostExecute(result);
    }

But i got an Exception : Calling an startActivity() from outside an activity require the flag FLAG_ACTIVITY_NEW_FLAG

Thanks

Upvotes: 0

Views: 869

Answers (1)

adneal
adneal

Reputation: 30794

Intent myIntent  = new Intent(this, FlagGameRecapActivity.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(myIntent);

Upvotes: 1

Related Questions