开发者

How to create a incomming call broad receiver programatically

开发者 https://www.devze.com 2023-04-11 09:34 出处:网络
I have managed to put a broadcast receiver from the manifest file, it looks like this: <receiver android:name=\".BReceivers.CallBReciever\">

I have managed to put a broadcast receiver from the manifest file, it looks like this:

    <receiver android:name=".BReceivers.CallBReciever">
        <intent-filter>
            <action android:name="android.intent.action.PHONE_STATE" />
        </intent-filter>
    </receiver>

Now what i am trying to do is to take it out of the manifest and start it only when the user presses a certain button, which should look somethings like this:

        Button start = (Button) findViewById(R.id.Button_Start);

        start.setOnClickListe开发者_StackOverflow中文版ner(new View.OnClickListener() {

        public void onClick(View v) {


                    @Override
                    public void onReceive(Context context, Intent arg1) {
                        Log.d("aaa", "bbb");
                        switch (getResultCode())
                        {

                        }
                    }
                }, new IntentFilter(Intent.ACTION_CALL));


            }
        }
    });

But i don't get into the receiver, any idea why? what IntentFilter String param should i use?


You have to implement phone state listener to listen your call state

for more information refer this

0

精彩评论

暂无评论...
验证码 换一张
取 消