[android-developers] Static boolean in Service resets after device comes back to sleep?
I have a Service that is launched from in a widget, when the service start's it sets a static boolean to either true or false depending if it's able to connect to a device in my home network. I have different buttons on my widget performing different task if we are connected, I also have an alarm that triggers an update at different intervals ( it sends a specific Intent to the widget ). Everything works fine, but if I leave the phone long enough it goes into sleep and when I return the buttons won't send any actions to the device because for some reason the connected boolean has changed from true to false. The strange thing is that if we are unable to connect the device, it prints out Unable to connect in the widget. But in this case it doesn't but the boolean has still changed to false. Example: if (mConnection.getConnection() != null) { CONNECTED = true; doStuff(); } else { CONNECTED = false; updateWidget(Unable to connect); stopSelf(); } So if the Service has been killed, and is re-launched and unable to connect the widget would have said Unable to connect instead shows a message that has not been valid for some minutes (and should have changed when the automated update triggers). I know my onClickListeners work because one button doesn't send a command but instead opens up an Activity, and that still works. Any ideas for this strange behaviour? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Static boolean in Service resets after device comes back to sleep?
After reading my text I just realized something! in the service onStartCommand() i check if the passed intent is != null and if that is the case proceed to check the connection state. But if the service was killed while in idle the intent would have been null and i would NOT have proceeded to check the connection state and the static boolean would now be false (senes the service has been re-created). I made fix so that if(intent != null) { doStuff(); } else { checkConnection();}. Now if the service is killed and later restarted it would check for the connection! // Fredrik On Jun 24, 3:18 pm, Freddman fredd...@gmail.com wrote: I have a Service that is launched from in a widget, when the service start's it sets a static boolean to either true or false depending if it's able to connect to a device in my home network. I have different buttons on my widget performing different task if we are connected, I also have an alarm that triggers an update at different intervals ( it sends a specific Intent to the widget ). Everything works fine, but if I leave the phone long enough it goes into sleep and when I return the buttons won't send any actions to the device because for some reason the connected boolean has changed from true to false. The strange thing is that if we are unable to connect the device, it prints out Unable to connect in the widget. But in this case it doesn't but the boolean has still changed to false. Example: if (mConnection.getConnection() != null) { CONNECTED = true; doStuff(); } else { CONNECTED = false; updateWidget(Unable to connect); stopSelf(); } So if the Service has been killed, and is re-launched and unable to connect the widget would have said Unable to connect instead shows a message that has not been valid for some minutes (and should have changed when the automated update triggers). I know my onClickListeners work because one button doesn't send a command but instead opens up an Activity, and that still works. Any ideas for this strange behaviour? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] How does Android PhoneNumberUtils determin the international call prefix for a specific country?
I noticed that when i recive an incoming international call, the call screen will show the entire number e.g beginning with '00' because Swedens call prefix is '00'. When i later dismissed the call, when the notification was shown in the status bar, the '00' had been replaced with '+'. How does Android determin the call prefix, and is it compatible with every country (e.g Indonesia can have 001 or 008 as call prefix)? Im writing an app where i determin the origin of the calling international number, but iv discovered the WAST number of possibilites a number can have. Example: 00 852 This could be a call from Hong Kong (00 +852 ) when living in Sweden, but also a call from Mexico when living in Indonesia ( 008 +52 ). -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How does Android PhoneNumberUtils determin the international call prefix for a specific country?
Sweden's prefix for dialing out is 00, but dialing in is 46. The problem i encountered was that when my app get's a number that is from Hong Kong (852) it adds (00) to the number, thus enabling me to redial the number. My app get's the number 00852 and determinds that 00 must be the dial out, and 852 is dial in for Hong Kong. But if i instead get a number from (52) 55 and i live in Indonesia i would append 008 in the begining sense in Indonesia dial out can be 008. The number would then look like 0085255, how to determin that 008 is the dial out, and 52 is country code ( for Mexico), and not dial out is 00 and country code is 852 ? On Apr 19, 10:34 am, Bernard T. Higonnet bthigon...@gmail.com wrote: On 04/19/11 10:29, Freddman wrote: I noticed that when i recive an incoming international call, the call screen will show the entire number e.g beginning with '00' because Swedens call prefix is '00'. When i later dismissed the call, when the notification was shown in the status bar, the '00' had been replaced with '+'. 00 is not Sweden's prefix, which actually is 46. 00 is the caller's local what follows is an international number code How does Android determin the call prefix, and is it compatible with every country (e.g Indonesia can have 001 or 008 as call prefix)? Im writing an app where i determin the origin of the calling international number, but iv discovered the WAST number of possibilites a number can have. Example: 00 852 This could be a call from Hong Kong (00 +852 ) when living in Sweden, but also a call from Mexico when living in Indonesia ( 008 +52 ). 852 is the code for Hong Kong everywhere... Bernard Higonnet -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How does Android PhoneNumberUtils determin the international call prefix for a specific country?
Im trying to figure out the origin of the incoming call and those don't have a '+' in the begining (i never seen anyone atleast). I'v noticed that when reciving an international call, it shows (00) (sense im in Sweden) in the begining of the number, but when i later rejected the call, my status notification (about missed call) had changed the 00 to '+'. So there must be something in Android that knows that 00 was the outbound prefix. On Apr 19, 1:35 pm, lbendlin l...@bendlin.us wrote: since you do all this on a mobile phone why not use the + notation for outgoing calls too? Let your mobile operator figure out how to connect the call. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Phone number formating on incoming call, determing country code?
Hi! I'm writing an app that reads the number for an incoming call. The idea is then it extract the country code if it's an international call. I'm not certain of how the phone numbers are formatted (if there is some kind of unified formatting for incoming numbers). Sometimes when in receive an international call, it can be formatted as +46 or some cases 0046. Is there a simple way to extract the country code from a number? Or perhaps re-format the number so that the country code easily can be extract. Iv taken a look at the PhoneNumberUtils class, but so far i haven't struck gold :( Any help is appreciated! Fredrik -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en