2

I want to know how to we can hide the dialed number from screen when user make any call from android device. Don't want to allow user to see the dialed number from the app. In my app i am using calling intent and it works fine. But it shows default dialer. How to hide this dialer and delete number from history?

Goku
  • 9,102
  • 8
  • 50
  • 81
SARATH V
  • 500
  • 1
  • 7
  • 33
  • I think its impossible you can not handle a system application behavior(as much as i know). Did you see any application doing the same ? – ADM Dec 04 '17 at 04:47
  • @ADM , I don't want to override the system app, but just want show an overlay above system app to hide dialer view and remove that number from history. Not seen any app like that. – SARATH V Dec 04 '17 at 04:49
  • I think so . Well that is possible you just need to listen for the phone state with a Broadcast reciever. On incoming call draw a View over the screen. In that way whole screen will disappear behind your Overlay view . As you don't know the exact location of the number on screen this is quite a hustle ti hide only number . – ADM Dec 04 '17 at 04:52
  • That sounds like very bad UX, can you explain the reason for this scenario? – marmor Dec 04 '17 at 08:07
  • 1
    @marmor i'm looking forward to call users from app using native intent, but user shouldn't get the dialed number after call end. For recieving side user, its not mandatory (can view number since we can't change it right ?). Just for privacy reasons. – SARATH V Dec 04 '17 at 10:25
  • you mean you don't want the user to know the *number* you're calling to? the user will always be able to get the number by looking at his service-provider call activity (users get that by mail, or can see it online on most service providers). – marmor Dec 04 '17 at 10:29
  • @marmor, i'm aware about that info , even if it is possible to get numbers is there any solution for my requirement? – SARATH V Dec 04 '17 at 11:14
  • It's not possible unless you implement IVR calling. – Mohammed Junaid Apr 17 '20 at 12:38

1 Answers1

0

You'll need the following permissions:

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>    
<uses-permission android:name="android.permission.READ_CALL_LOG"/>
<uses-permission android:name="android.permission.WRITE_CALL_LOG"/>

Whenever you start the call intent, you'll need to start an ongoing service that will register a listener to listen to calls events (to detect exactly when the call start and ends). When the service detects the outgoing call starts, it should place a full-screen view with LayoutParams.TYPE_SYSTEM_ALERT Window LayoutParam, this will make the view "on top" of everything else on screen, including the call-UI. See this and this

When the call ends, make sure you remove the view from the Window, also make sure that if there's a bug, crash, or if the service exists unexpectedly, you remove your view, otherwise you may block the user from using the phone!

When the call ends, the service should add an Observer to the CallLog database and when you detect a change check if the last call is your call. If so, delete it.

P.S The SYSTEM_ALERT_WINDOW is granted by default when you install an app from Google Play, while developing, you need to manually enable it in your phone Settings > apps > Menu/Gear icon > Permissions > "Draw over other apps" > Enable for your app. For the other permissions, you may require to use the Runtime Permissions api

marmor
  • 27,641
  • 11
  • 107
  • 150