Question

I have problem with resuming my app - when it goes to background due to something else opened (for example I call intent to open a navigation), or because phone sleeps; after return (another activity closed or phone woked up) my app remains in background, on onResume is never called (no errors in log, nothing). Why is this happening and how can I get rid of this behavior, where I should start looking?

public class MainActivity extends ...v4.app.FragmentActivity implements FewMyListeners {
    . . .
    private Locator locator;

@Override
public void onResume() {
    super.onResume();

    try {
        locator = new Locator(this);
    } catch (NoLocationProviderFoundException e) {
        showLocationSettingsDialog();
    }

    refreshLocation();
}

@Override
protected void onPause() {
    if(locator != null) {
        locator.removeUpdates(false);
        locator = null;
    }

    dismissProgressDialog();

    super.onPause();
}
}

public class Locator implements LocationSource, LocationListener { . . . }
Was it helpful?

Solution

It was the most idiotic "bug" ever - noHistory set to true. Reset it to false did the trick:

    <activity
        android:name=".MainActivity"
        android:noHistory="false">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

OTHER TIPS

Make sure that you have called the super.onResume() method in your overridded onResume() method

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top