Canyou please post the cade about getcallstate() On Sat, Feb 11, 2012 at 6:16 PM, Nitin Sethi <sethi.5...@gmail.com> wrote:
> Hi All, > > I could finally sort out this issue. It so turns out that the > Broadcast Intent i want to receive doesn't linger for long enough for > your receiver to consume it and process it. In technical words, the > intent is NOT STICKY. Hence, I had to get the state using the method > getCallState() to process the Intent. :) > > On Feb 11, 3:59 pm, Nitin Sethi <sethi.5...@gmail.com> wrote: > > Hi All, > > > > I have been trying very hard to get it work in my Gingerbread 2.3.5 > > phone but with no success. I have read all the posts and have come up > > with the below code which works very rarely. I suspect it has > > permissions issue but could not zero in on the issue which is bugging > > me for long. > > > > My Manifest: > > > > <?xml version="1.0" encoding="utf-8"?> > > <manifest xmlns:android="http://schemas.android.com/apk/res/android" > > package="utils.self.puttu" > > android:versionCode="1" > > android:versionName="1.0" > > > > > <uses-sdk android:minSdkVersion="10" /> > > > > <uses-permission > > android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> > > <uses-permission > > android:name="android.permission.READ_PHONE_STATE" /> > > > > <application > > > <receiver android:name=".PersonalisedSetting" > > > <intent-filter > > > <action > > android:name="android.intent.action.PHONE_STATE" /> > > </intent-filter> > > </receiver> > > </application> > > > > </manifest> > > > > My Receiver: > > > > package utils.self.puttu; > > > > import android.content.BroadcastReceiver; > > import android.content.Context; > > import android.content.Intent; > > import android.media.AudioManager; > > import android.telephony.TelephonyManager; > > import android.widget.Toast; > > > > public class PersonalisedSetting extends BroadcastReceiver { > > // private PhoneStateListener myListener = null; > > @Override > > public void onReceive(Context context, Intent intent) { > > > > // if > (intent.getStringExtra(TelephonyManager.EXTRA_STATE) == > > // TelephonyManager.CALL_STATE_RINGING) > > > > String number = intent > > > .getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER); > > > > if (number.equals("+919742431366") || > number.equals("9742431366")) > > { // My Gf's Number :D > > AudioManager vAudioManager = (AudioManager) > context > > > .getSystemService(Context.AUDIO_SERVICE); > > int maxVolume = vAudioManager > > > .getStreamMaxVolume(AudioManager.STREAM_RING); > > > > > vAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL); > > > vAudioManager.setStreamVolume(AudioManager.STREAM_RING, maxVolume, > > AudioManager.FLAG_SHOW_UI); > > } else { > > Toast.makeText(context, "Forget it", > Toast.LENGTH_LONG).show(); > > } > > > > } > > > > > > > > > > > > > > > > } > > -- > 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 > -- 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