开发者

Adding a button to the default incoming call screen in Android

I'm in the process of developing an Android app for which I need to add a butt开发者_如何学Pythonon on the incoming call screen. Is it possible to add a new button to the existing incoming call screen or should I create a custom screen specific to my app?

Edit: I want to add a button in addition to the Answer and Decline buttons in the screen that appears when there is an incoming call.


I was looking for the same funcionality and found this open source project, http://code.google.com/p/incomingcallplus/

Haven't played with it yet, but seems to do what you're looking for.


Yes and No.

No, you can't add a new button to an existing app. But Yes, you can replace that app (in this case, the dialer) with one that has the button you want. When users install your app, they'll pick whether they want to use your app or the built-in dialer app to make and receive calls.


You probably want to add something like the following to your main.xml:

<Button android:id="@+id/helloButton" android:layout_height="wrap_content" android:layout_width="wrap_content" text="Hello Button" />

Then in your 'Launcher' activity, you'll need to assign a handler to handle clicks, etc.


If you want to do this on the default dialer screen then I don't think that's possible without disabling controls of the dialer and having your transparent activity over the dialer; user will be able to interact with your activity and can only use the dialer on clicking the back button.

You might want to go with the custom design.


public void addInvitePopup(final String number,Context c){
    //check if pref is ok with invite in call
   // if(!Preferences.getInstance(c.getInviteInCall())){return ; }
    // sets the WindowManager
    WindowManager wm = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE);

    WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_SYSTEM_ALERT | 
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            PixelFormat.TRANSLUCENT);
    params.x = 250;
    params.height = LayoutParams.WRAP_CONTENT;
    params.width = LayoutParams.WRAP_CONTENT;
    params.format = PixelFormat.TRANSLUCENT;
     final Context ct =c;

    params.gravity = Gravity.TOP;
    params.setTitle("Testing");

    LinearLayout ly = new LinearLayout(c);
    ly.setOrientation(LinearLayout.VERTICAL);

    Button inviteButton = new Button(c);
    inviteButton.setClickable(true);
    inviteButton.setBackgroundDrawable(c.getResources().getDrawable(R.drawable.icon));
    inviteButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(v.getContext(), "adding to blacklist..", Toast.LENGTH_LONG).show();
            v.setBackgroundDrawable(ct.getResources().getDrawable(R.drawable.images));
            v.setClickable(false);
           // sendMessage(v, number);

            //Track this event:
            //MixPanelTracking.setPropKeyValue(getApplicationContext(), null, null, "Add friend - During Call");
        }
    });

also dont forget to add permission : android.permission.SYSTEM_ALERT_WINDOW in your manifest file

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜