Question: I work for my license project, and one part consist in an android client. All was ok, until I upgraded my phone to Android 4.0.4.

So, I have one AsyncTask. It looks like this:

```
public class TestTask extends AsyncTask<Context, Integer, Long> {

@Override
protected Long doInBackground(Context... params) {
    for (int i = 0; i < 10; i++) {
        System.out.println("nothing-" + i);
        if (i == 5) {
            TestTask2 testTask2 = new TestTask2();
            testTask2.execute(null);
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    return null;
}

```

}

This task wait 5 seconds, than it calls another async task, TestTask2.

```
public class TestTask2 extends AsyncTask<Context, Integer, Long> {

@Override
protected Long doInBackground(Context... params) {
    System.out.println("task 2 in action");
    return null;
}

```

}

In android 4.0.3 or lower, the output is:

> 
> nothing-0 nothing-1 nothing-2 nothing-3 nothing-4 nothing-5
> 
> 
> task 2 in action
> 
> 
> nothing-6 nothing-7 nothing-8 nothing-9
> 
> 
> 

When I upgraded to 4.0.4, the second task doesn't start until the first finished its job.

> 
> nothing-0 nothing-1 nothing-2 nothing-3 nothing-4 nothing-5 nothing-6 nothing-7 nothing-8 nothing-9  
> 
>  task 2 in action
> 
> 
> 

Is there any thread policy in android 4.0.4, or something else? what could be the problem?

Answer: 
There are two steps to do: At first we need to know how to use parameters in our domain and finally the contents need to be switched.

1) You can add parameters to the called files as following:

```
http://server/path/file?key=value

```

For this examples let's use the key `page`. So these would be the urls you'd need to link:

```
http://server/path/file?page=div-1
http://server/path/file?page=div-2

```

2) Split your code into one php file containing all that's in there right now and two ones, called whatever you like, e.g. div-1.php and div-2.php . Into the latter ones you copy the specific div-1 and div-2 contents.

3) Finally open your main php file and remove div-1 and div-2. They should both be in the other files now. And enter the following php code:

```
<?php
if (isset($_REQUEST['page']) === false || in_array($_REQUEST['page'], array('div-1', 'div-2')) === false) {
    $_REQUEST['page'] = 'div-1';
}
include $_REQUEST['page'] . '.php';
?>

```

That urls will call the php file, that's pushing its content to the browser and while pushing it's executing the script we put in. The script verifies if the url parameter page is set, checks if it is valid and pushes the second file just where we put the script before.
The latter check is highly required for security reasons (see below)!

---

Note: The following code line is used to display the default page, e.g. `index` or `start`. It can be changed easily.

```
$_REQUEST['page'] = 'div-1';

```

Note: We need to care about security and therefore do not allow pages, that do not exist. In case we don't do so, various php scripts on your server could be executed.
Just change, edit or add additional elements to the array inside the if statement above:

```
array('div-1', 'div-2')

```
You could do this using Javascript/jQuery only by checking for the hash part of the URL on page load: 

`http://mydomain.com/some/path#showcontainer1` 

HTML

```
<div class="container_one" style="display:none;">Content</div>
<div class="container_two" style="display:none;">Other Content</div>

```

JS

```
$(function(){

  switch( window.location.hash ){
    case '#showcontainer1':  //if hash is #showcontainer1
      $('.container_one').fadeIn();   //fadein the container with some class 
      break;
    default:
      $('.container_two').fadeIn()   //else fade container with other class
      break;
  }

});

```