Italian [B4A] Lettura informazioni da rubrica Android

amorosik

Expert
Licensed User
Sto tentando di leggere la rubrica Andoid
Solitamente parto con gli esempi scritti da Erel che sono sicuramente un buon esempio di programmazione e funzionano
Andando su questo ContactsSearcher pero' non riesco a farlo partire
Uso B4A ver 10.2 + Java 8.0.261
Sul progetto originale come disponibile da sito web ho cambiato solo android:targetSdkVersion="29" sul manifest
Testo con un telefono Android 10 via wifi + B4abridge 2.62
Se tento di avviare in debug, compila correttamente, passa sul telefono, installa correttamente, poi appare APRI che premo e a questo punto su telefono appare "Waiting for Ide debugger...." mentre sul log appare
B4X:
Logger connesso a:  samsung SM-A105FN
--------- beginning of crash
--------- beginning of main

se tolgo il filtro dal log appare
B4X:
Logger connesso a:  samsung SM-A105FN
--------- beginning of crash
FATAL EXCEPTION: main
Process: b4a.example, PID: 23519
anywheresoftware.b4a.B4AUncaughtException
    at anywheresoftware.b4a.Msgbox.debugWait(Msgbox.java:210)
    at anywheresoftware.b4a.debug.Debug.wait(Debug.java:217)
    at anywheresoftware.b4a.debug.Debug.StartFromShell(Debug.java:109)
    at anywheresoftware.b4a.shell.Shell.start(Shell.java:101)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:92)
    at b4a.example.main.afterFirstLayout(main.java:97)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:237)
    at android.app.ActivityThread.main(ActivityThread.java:7948)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
FATAL EXCEPTION: main
Process: b4a.example, PID: 30225
anywheresoftware.b4a.B4AUncaughtException
    at anywheresoftware.b4a.Msgbox.debugWait(Msgbox.java:210)
    at anywheresoftware.b4a.debug.Debug.wait(Debug.java:217)
    at anywheresoftware.b4a.debug.Debug.StartFromShell(Debug.java:109)
    at anywheresoftware.b4a.shell.Shell.start(Shell.java:101)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:92)
    at b4a.example.main.afterFirstLayout(main.java:97)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:237)
    at android.app.ActivityThread.main(ActivityThread.java:7948)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
--------- beginning of main
Not starting debugger since process cannot load the jdwp agent.
setConscryptValidator
setConscryptValidator - put
Class anywheresoftware.b4a.BA failed lock verification and will run slower.
Common causes for lock verification issues are non-optimized dex code
and incorrect proguard optimizations.
common created.
Starting remote logger. Port: 35352
forceLight changed to true [] from com.android.internal.policy.PhoneWindow.updateForceLightNavigationBar:4238 com.android.internal.policy.DecorView.updateColorViews:1491 com.android.internal.policy.PhoneWindow.dispatchWindowAttributesChanged:3216 android.view.Window.setFlags:1148 com.android.internal.policy.PhoneWindow.generateLayout:2444
updateCaptionType >> DecorView@ef6d7ba[], isFloating: false, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: true
setCaptionType = 0, DecorView = DecorView@ef6d7ba[]
setView = com.android.internal.policy.DecorView@ef6d7ba TM=true MM=false
Relayout returned: old=(0,0,720,1520) new=(0,0,720,1520) req=(720,1520)0 dur=10 res=0x7 s={true 3625797632} ch=true
createReliableSurface : 0xd8250e00, 0xd81d4800
EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
mapper 3.x is not supported
Arm Module v1.0
mIsSamsungBasicInteraction = false, isMetaDataInActivity = false
shell switching to alternate port
shell switching to alternate port
*** Debugger waiting for connection (0) ***
updateCaptionType >> DecorView@12244b1[], isFloating: true, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: false
setCaptionType = 0, DecorView = DecorView@12244b1[]
initGoToTop
initGoToTop
setView = com.android.internal.policy.DecorView@12244b1 TM=true MM=false
MSG_WINDOW_FOCUS_CHANGED 1 1
prepareNavigationBarInfo() DecorView@ef6d7ba[main]
getNavigationBarColor() -855310
prepareNavigationBarInfo() DecorView@ef6d7ba[main]
getNavigationBarColor() -855310
Starting input: tba=b4a.example ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
startInputInner - Id : 0
startInputInner - mService.startInputOrWindowGainedFocus
MSG_RESIZED: frame=(0,0,720,1520) ci=(0,54,0,84) vi=(0,54,0,84) or=1
Relayout returned: old=(0,54,720,1436) new=(18,643,701,847) req=(683,204)0 dur=9 res=0x7 s={true 3883325440} ch=true
createReliableSurface : 0xd8250f80, 0xe776d800
EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
mWindow.mActivityCurrentConfig is null
MSG_WINDOW_FOCUS_CHANGED 1 1
prepareNavigationBarInfo() DecorView@ef6d7ba[main]
getNavigationBarColor() -855310
Starting input: tba=b4a.example ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
startInputInner - Id : 0
MSG_RESIZED_REPORT: frame=(18,643,701,847) ci=(0,0,0,0) vi=(0,0,0,0) or=1
MSG_WINDOW_FOCUS_CHANGED 0 1
prepareNavigationBarInfo() DecorView@ef6d7ba[main]
getNavigationBarColor() -855310
After accept
Log reader error: java.io.InterruptedIOException: read interrupted
-1 received
writer error
java.lang.InterruptedException
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:2042)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2076)
    at java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:387)
    at anywheresoftware.b4a.remotelogger.Connector$Writer.run(Connector.java:160)
    at java.lang.Thread.run(Thread.java:919)
Starting remote logger. Port: 35352
After accept
java.net.SocketTimeoutException: Poll timed out
    at libcore.io.IoBridge.poll(IoBridge.java:682)
    at java.net.PlainSocketImpl.socketAccept(PlainSocketImpl.java:196)
    at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:451)
    at java.net.ServerSocket.implAccept(ServerSocket.java:547)
    at java.net.ServerSocket.accept(ServerSocket.java:515)
    at anywheresoftware.b4a.shell.ShellConnector.connect(ShellConnector.java:153)
    at anywheresoftware.b4a.shell.ShellConnector.run(ShellConnector.java:119)
    at java.lang.Thread.run(Thread.java:919)
System.exit called, status: 0
VM exiting with result code 0, cleanup skipped.
Not starting debugger since process cannot load the jdwp agent.
setConscryptValidator
setConscryptValidator - put
Class anywheresoftware.b4a.BA failed lock verification and will run slower.
Common causes for lock verification issues are non-optimized dex code
and incorrect proguard optimizations.
common created.
Starting remote logger. Port: 35352
forceLight changed to true [] from com.android.internal.policy.PhoneWindow.updateForceLightNavigationBar:4238 com.android.internal.policy.DecorView.updateColorViews:1491 com.android.internal.policy.PhoneWindow.dispatchWindowAttributesChanged:3216 android.view.Window.setFlags:1148 com.android.internal.policy.PhoneWindow.generateLayout:2444
updateCaptionType >> DecorView@ef6d7ba[], isFloating: false, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: true
setCaptionType = 0, DecorView = DecorView@ef6d7ba[]
setView = com.android.internal.policy.DecorView@ef6d7ba TM=true MM=false
Relayout returned: old=(0,0,720,1520) new=(0,0,720,1520) req=(720,1520)0 dur=12 res=0x7 s={true 3625674752} ch=true
createReliableSurface : 0xd8250e00, 0xd81b6800
EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
mapper 3.x is not supported
Arm Module v1.0
mIsSamsungBasicInteraction = false, isMetaDataInActivity = false
shell switching to alternate port
shell switching to alternate port
*** Debugger waiting for connection (0) ***
updateCaptionType >> DecorView@12244b1[], isFloating: true, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: false
setCaptionType = 0, DecorView = DecorView@12244b1[]
initGoToTop
After accept
initGoToTop
setView = com.android.internal.policy.DecorView@12244b1 TM=true MM=false
MSG_WINDOW_FOCUS_CHANGED 1 1
prepareNavigationBarInfo() DecorView@ef6d7ba[main]
getNavigationBarColor() -855310
prepareNavigationBarInfo() DecorView@ef6d7ba[main]
getNavigationBarColor() -855310
Starting input: tba=b4a.example ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
startInputInner - Id : 0
startInputInner - mService.startInputOrWindowGainedFocus
Relayout returned: old=(0,54,720,1436) new=(18,643,701,847) req=(683,204)0 dur=39 res=0x7 s={true 3882956800} ch=true
createReliableSurface : 0xd8250f80, 0xe7713800
EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
mWindow.mActivityCurrentConfig is null
MSG_RESIZED: frame=(0,0,720,1520) ci=(0,54,0,84) vi=(0,54,0,84) or=1
MSG_WINDOW_FOCUS_CHANGED 1 1
prepareNavigationBarInfo() DecorView@ef6d7ba[main]
getNavigationBarColor() -855310
Starting input: tba=b4a.example ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
startInputInner - Id : 0
MSG_RESIZED_REPORT: frame=(18,643,701,847) ci=(0,0,0,0) vi=(0,0,0,0) or=1
MSG_WINDOW_FOCUS_CHANGED 0 1
prepareNavigationBarInfo() DecorView@ef6d7ba[main]
getNavigationBarColor() -855310
java.net.SocketTimeoutException: Poll timed out
    at libcore.io.IoBridge.poll(IoBridge.java:682)
    at java.net.PlainSocketImpl.socketAccept(PlainSocketImpl.java:196)
    at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:451)
    at java.net.ServerSocket.implAccept(ServerSocket.java:547)
    at java.net.ServerSocket.accept(ServerSocket.java:515)
    at anywheresoftware.b4a.shell.ShellConnector.connect(ShellConnector.java:153)
    at anywheresoftware.b4a.shell.ShellConnector.run(ShellConnector.java:119)
    at java.lang.Thread.run(Thread.java:919)
System.exit called, status: 0
VM exiting with result code 0, cleanup skipped.
Not starting debugger since process cannot load the jdwp agent.
setConscryptValidator
setConscryptValidator - put
Class anywheresoftware.b4a.BA failed lock verification and will run slower.
Common causes for lock verification issues are non-optimized dex code
and incorrect proguard optimizations.
common created.
Starting remote logger. Port: 35352
forceLight changed to true [] from com.android.internal.policy.PhoneWindow.updateForceLightNavigationBar:4238 com.android.internal.policy.DecorView.updateColorViews:1491 com.android.internal.policy.PhoneWindow.dispatchWindowAttributesChanged:3216 android.view.Window.setFlags:1148 com.android.internal.policy.PhoneWindow.generateLayout:2444
updateCaptionType >> DecorView@ef6d7ba[], isFloating: false, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: true
setCaptionType = 0, DecorView = DecorView@ef6d7ba[]
setView = com.android.internal.policy.DecorView@ef6d7ba TM=true MM=false
Relayout returned: old=(0,0,720,1520) new=(0,0,720,1520) req=(720,1520)0 dur=10 res=0x7 s={true 3625768960} ch=true
createReliableSurface : 0xd8250e00, 0xd81cd800
EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
mapper 3.x is not supported
Arm Module v1.0
mIsSamsungBasicInteraction = false, isMetaDataInActivity = false
shell switching to alternate port
shell switching to alternate port
*** Debugger waiting for connection (0) ***
updateCaptionType >> DecorView@12244b1[], isFloating: true, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: false
setCaptionType = 0, DecorView = DecorView@12244b1[]
initGoToTop
initGoToTop
setView = com.android.internal.policy.DecorView@12244b1 TM=true MM=false
MSG_WINDOW_FOCUS_CHANGED 1 1
prepareNavigationBarInfo() DecorView@ef6d7ba[main]
getNavigationBarColor() -855310
prepareNavigationBarInfo() DecorView@ef6d7ba[main]
getNavigationBarColor() -855310
Starting input: tba=b4a.example ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
startInputInner - Id : 0
startInputInner - mService.startInputOrWindowGainedFocus
Relayout returned: old=(0,54,720,1436) new=(18,643,701,847) req=(683,204)0 dur=11 res=0x7 s={true 3882805248} ch=true
createReliableSurface : 0xd8250f80, 0xe76ee800
EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
mWindow.mActivityCurrentConfig is null
MSG_RESIZED: frame=(0,0,720,1520) ci=(0,54,0,84) vi=(0,54,0,84) or=1
MSG_WINDOW_FOCUS_CHANGED 1 1
prepareNavigationBarInfo() DecorView@ef6d7ba[main]
getNavigationBarColor() -855310
Starting input: tba=b4a.example ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
startInputInner - Id : 0
MSG_RESIZED_REPORT: frame=(18,643,701,847) ci=(0,0,0,0) vi=(0,0,0,0) or=1
MSG_WINDOW_FOCUS_CHANGED 0 1
prepareNavigationBarInfo() DecorView@ef6d7ba[main]
getNavigationBarColor() -855310
After accept

Come' sta cosa?
Sbaglio qualcosa o anche a voi questo esempietto in modalita' debug non funziona?
Se provo in release funziona correttamente
 

LucaMs

Expert
Licensed User
Longtime User
1603870507418.png


Forse avevi qualche casino con il server ADB (più IDE aperti e connessi).
Chiudi tutto, riapri il progetto, riavvia il server ADB (dal menu Tools - Restard ADB server) e riprova.
 

Star-Dust

Expert
Licensed User
Longtime User
Se non ricordo male, con android 10 l'accesso ai contatti è limitato o richiede un'autorizzazione specifica. Però non sono sicuro

Vedi nella pagina di Erel sulle specifiche degli SDK, dovresti trovare qualcosa.
 

Star-Dust

Expert
Licensed User
Longtime User

amorosik

Expert
Licensed User
Ed invece come dice Star-Dust e' proprio questione di permessi, ho aggiunto questo
B4X:
    Dim rp As RuntimePermissions
   
    rp.CheckAndRequest(rp.PERMISSION_READ_CONTACTS )
    wait for Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result Then
        Logga("SI permesso PERMISSION_READ_CONTACTS")
    Else
        Logga("NO permesso PERMISSION_READ_CONTACTS")
    End If
   
    rp.CheckAndRequest(rp.PERMISSION_WRITE_CONTACTS )
    wait for Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result Then
        Logga("SI permesso PERMISSION_WRITE_CONTACTS")
    Else
        Logga("NO permesso PERMISSION_WRITE_CONTACTS")
    End If

Oltre al manifest
B4X:
AddPermission(android.permission.READ_CONTACTS)
AddPermission(android.permission.WRITE_CONTACTS)

E anche l'esempio recalcitrante e' stato domato
Prima di fare questo, ho provato anche su un Android 6 e l'esempio originale dava lo stesso problema, solo che su quello vedevo proprio la richiesta del permesso di lettura/scrittura contatti e quindi dava indicazioni sul mancante
 
Last edited:

amorosik

Expert
Licensed User
Avro' anche matto, ma realmente in release andava, in debug no
Forse in release me li ha chiesti e non ricordavo di aver confermato
Ma fosse cosi', non avrebbe dovuto chiederli anche in debug?
 

Star-Dust

Expert
Licensed User
Longtime User
Avro' anche matto, ma realmente in release andava, in debug no
Forse in release me li ha chiesti e non ricordavo di aver confermato
Ma fosse cosi', non avrebbe dovuto chiederli anche in debug?
Credo che in modalità debug erediti/usi i permessi richiesti dal Birdge, che potrebbe non averli o avere nel manifest un SDK Target che impedisce l'accesso a determinati dati senza permesso specifico
 
Last edited:
Top