Hi,
Been having some issues with my PhoneStateListener, what i would like
it to do is to always listen to CellLocationUpdates even when the
phone "sleeps". I am currently trying to do this with the following
code.
public class MyService extends Service {
...
public void onCreate() {
// Start listening to the phone
mMyPhoneListener = new MyPhoneStateListener(this);
mTelephonyManager = (TelephonyManager)getSystemService
(TELEPHONY_SERVICE);
mTelephonyManager.listen(mMGPhoneListener,
PhoneStateListener.LISTEN_CELL_LOCATION)
mPm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWl = mPm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MYS");
mWl.acquire();
Log.d("MGS", "ServiceOnCreate");
}
public void onDestroy() {
// Stop listen to the location updates
mTelephonyManager.listen(mMGPhoneListener,
PhoneStateListener.LISTEN_NONE);
// Release wake lock
mWl.release();
Log.d("MGS", "ServiceOnDestroy");
}
}
public class MyPhoneStateListener extends PhoneStateListener {
public void onCellLocationChanged(CellLocation location) {
// DOING SOME LOGGING
}
}
Even though i am using a PARTIAL_WAKE_LOCK the CellLocationUpdates
stop when the phone "sleeps", i am almost certain that my service is
not getting destroyed as i have debug in place onDestroy to show this
happening on logcat.
I have also noticed this on logcat,
D/MGS ( 6153): ServiceOnCreate (my debug of the service starting)
and
D/SurfaceFlinger( 59): About to give-up screen, flinger = 0x1841e8
D/dalvikvm( 143): GC freed 54 objects / 2328 bytes in 146ms
D/dalvikvm( 6153): GC freed 2115 objects / 126456 bytes in 140ms
Is this android freeing up the memory from my service? looks like the
same PID?
Can anyone shed some light on why i am not receiving any updates after
the screen/phone "sleeps"?
Thanks Liam.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---