android - activity.onPause not always getting called -


for reason onpause method not getting called when app put background. either or mylocationoverlay not disabling.

my app uses google maps , mylocationoverlay. when starting app, call mylocationoverlay.enablemylocation() in onresume method. in onpause method call mylocationoverlay.disablemylocation(). however, when hit home key or key go home screen, gps stays running indicated top of status bar gps icon.

edit: not work on either emulator or phone.

edit2: gps icon goes away when use advanced task killer kill it.

edit3: onpause being called put log statement in it, gps icon remains. therefore looks either gps service isn't shutting down, or mylocationoverlay has bug disablemylocation() method.

here manifest file , excerpts activity:

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:myapp="http://schemas.android.com/apk/res/com.tfb"   package="com.tfb"   android:versionname="1.2.2" android:versioncode="11"> <application android:icon="@drawable/globe_search"       android:label="@string/app_name"     android:theme="@android:style/theme.notitlebar">     <activity android:name=".activity.garagesalemap"               android:label="@string/app_name"               android:configchanges="keyboardhidden|orientation"               android:launchmode="singletop">         <intent-filter>             <action android:name="android.intent.action.main" />             <category android:name="android.intent.category.launcher" />         </intent-filter>         <intent-filter>             <action android:name="android.intent.action.search" />         </intent-filter>         <meta-data android:name="android.app.searchable"                    android:resource="@xml/searchable"/>    </activity>    <uses-library android:name="com.google.android.maps" /> <meta-data android:value="xxxxxxxxxxx" android:name="admob_publisher_id"/> <meta-data android:value="true" android:name="admob_allow_location_for_ads"/> </application> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_fine_location"/> <uses-sdk android:minsdkversion="4" android:targetsdkversion="8"/> </manifest>  

activity

private void domain() {     mapview = (mapview) findviewbyid(r.id.mapview);     mapview localmapview = mapview;      localmapview.setbuiltinzoomcontrols(true);     final mapcontroller controller = localmapview.getcontroller();      localmapview.getzoombuttonscontroller().setautodismissed(false);      lastsearchbutton = (imagebutton) findviewbyid(r.id.lastsearchbutton);     lastsearchbutton.setonclicklistener(new lastsearchbuttonlistener(this));      geopoint point = new geopoint((int)(40.8138 * 1e6), (int)(-96.6831 * 1e6));//lincoln, ne     controller.animateto(point);     controller.setzoom(13);      pushpinitemizedoverlay = getpushpinoverlay();     localmapview.getoverlays().add(pushpinitemizedoverlay);      new populatemaptask(this).execute();       locationoverlay = new fixedmylocationoverlay(this, localmapview);     localmapview.getoverlays().add(locationoverlay); }  @override protected void onpause() {     locationoverlay.disablemylocation();     super.onpause(); }  @override protected void onresume() {     locationoverlay.enablemylocation();     super.onresume(); } 

any appreciated.

i not positive, think may admob ad plugin using. if start app , hit home, gps icon not go away. however, if leave app running bit , come later , hit home, icon go away. maybe admob plugin (which am allowing location data) blocking gps shutdown until gets gps timeout or (i have tested inside no satellites available).

not sure when have time, have test removing admob plugin see, maybe else in meantime.

edit1: more info, have found if gps icon blinking still trying lock onto location. when gps indicator not go away when out of app. however, if icon steady (indicating lock on location), go away when exiting app. appears timeout issue. (i don't have unit test admob hypothesis on right now).


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -