a service example?

Put your problem here if it does not fit any of the other categories.

a service example?

Postby chouman » Mon Sep 29, 2008 10:25 pm

Is there a service example anywhere?

i am trying to write a class that extends service and in the service i will setup the call state listener. Not working out too well.

i see this in the logcat.

09-29 21:13:14.983: WARN/ActivityManager(53): Scheduling restart of crashed service com.asurion.android.activity/.CallStateService in 5000ms



this is what i have:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class CallStateService extends Service
  3.  
  4. {
  5.  
  6.         private Context f_context;
  7.  
  8.        
  9.  
  10.         public IBinder onBind(Intent intent)
  11.  
  12.         {
  13.  
  14.                 return null;
  15.  
  16.         }
  17.  
  18.        
  19.  
  20.         public void onStart(Intent intent, int startId)
  21.  
  22.         {
  23.  
  24.                 super.onStart(intent, startId);
  25.  
  26.                 Logger.log("starting call state listener");
  27.  
  28.                 f_context = getApplicationContext();
  29.  
  30.                 TelephonyManager tManager = (TelephonyManager)f_context.getSystemService(Context.TELEPHONY_SERVICE);
  31.  
  32.                 tManager.listen(new CallStateListener(), PhoneStateListener.LISTEN_CALL_STATE);
  33.  
  34.                 Logger.log("LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLListenting");
  35.  
  36.         }
  37.  
  38.        
  39.  
  40.         public void onDestroy()
  41.  
  42.         {
  43.  
  44.                 super.onDestroy();
  45.  
  46.                 Logger.log("DOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOON'T kill me =(");
  47.  
  48.         }
  49.  
  50.        
  51.  
  52.         private class CallStateListener extends PhoneStateListener
  53.  
  54.         {
  55.  
  56.                 public void onCallStateChanged(int state, String incomingNumber)
  57.  
  58.                 {
  59.  
  60.                         Log.d("DEBUG", "addddddddddddddddddding this here");
  61.  
  62.                         super.onCallStateChanged(state, incomingNumber);
  63.  
  64.                         Log.d("DEBUG", TelephonyManager.CALL_STATE_OFFHOOK + " weeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee are def in here: " + state);
  65.  
  66.                        
  67.  
  68.                         switch(state)
  69.  
  70.                         {
  71.  
  72.                                 case TelephonyManager.CALL_STATE_IDLE:
  73.  
  74.                                         Logger.log("phhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhone is idle");
  75.  
  76.                                         break;
  77.  
  78.                                 case TelephonyManager.CALL_STATE_OFFHOOK:
  79.  
  80.                                         Logger.log("phoooooooooooooooooooooooooooooooooooooon is off hook");
  81.  
  82.                                         break;
  83.  
  84.                                 case TelephonyManager.CALL_STATE_RINGING:
  85.  
  86.                                         Logger.log("phoooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnnnnnnneeeeeeeeeeeeeeeeee is ringing");
  87.  
  88.                                         break;
  89.  
  90.                                 default:
  91.  
  92.                                         Logger.log("The staaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaate is " + state);
  93.  
  94.                                                
  95.  
  96.                         }
  97.  
  98.                 }
  99.  
  100.         }
  101.  
  102. }
  103.  
  104.  
Parsed in 0.037 seconds, using GeSHi 1.0.8.4
chouman
Developer
Developer
 
Posts: 27
Joined: Thu Jan 03, 2008 2:59 pm

Top

Postby cassianotartari » Tue Sep 30, 2008 1:49 am

Maybe this: http://www.helloandroid.com/node/140 can help you
public class pessoa {
private String nome = "Cassiano Tartari";
private String url = "www.cassianotartari.eng.br"
}
User avatar
cassianotartari
Developer
Developer
 
Posts: 28
Joined: Thu Aug 28, 2008 3:42 pm

Postby soniya » Mon Oct 27, 2008 8:25 am

Hi chouman,
i have same problem...could u plz help me ???
soniya
Senior Developer
Senior Developer
 
Posts: 111
Joined: Mon Jan 14, 2008 1:52 pm
Location: india

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google Feedfetcher and 15 guests