B4A Library AnswerCall Library

Maartensaps

Member
Licensed User
Longtime User
ac.enablespeakerphone notworking

Very nice lib but the enablespeakerphone function does not work on my samsung galaxy y duos. :signOops:
The log reports:
Audio Settings Permission Denial: SetSpeakerphoneOn() from pid 32019, uid 10099

Can anything be done for this?

Thanks for all that great work!!

Maarten
 

Maartensaps

Member
Licensed User
Longtime User
still a little issue

Hi Erel,

Your solution works on a Samsung phone but...
Does a HTC evo WiMax do things diferently?
The speaker does not switch on :-(

Any ideas?
 

Maartensaps

Member
Licensed User
Longtime User
I am trying to.....

Pick up the phone and switch on the speaker. A simple auto-answer app.
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
I have it set to allow the user to disable the answering abilities in my app, is there a way to turn this off? ie: an enabled property

Or will all calls go through this no matter what?

EDIT: nevermind, it works perfectly.
 
Last edited:

Maartensaps

Member
Licensed User
Longtime User
still some issues

I still have some issues.

On a HTC EVO the speaker does not switch on.

On a Star W007 it does not answer calls.

Any ideas ? Can it be a permission issue or android incompatibility ???

The app is compiled with api 16 (I think, as I can not find out where this is set)

Maarten
 

Maartensaps

Member
Licensed User
Longtime User
Check the logs and see whether there is any message related to permissions.

I will..... as soon as I figure out how to get the phone-log into a file. (see #post136606)
I do not have those phones. That is the problem. :-(
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
A user on an HTC Thunderbolt reports when they click answer, the call gets sent to voicemail.

Is there a mute microphone setting?
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
HTC EVO 4g wont answer calls

Also, could you add the ability to handle 2 calls at once?
ie: keep track of the phone number for both, switch between them, or release a specific one?
 

GMan

Well-Known Member
Licensed User
Longtime User

koaunglay

Member
Licensed User
Longtime User
Please ! What is my error?
B4X:
** Activity (main) Create, isFirst = true **


** Activity (main) Resume **


** Service (forblack) Create **


AsnwerCall has been initialized.


** Service (forblack) Start **


forblack_pe_phonestatechanged (java line: 136)


java.lang.ArrayIndexOutOfBoundsException: length=1; index=1


    at com.aung.blacklis.forblack._pe_phonestatechanged(forblack.java:136)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:159)
    at anywheresoftware.b4a.phone.PhoneEvents$ActionHandler.send(PhoneEvents.java:326)
    at anywheresoftware.b4a.phone.PhoneEvents$15.handle(PhoneEvents.java:245)
    at anywheresoftware.b4a.phone.PhoneEvents$16.onReceive(PhoneEvents.java:268)
    at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:761)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4791)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)


    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
    at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.PHONE_STATE flg=0x10 (has extras) } in anywheresoftware.b4a.phone.PhoneEvents$16@427bda50


    at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:771)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4791)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:201)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:159)


    at anywheresoftware.b4a.phone.PhoneEvents$ActionHandler.send(PhoneEvents.java:326)
    at anywheresoftware.b4a.phone.PhoneEvents$15.handle(PhoneEvents.java:245)
    at anywheresoftware.b4a.phone.PhoneEvents$16.onReceive(PhoneEvents.java:268)
    at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:761)
    ... 9 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
    at com.aung.blacklis.forblack._pe_phonestatechanged(forblack.java:136)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
    ... 14 more
This is my Service code...
B4X:
#Region  Service Attributes
    #StartAtBoot: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim sq1 As SQL
    Dim c1 As Cursor
            Dim mysq_fo As String : mysq_fo = File.DirRootExternal & "/Android/AungLay_black"
                ' ////////////////////
'                Dim names, nums As String
'                Dim texR As TextReader
                Dim numbers() As String
'    --------------------
    Dim pe As PhoneEvents
    Dim pid As PhoneId
    Dim ac As AnswerCall
End Sub
Sub Service_Create
    If File.Exists(mysq_fo, "") = False Then
        File.MakeDir(File.DirRootExternal, "/Android/AungLay_black")
    End If
    ' ---------------------
    If File.Exists(mysq_fo, "Black_db.db") = False Then
        File.Copy(File.DirAssets, "Black_db.db", mysq_fo, "Black_db.db")
    End If
    ' --------------------
    If sq1.IsInitialized = False Then
        sq1.Initialize(mysq_fo, "Black_db.db", True)
    End If
    '    -----------------------------
    pe.InitializeWithPhoneState("pe", pid)
    ac.Initialize("ac")
   
End Sub

Sub Service_Start (StartingIntent As Intent)
    ToastMessageShow("Now Start Service!!!", True)
End Sub

Sub Service_Destroy

End Sub
Sub pe_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
    ' ------------------ Whit DB
    c1 = sq1.ExecQuery("SELECT Number FROM Black_table")
    For i = 0 To c1.RowCount - 1
        c1.Position = i
                numbers = Array As String(c1.GetString("Number"))
                If numbers(i).Contains(IncomingNumber) Then
                    Kill_Call
'                    ToastMessageShow(IncomingNumber, True)
'                        ac.LetPhoneRing(3000)
'                        If ac.isRinging == True Then
'                            ac.AnswerPhone
'                        End If
'                        ac.enableSpeakerphone
                Else
'                    Kill_Call
                    ToastMessageShow(IncomingNumber, True)
                        ac.LetPhoneRing(3000)
                        If ac.isRinging == True Then
                            ac.AnswerPhone
                        End If
                        ac.enableSpeakerphone                   
                End If
    Next
End Sub
Sub Kill_Call
   '    For This ---- You should add "AddPermission("android.permission.CALL_PHONE")" in manifest editor
   Dim r As Reflector
   r.Target = r.GetContext
   Dim 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
Please somebody help!
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…