Android :: Phone State Listener State Transitions

Feb 8, 2009

I'm a little confused by what I'm seeing with regards to phone state transitions via the PhoneStateListener. When I receive a call, this is what happens: (call comes in) RINGING -> IDLE (I pick up) OFFHOOK (I hang up) IDLE It's that first transition from RINGING to IDLE without any interaction from me (not ending the call, not answering the call) that confuses me. Do I really have to implement an idle counter to know that an incoming call has really ended? Seems like the reported phone state represents some sort of phone state that isn't the obvious one.Is this a bug or am I just not in tune with the paradigm here?

Android :: Phone State Listener state transitions


Android :: Phone State Listener Memory Leak

Sep 8, 2009

There appears to be a leak when using PhoneStateListeners. The following code simply reigsters in onResume and unregisters in onPause a PhoneStateListener. Repeatedly launch then press BACK (so the app is finished & onDestory is called before the next launch) and the number of activities reported by meminfo will equal the number of launches. For instance, here is the output I get after launching (and finishing) 11 times in sequence:

dumpsys meminfo com.example.leak Currently running services: meminfo
DUMP OF SERVICE meminfo: Applications Memory Usage (kB): Uptime: 12204322 Realtime: 12204322

** MEMINFO in pid 1358 [com.example.leak] ** native dalvik other total size:
2648 3079 N/A 5727
allocated: 2604 2254 N/A 4858
free: 43 825 N/A 868
(Pss): 913 1305 1475 3693
(shared dirty): 1080 3864 568 5512
(priv dirty): 808 936 1056 2800

Objects Views: 77
ViewRoots: AppContexts: 12
Activities: 11
Assets: 2
AssetManagers: 2
Local Binders: 36
Proxy Binders: 21
Death Recipients: 0
OpenSSL Sockets: 0
SQL heap: 0
dbFiles: 0
numPagers: 0
inactivePageKB: 0
activePageKB: 0 #

Without the PhoneStateListener, the number of activities is always 1 no matter how many times the app is launched & finished. So, am I doing anything wrong here? Or is this a bug in the TelephonyManager?

Here's the code package com.example.leak;

import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.util.Log;
public class LeakExample extends Activity {
private class MyPhoneStateListener extends PhoneStateListener {
@Override public void onCallStateChanged(int state, String incomingNumber) {
if ((state == TelephonyManager.CALL_STATE_RINGING)
|| (state == TelephonyManager.CALL_STATE_OFFHOOK)) {
LeakExample.this.finish();
} } }
MyPhoneStateListener phone_listener = new MyPhoneStateListener();
TelephonyManager telMgr ;
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
telMgr = (TelephonyManager) getSystemService (Context.TELEPHONY_SERVICE);
} @Override protected void onPause() { super.onPause();
telMgr.listen(phone_listener, PhoneStateListener.LISTEN_NONE);
} @Override protected void onResume() { super.onResume();
telMgr.listen(phone_listener, PhoneStateListener.LISTEN_CALL_STATE);
} @Override protected void onDestroy() { super.onDestroy();
Log.v("LEAK EXAMPLE", "onDestory");
}

View 3 Replies View Related

Android :: Telephony Manager & Phone State Listener

Sep 7, 2010

I would like to know what are the main differences between TelephonyManager and PhoneStateListener, because you can do (more or less) the same things with both. For example, you could create an incoming calls register implementing a broadcastreceiver and using TelephonyManger API or extending PhoneStateListener class and registering this new listener throughTelephonyManager . Case 1 - BroadcastReceiver (TelephonyManager)

View 13 Replies View Related

Android :: Notify Service From Phone State Listener

Mar 19, 2010

I have built an application that listen to call state changes, and I want to notify a service when the call_state became IDLE.All the components I have are functional, I just need to notify (not start) a service for this.What's the correct practice, maybe using AIDL? Because, in a PhoneStateListener, I can't bind to a service. Do I have to start an activity for that?

View 2 Replies View Related

Android :: Error With Listening To Phone State Listener In Service

Nov 11, 2009

I have a BroadcastReceiver that listens for the BOOT_COMPLETED, that part works I know because I disabled my phone listener and displayed a Toast within. That BroadcastReceiver is supposed to start a service, that also works. I run into Force Close issues when my service attempts to tell my TelephonyManager to listen. Any one have any ideas? Here is my code StartSeviceAtStartUp.java import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent;

View 3 Replies View Related

Android :: Reregister Phone State Listener If Application Crashed

Nov 17, 2009

i've registered a PhoneStateListener in BOOT_COMPLETED receiver by using following call: tm.listen(new TestCallStateListener(), PhoneStateListener. LISTEN_ CALL _STATE); If the application crashes then system automatically unregisters the PhoneStateListener. Is there any mechanism of checking if particular PhoneStateLister is registered or not? Actually i'm thinking of starting a repeating service by AlarmManager which will check if PhoneStateListener is registered or not . And if it's not registered then service will register it again. Just a backup if application crashes. Is this a good approach or there is some better mechanism to make sure that PhoneStateListener is always registered even if application crashes ?

View 2 Replies View Related

Android :: Phone State Listener Events Stop Receiving Sometime

Jan 21, 2010

My application process incoming/outgoing calls and shows some UI. So I use PhoneState Listener to listen changes such as CALL_STATE_IDLE , CALL_STATE_RINGING ,CALL_ STATE_ OFFHOOK. on receiving call to my BroacastReceiver for incoming/outgoing call. Most of the time things work properly. But sometimes my application does not receive events of Phone State Listener and hence it is not able to change/clear UI.From user feedback this typically occurs on HTC Hero. But I have came across this issue sometime on other devices also.My first guess is that android is killing my application in midway during call due to memory requirement. If so, is there any way to ensure that android does not my kill application under such situation .

View 1 Replies View Related

Android :: Changing Displayed State Of Views Based On Parent ViewGroup's State

Aug 11, 2010

I have a compound UI component built up from a ViewGroup containing a number of TextView, ImageView etc. components. Many of these have StateListDrawables as their images/backgrounds. Is there any way of making them select from this drawable based on the state of the parent ViewGroup rather than the component itself? Ideally I want to be able to change the visual state of all children of the ViewGroup (text colour, image etc) based on the state of the ViewGroup, preferably without having to hook up complex logical code. This seems like a fairly common sort of requirement, so I was hoping it would be straightforward in Android - am I going to be disappointed?

View 1 Replies View Related

Android :: How To Save App State In Phone?

Aug 30, 2010

I am writing an app where I get all the data from the rest call and display all the data in a custom component list(based on Linear Layout) which is added to a LinearLayout. I write this code in onCreate of the activity. The problem is when I switch activity using startActivity, and come back to the calling activity (using startActivity) then onCreate is called again. I see onPause, onStop called when I call other activity. Is there any way that I can save the application's state?

View 1 Replies View Related

Android :: Using Broadcast Intents / Phone State Changes

Jun 29, 2010

I was just working on an application that will do stuff when a call is missed or made; and am left wondering why do you have to register a listener using a long lived background service for phone state changes instead of being able to use broadcast intents?

View 2 Replies View Related

Android :: Read Phone State And Identity?

Feb 27, 2010

For applications that set the android.permission.READ_PHONE_STATE permission. What is meant by "identity" in the permission description "read phone state and identity"? Users ask about this and we don't know what to tell them...

View 5 Replies View Related

Android :: Need To Allow State Of A Correct Phone Call

Oct 14, 2009

I can see that we can get a phonestate via the PhoneStateListener, but there is no way of telling the state of the call. OFFHOOK is a number of states combined into one. Is there a particular reason for this? Are we not allowed to see the correct state of a call?

View 2 Replies View Related

Android :: How Do I Get State Of Outgoing Call In Phone?

May 20, 2010

I noticed in the class TelephonyManager there are CALL_STATE_IDLE, CALL_STATE_OFFHOOK adn CALL_STATE_RINGING. They seem to be used for incoming calls.What I actually want to do is to be notified when an outgoing call is made, is received, or timed out. How to do that?

View 2 Replies View Related

Android : Opening Phone Deletes App State

Jun 10, 2010

I'm writing an android application that maintains a lot of "state" data...some of it I can save in the form of onSaveInstanceState but some of it is just to complex to save in memory.

My problem is that sliding the phone open destroys/recreates the app, and I lose all my application state in the process. The same thing happens with the "back" button, but I overloaded that function on my way. Is there any way to overload the phone opening to prevent it from happening?

View 2 Replies View Related

Android :: Application Read Phone State And Identity?

Dec 6, 2009

Anyone know what providing an application access to "Phone calls: read phone state and identity" actually does?

View 5 Replies View Related

Android :: Phone Won't Save Current State Of An Activity / Way To Do

Nov 17, 2010

I am trying to save some values in the onSaveInstanceState(Bundle) method of my activty by following the example here: How do I save an Android application's state?

But it doesnt seem to load it from the Oncreate(). the bundle object is always null but whenever i call another activity, it does indeed go into the onSaveInstanceState method to save my values.

Now i read that question i just posted and someone noted how they could not get it to work in an emulator? unfortunately that is all im working on. On an emulator and cant test the app on the device as i have no device available to me right now And the web services i am interacting with are in a local VM on my work machine that cannot be accesses remotely at the moment.

My question is, is it true that saved bundles dont work on emulators? I also noticed how when i do dismiss or bring up a new activity , the activity calles onPause and then onStop. when i bring back the same activty, it goes straight to onCreate?

now according to the docs here http://developer.android.com/guide/topics/fundamentals.html#actlife That is correct in terms of what the lifecycle diagram shows but if you read below that diagram on the onStop() section it says the next step it goes into is either onRestart() or onDestroy()? no mention of onCreate? Type on the docs?

Anyways here is my onSaveInstanceState() and onCreate() both in the same activity: code...

View 1 Replies View Related

Android :: Application Installer Tells That My App Reads Phone State And Identity

Apr 18, 2010

I have a simple app with a surfaceview nothing special one would say. However when installing on my phone I get two warnings.
1 - Phone calls
- read phone state and identity
2 - Storage
- modify/delete SD card content.
My really is nothing more than a simple puzzle and I dont understand why I get these warnings.

View 2 Replies View Related

HTC EVO 4G :: Reset Phone Later Back To Factory State After Root?

Oct 12, 2010

If you root your evo can you reset it later back to factory state.

View 1 Replies View Related

General :: Phone Won't Turn On And Reverts To Previous State

Sep 6, 2013

I have a Droid RAZR MAXX running Android 4.1.2 and for some reason my phone just freezes overnight. When I wake up the notification light may or may not be blinking and when I try to press the power button to wake it from sleep the screen will stay off. I usually need to perform a hard reboot by pressing the power and volume down button. After that I turn it back on by holding the power button as usual and I will be greeted with most of my settings reset and all apps reverted to their previous state. For example: If I update the Play Store app the day before it will be reverted back as if it was never updated.

View 4 Replies View Related

Samsung Behold 2 :: Killed My Phone - Restore This Phone Back To Its Original State?

Apr 20, 2010

I was trying to root my samsng behold 2 earlier today using the command codes on theunlockr.com. I thought everything was going well as I went all the way to the last step where it rebooted my behold 2. Problem is, the phone kinda just turned off after doing the reboot command and didn't turn back on by itself (I gave it like 10 minutes). I eventually then just turned on the phone manually and noticed that everything was super laggy. Even when I used taskkiller to kill every task minus GDE, it said I only had 38MB ram available. I rebooted my phone a few times and it was laggy everytime so I decided to do a hard reset. The problem is that when I attempted the hard-reset, it will now get stuck on the samsung screen when trying to load up (stayed there for over 30 minutes). I can still enter the phone if I just start it up regularly without trying to hard-reset, but it will continue to be VERY laggy.

Is there anything I can do to restore this phone back to its original state? I was reading about using ODIN to flash it or something, but for some reason my computer doesn't detect my phone when I go into Download mode on startup (it does however detect the usb drivers on my phone once the phone officially startsup into its homepage).

View 7 Replies View Related

HTC Droid Eris :: Revert Phone Back To Its Original State?

Aug 12, 2010

I created a backup while following rooting instructions for mac (http://androidforums.com/htc-droid-eris/125436-detailed-leak-root-tutorial.html) so I figure I should be able to revert the phone back to its original state. How do I do this?

View 6 Replies View Related

Motorola Droid X :: Wireless Tether Says My Phone Is In An Unknown State / Why Is So?

Oct 4, 2010

Not sure why I have 2.2 rooted and its giving me this error. Anyone know why?

View 2 Replies View Related

Samsung Captivate :: Can Get Phone And It's Internal Storage To Factory Fresh State?

Jul 21, 2010

I've recently restored my phone to factory defaults and it decided not to remove my music. Is there any way I can get my phone and it's internal storage to a "factory fresh" state?

View 3 Replies View Related

Android :: Android Permissions - Calls Read Phone State / Identity?

Nov 17, 2009

My android app has nothing to do with phone calls, but I'm seeing that when I install a debug build on my test device it requires "Phone Calls: read phone state and identity" permissions. (I make no mention of this in AndroidManifest.xml). I'd like to have the minimum possible permissions, and wondered if anyone knew how to get rid of this? I commented out the part where I was logging some stuff from Build.MODEL, Build.VERSION.*, etc. I also commented out the part where I was detecting the landscape/portrait orientation thinking that that might be the "phone state". But neither of those seemed to remove that permission required.

I found this bug report but it's marked working-as-intended with a note about permissions being correct from the market but not otherwise. Is this other people's experience? (I'd hate to have to publish to the market just to test that out.) Otherwise, does anyone know if there's an API I can avoid calling that will make it so my app doesn't need this permission?

View 4 Replies View Related

Android :: How To Read USB State?

Oct 27, 2009

Is it possible to know when the user unplugs a charger or headsets from the device so I can trigger something..

View 2 Replies View Related

Android :: How To Get Service State?

Jan 6, 2010

I'm trying to get current service state of my phone. It can be easily fetched with get State() method of Service State when a on Service State Changed (Service State service State) callback is invoked: Code...

View 2 Replies View Related

Android :: Dev - Save State

Sep 1, 2010

can someone helpme out with how to save state of the app when the screen orientation is changed i read the development guide at http://developer.android.com/guide/topics/resources/runtime-changes.html#HandlingTheChange

But i dont know how to define the method collectMyLoadedData();

View 2 Replies View Related

Android :: Screen On/Off State?

Nov 3, 2009

I have an app that runs in the background indefinitely provided there is work to be done. I want the app to go to sleep if there is no work to be done and the user is idle. The second part has me stumped. On Windows Mobile I was able to poll the power state to determine user idleness. On BlackBerry I was able to poll the device idle time. However, there does not appear to be a way to determine user idleness on Android.

Instead of polling for user idleness directly, I thought I might be able to use the on/off state of the screen. There are 2 intents ACTION_SCREEN_OFF and ACTION_SCREEN_ON and I was able to setup a listener for these (BroadcastReceiver). The problem is that I do not know how to determine the current state of the screen at the time I register the listener, therefore I have to wait until the next screen on/off change to know anything. The docs speak of some intents that are "sticky" and thus will allow the current state to be determined, but the screen events do not appear to have that property. What am I to do?

In general, I find the lack of support for polling system state properties (e.g. screen state, power state, signal strength) in Android to be annoying. It's cool that one can listen for changes in system state rather than constantly polling for them, but one still needs to know the current state of the property at the time the listener is registered.

View 10 Replies View Related

Android :: Restore Instance State

Aug 24, 2010

I need to save some state when the user leaves my game during game play. Saving the state doesn't seem to be an issue, but I can't figure out how to restore it. The onCreate function isn't called when the Activity is resumed (only when it is first created), so I can't get my state back there. Logically, I would use onRestoreInstanceState, but it isn't being called.

CODE:..........

I see log output from onSaveInstanceState, onResume, onCreate, etc, but I never see a log message from onRestoreInstanceState and savedState is always null. Why isn't onRestoreInstanceState being called, and is there another way to get my state back?

View 1 Replies View Related

Android :: Usability / State Vs Verb?

Feb 26, 2010

My business partner and I have a small disagreement, and I'm trying to figure out the best way to resolve it. First, I should say I started out his way, and switched after reviewing a lot of applications. The background is this -- we have an app, with some controls which can be locked. A lock/unlock icon is put next to the lockable controls. You can long-click the icon, and it brings up a context menu with several items, including the item for the lock state.Currently, it brings up a "Locked [X]" or "Locked [ ]" item -- that is, a menu item with a checkbox that can be checked or unchecked, and the lock state is changed accordingly.He would like me to change it to reflect the action being taken. I.e. the menu item would say "Lock" if it is currently unlocked, and "Unlock" if it is currently locked.It would be acting as a toggle in either case; the only difference is how it is presented to the user.

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved