2

I am trying to launch my custom screen on top of native outgoing caller screen that may contain full Screen image of Caller and some buttons for actions like reject call. Using this I am able to make call, but is redirecting me to native caller screen...

How to replace\override the default call screen by my custom screen screen?

startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phonenumber)));
public class GetOutgoingNUmber extends BroadcastReceiver {


final static String INTENT_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";

@Override
public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub
    Log.v("DileBroadCastReceiver","In onReceive()");

    if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {

         new Handler().postDelayed(new Runnable() {
             @Override
             public void run() {
                 Intent i = new Intent(context, OutGoingScreen.class);
                i.putExtras(intent);
                i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
                context.startActivity(i);
             }
         }, 1000);
}

here OutGoingScreen is for displaying outgoing screen

  public class OutGoingScreen extends Activity {
 @Override
    protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.outgoingscreen );

    }
}

Now the problem is it is showing my screen for few msec and again showing native screen....?

Aniket
  • 37
  • 2
  • 9

3 Answers3

2

Write a receiver for outgoing call

public class OutgoingCallReceiver extends BroadcastReceiver {
@Override
    public void onReceive(final Context context, final Intent intent) {
      //Write intent for yout page
  }
}

add these to Manifest

<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

<receiver android:name=.OutgoingCallReceiver" >
   <intent-filter>
      <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
   </intent-filter>
 </receiver>

add below theme to activity theme

android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"

Open you intent after 1 second bcoz the original outgoing call screen takes 800ms to open so you need to over lay that screen, so you must call intent after 800ms. it works for me.

Massimo
  • 3,436
  • 4
  • 40
  • 68
Poovizhirajan N
  • 1,263
  • 1
  • 13
  • 29
  • i have edited my code accordingly. thank you. but still not getting my screen. – Aniket Oct 07 '13 at 05:54
  • how to delay it? should i use Runnable using the Handler postDelayed() method.... – Aniket Oct 07 '13 at 05:55
  • after adding delay in it , it's still giving some issue.. i have updated my quetion – Aniket Oct 07 '13 at 06:12
  • increase the delay to 2msec and try.. in emulator it is difficukt to achive try in device, in device it wil work for 1000msec – Poovizhirajan N Oct 07 '13 at 06:23
  • This sounds like a dirty hack and I would not rely on this piece of code to work on all devices possible. What if a device takes more than 800 ms to open the native phone screen? – Nitin Sethi Oct 07 '13 at 06:23
  • @NitinSethi yes it takes 800-1000 to open outgoing screen – Poovizhirajan N Oct 07 '13 at 06:26
  • BUt it my case its still not working...@NitinSethi do you have any alternative? – Aniket Oct 07 '13 at 06:28
  • in emulator or mobile? – Poovizhirajan N Oct 07 '13 at 06:47
  • At Poovizhirajan.N: Can you guarantee that? At Aniket: I have given you an alternative. That in my opinion is your best bet. – Nitin Sethi Oct 07 '13 at 07:05
  • @Poovizhirajan.N it is showing my screen but not calling to he desired number – Aniket Oct 07 '13 at 07:09
  • wat do mean that desired number? – Poovizhirajan N Oct 07 '13 at 07:27
  • @NitinSethi i am guarantee it will work ,because i had already done this 3 months before... – Poovizhirajan N Oct 07 '13 at 07:30
  • @Poovizhirajan.N : By giving the delay to launch the custom outgoing call activity,the user can still see the android default dailer pop up for a fraction of second.Is there a way that we can make the outgoing call activity the default one? – Basher51 May 21 '14 at 11:02
  • @Basher51 NO You need manufacturing company's support adjust delay. – Poovizhirajan N May 22 '14 at 06:55
  • @Poovizhirajan.N: Would hard coding the delay be a solution,since different devices may have a different time periods for the outgoing screen popup.I came across another solution :http://stackoverflow.com/questions/15683952/pop-up-window-over-android-native-incoming-call-screen-like-true-caller-android/, have to try that as well. – Basher51 May 22 '14 at 07:07
  • @Basher51 what ever the you can't stop default screen. that is my point . – Poovizhirajan N May 22 '14 at 07:32
  • @Poovizhirajan.N: True the only way to avoid that would be to create our own custom dialer app and make it as the default – Basher51 May 22 '14 at 07:35
  • @Basher51 you can change dialer...but not incoming UI – Poovizhirajan N May 22 '14 at 08:38
  • @Poovizhirajan.N:Yes we can have our custom dialer.The only other workaround to modify the default UI would be to to use a hack to overlay the default UI with a View as shared in the link in my previous comment. – Basher51 May 22 '14 at 10:12
  • @Poovizhirajan.N: After tinkering a bit,I was able to overlay a view on top of the default dialer app(using which I could mask/change the appearance of the default dialer app).For more refer my answer at : http://stackoverflow.com/questions/23701879/popup-window-on-incoming-call-screen-like-truecaller/24377603#24377603 – Basher51 Jun 24 '14 at 02:56
0

The best way to do so is develop your own Phone app and expect the user to set it as the default app for making calls.

Edit:

Add an Activity which accepts ACTION_DIAL intent and have a numeric keypad and then once user has entered the call number, you can fire ACTION_CALL intent with the phone number which would invoke the native phone app. This way also, the user has to select your app to be set as default one for ACTION_DIAL intent.

Nitin Sethi
  • 1,416
  • 1
  • 11
  • 19
  • Thanks for reply. but actually i have done with my entire application now thing i have left with is getting custom outgoing screen,so only for that creating entire phone app will be to much time consuming for me.is there any alternative? again thanks for your suggestion. – Aniket Oct 07 '13 at 04:55
  • What do you want that screen to do? Make calls? – Nitin Sethi Oct 07 '13 at 05:36
0

You don't need to create a separate application. Ultimately you just want to handle the new outgoing call requests,so create a BroadcastReceiver to listen the event of ACTION_NEW_OUTGOING_CALL,and create an Activity to invoke upon that event.

you will need to specify permission in manifest file about PROCESS_OUTGOING_CALLS.

Have a look at some references:

handling-phone-call-requests-right-way

android-dialer-application

I hope it will be helpful !

Community
  • 1
  • 1
Mehul Joisar
  • 15,348
  • 6
  • 48
  • 57