My location based app works on android 4.2.2 but not on 4.0.3 or 4.0.4
<p>I searched, searched and searched, but couldn't find a solution to my problem.</p>

<p>I have a very simple location based which returns the person's current address.
When you open the app in a 4.2.2 device, a GPS icon on the notification bar appears and when you press My Location button the address is returned.</p>

<p>But when running the app in a 4.0.3 and 4.0.4 the GPS icon is not shown on the notification bar and when clicking on My Location the app closes.</p>

<p>I'm new to android development so I have no idea why this is happening.</p>

<p>Does anyone have any idea on how to fix it?</p>

<p>Thanks.</p>

<p>This is part of my manifest file:</p>

<pre><code> &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATIO" /&gt;
 &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
 &lt;uses-permission android:name="android.permission.INTERNET" /&gt;

 &lt;uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="17" /&gt;
</code></pre>

<p>Part of the code:</p>

<p>public class MainActivity extends Activity implements ActivityConstants {</p>

<pre><code>private static final long MIN_DIST_CHANGE_FOR_UPDATES = 1; //in meters
private static final long MIN_TIME_BETWEEN_UPDATES = 0; //in milliseconds
protected LocationManager locationManager;
private String provider;
Criteria criteria;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    locationManager=LocationManager)getSystemService(Context.LOCATION_SERVICE);
    criteria = new Criteria();
    provider = locationManager.getBestProvider(criteria, false);

    locationManager.requestLocationUpdates(provider, MIN_TIME_BETWEEN_UPDATES, MIN_DIST_CHANGE_FOR_UPDATES, new MyLocationListener());

}


public void myLocation(View view) {


    Location location =locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

    // If location is not null show a Toast with the location.
    if (location != null) {
        String message = String.format("Current location \n Longitude: %1$s \n Latitude: %2$s", location.getLongitude(), location.getLatitude());
        Toast.makeText(this, message, Toast.LENGTH_LONG).show();
    } else {
        Toast.makeText(this, "Latitude and longitude were not found", Toast.LENGTH_LONG).show();
    }


    if (Geocoder.isPresent()) {

        Geocoder geocoder = new Geocoder(MainActivity.this, Locale.getDefault());
        List&lt;Address&gt; addresses = null;
        double latitude = location.getLatitude();
        double longitude = location.getLongitude();

        try {
            addresses = geocoder.getFromLocation(latitude, longitude, 1);
        } catch (IOException e) {
            e.printStackTrace();
            Toast.makeText(MainActivity.this, e.toString(), Toast.LENGTH_LONG).show();
        }

        if (addresses.size() &gt; 0) {
            String address = "";
            for (int i = 0; i &lt; addresses.get(0).getMaxAddressLineIndex(); i++) {
                address += addresses.get(0).getAddressLine(i) + "\n";

            }

            Toast.makeText(MainActivity.this, "Your current address is: \n" + address, Toast.LENGTH_LONG).show();

        }


    }
}
</code></pre>
