Android Question InputList disappears

positrom2

Active Member
Licensed User
Longtime User
An app working correctly on an older 7" tablet (Android 3.2.1) does not work on a Galaxy SII with Android 4.1.2 and smaller screen size. On the tablet the paired devices can be selected as usual from the popup-screen showing the paired devices, using inputlist (the code below was taken from the BluetoothAdmin tutorial).
B4X:
Sub Verbinden
    Dim PairedDevices As Map
    PairedDevices = blauerZahnDaten.GetPairedDevices
    Dim GeraeteListe As List
    GeraeteListe.Initialize
    For i = 0 To PairedDevices.Size - 1
        GeraeteListe.Add(PairedDevices.GetKeyAt(i))
    Next
    Dim res As Int
    res = InputList(GeraeteListe, "Bitte Gerät wählen", 2) 'show list with paired devices
    If res <> DialogResponse.CANCEL Then
        blauerZahnDaten.Connect(PairedDevices.Get(GeraeteListe.Get(res))) 'convert the name to mac address
    End If
End Sub
On the Galaxy SII the popupscreen shows up only very shortly and disappears without offering the possibility to select an item.
The nucleus of the problem might not be in the different Android versions nor screen sizes since I have another application using the same bluetooth setup which is working correctly on the Galaxy.
So my question is: In order to see the popup menu generated by Inputlist, are there any precautions to be taken considerering the screen layout? If other view are covering the screen, how to get the Input-list screen to the foreground?
 

positrom2

Active Member
Licensed User
Longtime User
I made a minimal example showing the problem:
The Bluetooth-Devices Inputlist is shown persistently in Android 3.2.1 but in Android 4.1.2 it closes immediately. The last log line reads:
** Activity (main) Pause, UserClosed = false **
I hope someone can point to a cure.
 

Attachments

  • BT_Inputlist_Test.zip
    6.5 KB · Views: 221
Upvote 0

positrom2

Active Member
Licensed User
Longtime User
I tested it on Android 4.4.2 and the dialog does show. What causes your activity to be paused?
When single-stepping on the Android 4.1.2 device the program closes when executing the line
B4X:
res = InputList(GeraeteListe, "Bitte Gerät wählen", -1) 'show list with paired devices
after a hard to see pop-up of the screen showing the paired devices.
So I assume the problem must be in the compiled code (I am with B4A 3.2).
Quite interestingly, the original long program runs as expected on the Android 4.1.2 (showing the BT-devices pop-up screen). I enclose it here. From that long program I had copied the BT-relevant lines to the short test program posted above which then does not run on 4.1.2 device.
 

Attachments

  • Largeprogram.zip
    30.1 KB · Views: 191
Upvote 0

positrom2

Active Member
Licensed User
Longtime User
I had inserted a log to print 1234 above the line "res=inputlist(...) to identify what might be of interest.
 
Upvote 0

positrom2

Active Member
Licensed User
Longtime User
Remove the ExitApplication call in Activity_Pause.
That was the cure. Thank you very much. I had stopped working on an application to be given to others because of this problem.
Could you explain for understanding why removing that statement apparently is only needed in Android 4.1.2 but not in some other Android versions like Android 4.4.2 as you had reported (or 3.2.1 as in the older tablet)?
 
Upvote 0

positrom2

Active Member
Licensed User
Longtime User
Update:
Tried again today... Apparently it worked once and no more on the Android 4.1.2 phone.
Connection from PC to the phone was via adb which had been installed by a recent Kies installation.
But, Using the B4A-Bridge the BT-connection (pop-up-menu) worked as it should (and so far apparently repeatedly).
Since installing via USB requires no user interaction one would prefer that instead of the B4A-bridge.
Is there any suggestion what might go wrong with the adb?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Since installing via USB requires no user interaction one would prefer that instead of the B4A-bridge.
Note that if you are using rapid debug mode then no user interaction is required in most cases as well.

ADB shouldn't affect the program behavior. Something on your device causes the activity to be paused. Maybe it has something to do with Kies.
 
Upvote 0

ValDog

Active Member
Licensed User
Longtime User
I too am seeing a similar problem. I am running Android 4.4.2 on a Nexus 7.

I have tried making a call to InputList from Activity_Create as well as Activity_Resume. In both cases the input list is displayed in Rapid Debug mode, but using Legacy Debug or Release mode I never see the input list - even though I know the code is called. The program just blows thru the code without responding to the InputList call. Any ideas?
 
Upvote 0

ValDog

Active Member
Licensed User
Longtime User
B4A v4.0

Yes, the InputList call is followed by a StartService call in the same Sub.
 
Upvote 0

ValDog

Active Member
Licensed User
Longtime User
Let me clarify that presently I am not calling InputList directly from Activity_Create, but rather from a Sub that is called from Activity_Create - if fact, from a Sub from a Sub - relevant code is as follows:

Sub Activity_Create(FirstTime As Boolean)
....
....
If FirstTime Then btnConnect_Click
End Sub 'Activity_Create

Sub btnConnect_Click
'BLUETOOTH - get it going
Serial1.Initialize("Serial1")
If Serial1.IsEnabled = False Then
Msgbox("Please enable Bluetooth before attempting to connect.", "")
Return
End If

BT_Connect
End Sub 'btnConnect_Click

Sub BT_Connect
....
....
Dim res As Int
res = InputList(lst, "Choose device", -1) 'show list with paired devices

If res <> DialogResponse.CANCEL Then
sMacAddress = PairedDevices.Get(lst.Get(res)) 'convert the name to mac address
sFriendlyName = PairedDevices.GetKeyAt(res)
StartService(BTSerial)
End If
End Sub 'BT_Connect
 
Upvote 0

ValDog

Active Member
Licensed User
Longtime User
No, the InputList seems to work correctly when I call it from Activity_Resume or Activity_Create in a new project.


The problem seems to occur with the btnConnect_Click call being made from Activity_Create. If I just click the Connect button to initiate the btnConnect_Click call it works just fine.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…