|  | 
 
|  
 นี่เป็นการแจกโค้ด B4A (Basic 4 Android) แรกสำหรับเว็บบอร์ดตัวใหม่ ซึ่งช่วงนี้เห็นมีการโหวตโน่นนั่นนี่ผ่านทาง Mobile App. แอดมินก็เลยเดาเอาว่าเวลาโหวตผ่านมือถือ คงต้องเช็ค Serial Number จากตัวเครื่อง ไปผสมกับรหัสบัตรประชาชน 13 หลัก เพื่อไม่ให้เกิดการซ้ำ ก็เลยถือเอาจังหวะนี้แหละมาแจกโค้ดในการอ่าน ID บางส่วนคือ Serial Number และ IMEI ตัวแรกของเครื่องโทรศัพท์ ในระบบปฏิบัติการ Android ...
 
 ดาวน์โหลด Java Library ... โดยแตกไฟล์ออกมาไปวางไว้ที่ C:\Program Files (x86)\Anywhere Software\Basic4android\Libraries ซึ่งจะมีนามสกุล jar และ xml
 Phone V2.50
 Reflection V2.40
 
 ฟังค์ชั่นที่ต้องนำมาใช้งาน ...
 
  
 มาดูโค้ด Basic for Android (B4A) ... (แอดมินไม่ได้ใช้ Designer เป็นการสร้าง Label Control แบบ @Run Time)
 
 คัดลอกไปที่คลิปบอร์ด#Region  Project Attributes 
        #ApplicationLabel: Serial-IMEI Phone
        #VersionCode: 1
        #VersionName: 
        'SupportedOrientations possible values: unspecified, landscape or portrait.
        #SupportedOrientations: unspecified
        #CanInstallToExternalStorage: False
#End Region
#Region  Activity Attributes 
        #FullScreen: False
        #IncludeTitle: 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.
End Sub
Sub Globals
        'These global variables will be redeclared each time the activity is created.
        'These variables can only be accessed from this module.
        Dim lblSerial As Label
        Dim lblIMEI As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
        'Do not forget to load the layout file created with the visual designer. For example:
        'Activity.LoadLayout("Layout1")
        If FirstTime Then
                lblSerial.Initialize("lblSerial")
                lblIMEI.Initialize("lblIMEI")
        End If
        lblSerial.TextSize=28
        lblIMEI.Textsize=28
        '/ Setting Label
        Activity.AddView(lblSerial, 0, 30dip, 100%x, 100%y)
        Activity.AddView(lblIMEI, 0, 100dip, 100%x, 100%y)
        Dim pid As PhoneId
        Dim r1 As Reflector
        lblSerial.Text="Build.SERIAL: " & r1.GetStaticField("android.os.Build", "SERIAL" )
        lblIMEI.Text="IMEI: " & pid.GetDeviceId
End Sub
ดาวน์โหลดโค้ดต้นฉบับ Basic For Android (B4A) ได้ที่นี่ ...
 
 
 | 
 
xขออภัย! โพสต์นี้มีไฟล์แนบหรือรูปภาพที่ไม่ได้รับอนุญาตให้คุณเข้าถึงคุณจำเป็นต้อง ลงชื่อเข้าใช้ เพื่อดาวน์โหลดหรือดูไฟล์แนบนี้ คุณยังไม่มีบัญชีใช่ไหม? ลงทะเบียน  |