Android Question Phone Number Blacklisting

johnaaronrose

Active Member
Licensed User
Longtime User
I want to write a simple app for phone number blacklisting as the ones on Google Play Store are much too complex. I simply want to be able to reject anonymous calls & calls from a numbers on a user maintained blacklist. I haven't been able to find any tutorials on this type of phone use. Can anybody direct me to the appropriate documentation?
 

mangojack

Expert
Licensed User
Longtime User
A while back I created a small app to kill off the telemarketers .. it worked OK on my old galaxy fit.
It would error on incoming private numbers (-1 , -2 ??). never got around to fixing it and have no need of it anymore.

it basically uses a service and Phone events(Core) to monitor the phone state.
on "Ringing" if the number was in the barred list the below library would answer the call .. and after short interval hang up.

I offer the app as a start to your project.
It would be a good idea to read thru the thread before grabbing the lib.
specially the last post .. something about it don't work anymore under Lolipop... !:(

Answer Call library ..

also include reflection lib ..
 

Attachments

  • Hangup and POQ sample.zip
    48.2 KB · Views: 381
Upvote 0

johnaaronrose

Active Member
Licensed User
Longtime User
A while back I created a small app to kill off the telemarketers .. it worked OK on my old galaxy fit.
It would error on incoming private numbers (-1 , -2 ??). never got around to fixing it and have no need of it anymore.

it basically uses a service and Phone events(Core) to monitor the phone state.
on "Ringing" if the number was in the barred list the below library would answer the call .. and after short interval hang up.

I offer the app as a start to your project.
It would be a good idea to read thru the thread before grabbing the lib.
specially the last post .. something about it don't work anymore under Lolipop... !:(

Answer Call library ..

also include reflection lib ..

Thanks for that. Erel suggested in thread https://www.b4x.com/android/forum/threads/end-call-incoming.19714/ to use the Reflection library (without the AnswerCall library) as follows:
In PhoneEvents:
Sub KillCall
Dim r AsReflector
r.Target = r.GetContextDim TelephonyManager, TelephonyInterface As Object
TelephonyManager = r.RunMethod2("getSystemService", "phone", "java.lang.String")
r.Target = TelephonyManager
TelephonyInterface = r.RunMethod("getITelephony")
r.Target = TelephonyInterface
r.RunMethod("endCall")
End Sub
Add this permission with the manifest editor:
Code:
AddPermission("android.permission.CALL_PHONE")

I think that I'll try this method first as it looks simpler as well as the AnswerCall method not always working (i.e. not with various devices & Lollipop). Did you mean "incoming private numbers (-1 , -2 ??)." as just meaning UK 01.. & 02.. phone numbers? What phone number would an anonymous call be (e.g. 0) taken as? I also understand that call centres now use international numbers: is there any way to recognize these?
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Did you mean "incoming private numbers (-1 , -2 ??)
call logs listed incoming calls from "private numbers" as -1 or -2 (Australia) ..
as mentioned above .. I never got around to investigating it further and have no plans to do so ..

What phone number would an anonymous call be (e.g. 0)
I have no Idea..

I also understand that call centres now use international numbers: is there any way to recognize these?
I have no Idea ..

Sorry I cant help any further .. ;)
 
Upvote 0

jchal

Active Member
Licensed User
Longtime User
hi there i tryed to run the sample code and i got the following error
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Service (listener) Create **
AsnwerCall has been initialized.
** Service (listener) Start **
An error occurred:
(Line: 0) null
java.lang.Exception: Sub service_start signature does not match expected signature.
public static anywheresoftware.b4a.pc.RemoteObject com.sample.hangup.listener_subs_0._service_start() throws java.lang.Exception
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
hi there i tryed to run the sample code and i got the following error
The Sub signature should be ... Sub Service_Start (StartingIntent As Intent)

This is a very old thread .. please start a new thread for any further questions.
 
Upvote 0
Top