Yeah, that sounds correct. I was not shure that this is the problem, cause its only a object reference but may something is done with the listener by calling telephonyManager.listen().
-Danny 2010/12/8 Kostya Vasilyev <[email protected]> > These two lines are backwards: > > > telephonyManager.listen(listener,PhoneStateListener.LISTEN_CALL_STATE); > > listener = new PhoneStateListener() { > > The listener is still null when telephonyManager.listen() is called. > > Debugging or checking the logcat would have shown this. > > Also, when your code crashes, adding a try/catch block that drops the > exception on the floor (without logging) is not the best way to debug =-O > > -- Kostya > > 08.12.2010 16:56, Danny Schimke пишет: > > What is not working? Any concrete exceptions in debug view? Like Dan says > we need more information. Does a exception occur? > > -Danny > > 2010/12/8 DanH <[email protected]> > >> You never compiled it? Never executed it? >> >> (Some symptoms would be helpful.) >> >> On Dec 7, 9:35 am, nirav sabhaya <[email protected]> wrote: >> > BroadcastExample.java >> > ---------------------------------- >> > package com.example.broadcast; >> > >> > import android.app.Activity; >> > import android.content.Context; >> > import android.os.Bundle; >> > import android.telephony.*; >> > import android.util.Log; >> > import android.widget.TextView; >> > >> > public class BroadcastExaple extends Activity { >> > TextView textOut; >> > TelephonyManager telephonyManager; >> > PhoneStateListener listener; >> > >> > /** Called when the activity is first created. */ >> > @Override >> > public void onCreate(Bundle savedInstanceState) { >> > >> > try { >> > >> > super.onCreate(savedInstanceState); >> > >> > // Get the UI >> > textOut = new TextView(this); >> > textOut.setText("DEmoBroadCast"); >> > setContentView(textOut); >> > >> > // Get the telephony manager >> > telephonyManager = (TelephonyManager) >> > getSystemService(Context.TELEPHONY_SERVICE); >> > >> > // Register the listener wit the telephony manager >> > >> > telephonyManager.listen(listener,PhoneStateListener.LISTEN_CALL_STATE); >> > >> > // Create a new PhoneStateListener >> > listener = new PhoneStateListener() { >> > >> > @Override >> > public void onCallStateChanged(int state, String >> > incomingNumber) { >> > Log.d("DEBUG", "Phone listener...."); >> > String stateString = "N/A"; >> > switch (state) { >> > case TelephonyManager.CALL_STATE_IDLE: >> > stateString = "Idle"; >> > break; >> > case TelephonyManager.CALL_STATE_OFFHOOK: >> > stateString = "Off Hook"; >> > break; >> > case TelephonyManager.CALL_STATE_RINGING: >> > stateString = "Ringing"; >> > break; >> > } >> > textOut.append(String.format("\nonCallStateChanged: >> %s", >> > stateString)); >> > } >> > }; >> > >> > } catch (Exception e) { >> > >> > } >> > >> > } >> > >> > } >> > >> > AndroidManifest.xml >> > ------------------------------- >> > <?xml version="1.0" encoding="utf-8"?> >> > <manifest xmlns:android="http://schemas.android.com/apk/res/android" >> > package="com.example.broadcast" android:versionCode="1" >> > android:versionName="1.0"> >> > <application android:icon="@drawable/icon" >> > android:label="@string/app_name"> >> > <activity android:name=".BroadcastExaple" >> > android:label="@string/app_name"> >> > <intent-filter> >> > <action android:name="android.intent.action.MAIN" /> >> > <category >> android:name="android.intent.category.LAUNCHER" /> >> > </intent-filter> >> > </activity> >> > </application> >> > <uses-prmission android:name="android.permission.READ_PHONE_STATE" >> /> >> > <uses-sdk android:minSdkVersion="7" /> >> > </manifest> >> > >> > Anybody can indicate me why this code doesn't work...... >> > >> > Thanks............ >> > >> > On Tue, Dec 7, 2010 at 7:35 PM, Kostya Vasilyev <[email protected]> >> wrote: >> > > Danny, >> > >> > > The values in R can change as you add and remove resources. >> > >> > > I'd say store color names, or actual RGB values (and match them to >> names >> > > when need to present to the user). >> > >> > > -- Kostya >> > >> > > 07.12.2010 16:56, Danny Schimke пишет: >> > >> > > Hi, >> > >> > >> I have 2 textual inputs that I saved to database, furthermore I have >> a >> > >> spinner with color selection. Color names and color values both >> stored in >> > >> the application resources. I want to save a color in the database, >> but what >> > >> is the best way to do this in your mind? Should I save the resource >> id? I >> > >> figured out, that the int value of the color resource is allways the >> same, >> > >> e.g. when I delete the "R" file and let it recreate. I do not have >> the >> > >> certainty that this is correct?! >> > >> > >> Or would you put colors in a seperate database table instead using >> > >> resources for this? This seems to be a good way and the user is able >> to add >> > >> own colors to the application. >> > >> > >> I don't know what is the best way to store this. What are your >> > >> experiences? >> > >> > >> Thank you very much! >> > >> -Danny Schimke >> > >> -- >> > >> 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]<android-developers%[email protected]> >> <android-developers%[email protected]<android-developers%[email protected]> >> > >> > >> For more options, visit this group at >> > >>http://groups.google.com/group/android-developers?hl=en >> > >> > > -- >> > > Kostya Vasilyev -- WiFi Manager + pretty widget -- >> > >http://kmansoft.wordpress.com >> > >> > > -- >> > > 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]<android-developers%[email protected]> >> <android-developers%[email protected]<android-developers%[email protected]> >> > >> > > For more options, visit this group at >> > >http://groups.google.com/group/android-developers?hl=en >> >> -- >> 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]<android-developers%[email protected]> >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> > > -- > 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 > > > > -- > Kostya Vasilyev -- WiFi Manager + pretty widget -- > http://kmansoft.wordpress.com > > -- > 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]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- 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

