ขอขอบคุณความรู้ดีๆของErel, ilanและAeric
สาธิตตัวอย่างการเขียนโค้ดในไฟล์ manifest
หมายเหตุ
เราใช้คำสั่งAddPermission() และRemovePermission()ในการอนุญาต/ยกเลิกการอนุญาต ในการเขียนโค้ดในไฟล์manifest
อีกวิธีหนึ่ง เราสามารถเขียนโค้ดอนุญาตในขณะแอพกำลังถูกเรียกใช้งาน
หมายเหตุ
กรณีไม่ได้เป็นการเขียน Non-B4XPages ให้แก้ไขบรรทัด
เขียนใหม่เป็น
ข้อควรจำ
เนื่องจากการอนุญาตเป็นเรื่องของB4Aเท่านั้น
ดังนั้น B4XPagesจึงไม่ใช่ CrossPlatforms
ขอขอบคุณ Aericชาวมาเลเซีย อีกครั้ง ณ ที่นี่
ศึกษาเพิ่มเติม
www.b4x.com
www.b4x.com
การขออนุญาตให้แอพสามารถทำงานบนแอพอื่น
www.b4x.com
สาธิตตัวอย่างการเขียนโค้ดในไฟล์ manifest
B4X:
AddPermission(android.permission.ACCESS_FINE_LOCATION)
AddPermission(android.permission.BLUETOOTH_SCAN)
AddPermission(android.permission.BLUETOOTH_CONNECT)
หมายเหตุ
เราใช้คำสั่งAddPermission() และRemovePermission()ในการอนุญาต/ยกเลิกการอนุญาต ในการเขียนโค้ดในไฟล์manifest
อีกวิธีหนึ่ง เราสามารถเขียนโค้ดอนุญาตในขณะแอพกำลังถูกเรียกใช้งาน
B4X:
'การเขียนโค้ด กำหนดอนุญาต ขณะruntime
Dim Permissions As List
Dim rp As RuntimePermissions
Dim phone As Phone
If phone.SdkVersion >= 31 Then
Permissions = Array("android.permission.BLUETOOTH_SCAN", "android.permission.BLUETOOTH_CONNECT", rp.PERMISSION_ACCESS_FINE_LOCATION)
Else
Permissions = Array(rp.PERMISSION_ACCESS_FINE_LOCATION)
End If
For Each per As String In Permissions
rp.CheckAndRequest(per)
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
If Result = False Then
ToastMessageShow("No permission: " & Permission, True)
Return
End If
Next
กรณีไม่ได้เป็นการเขียน Non-B4XPages ให้แก้ไขบรรทัด
B4X:
'B4XPages
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
B4X:
'Non-B4XPages
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
ข้อควรจำ
เนื่องจากการอนุญาตเป็นเรื่องของB4Aเท่านั้น
ดังนั้น B4XPagesจึงไม่ใช่ CrossPlatforms
ขอขอบคุณ Aericชาวมาเลเซีย อีกครั้ง ณ ที่นี่
ศึกษาเพิ่มเติม
PermissionsManager
PermissionsManager is a library that enables the management of runtime permissions. This library completely replaces the standard RuntimePermissions library with the addition of modern dangerous permissions and special permissions that require approval via the settings application. This library...
Runtime Permissions (Android 6.0+ Permissions)
1. Edit: In B4XPages the permission result event signature is: Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean) 2. Important to read: https://www.b4x.com/android/forum/threads/android-jar-targetsdkversion-minsdkversion.87610/#content If the targetSdkVersion is...
การขออนุญาตให้แอพสามารถทำงานบนแอพอื่น
Draw on top of other apps permission
Starting from Android 6 a special permission is required if you want to use the SYSTEM_ALERT_WINDOW permission. This permission is not related to the runtime permissions. You can put this code in a class to check whether your app has permission and open the settings page if needed: Sub...
Last edited: