0

I have My first Activity - [A] and my Second Activity [B]. I Starting my transparent-[B] Activity from Activity [A] in my PreExecute of BackGroundTask using

Intent intent = new Intent(ActivityA.this, ActivityB.class);
startActivity(intent);

and from my PostExecute i want to close my transparent Activity [B] to continue work with Activity [A] like:

Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

but it give's me Error cause i haven't an correct Intent.

i can do like:

Intent intent = new Intent(getAplicationContext(), ActivityA.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

This code will create a new Activity [A]. But i need to continue my work with Activity[A] not to create a new Activity [A]. How can i finish() Activity[B] from Activity[A] without errors, go back to Activity[A] and continue my work.

private class BackGroundTask extends AsyncTask<Void, Void, Void>
{


    @Override
    protected void onPreExecute()
    {
        StartPreExecute();
    }

    @Override
    protected Void doInBackground(Void... params)
    {
        //sending request to server and waiting response here
        return null;
    }

    protected void onPostExecute(Void result)
    {
        super.onPostExecute(result);
        StartPostExecute();
    }


}

protected Void doInBackground(Void... params)
{
    return null;
}

private void StartPreExecute()
{
    Intent intent = new Intent(SigninActivity.this, LoadingLayout.class);
    startActivity(intent);
}

private void StartPostExecute()
{
    Intent intent = new Intent(getAplicationContext(), SigninActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_);
    startActivity(intent);
}
Raqim
  • 93
  • 1
  • 1
  • 6

1 Answers1

3

If you say Actvity B should be transparent, I would recommend to use Service. Services are somehow similar to Activities but they run on the background and are not visible to the user. As soon the Service is completed with the tasks, it finish() itself later on. You don't need to leave the Activity A. Is this maybe what you need?

mapodev
  • 988
  • 8
  • 14
  • nope( Activity[A] takes Login and Pass - when User Clicks button - start's my background thread - witch sends request to server and waiting response.I need To close access to EditText and Buttons for User via starting [B]. Activity [B] is little blue and transparent - so it seems like my screen was blocked and changed color contrast. And... When background thread takes response from server - i need to close transparent Activity[B] - it will open access to Activity[A]'s layout(EditTexts and Buttons).But i need to close Activity[B] from Activity[A] cause my thread continue my work in Activity[A] – Raqim Jun 10 '14 at 11:54