چک کردن اتصال به اینترنت b4a
سلام
من تو برنامم از پرداخت درون برنامهای استفاده کردم این پرداخت درون برنامهای موقعی که گوشی به اینترنت وصل هست اجرا می شود اما هنگامی که گوشی به اینترنت وصل نیست وقتی رو دکمه قفل کلیک می کند به کاربر هیچ چیزی نشان نمی دهد میخواستم با یک دستور ایف این مشکل رو حل کنم اما اینکه داخل این دستور ایف چی بنویسم رو بلد نیستم

پاسخ ( 1 )
سلام
sub زیر رو نگاه کنید، در sub زیر یک متغیر از نوع PhoneEvents تعریف شده و یک sub هم براش نوشتیم و وضعیت اتصال رو بررسی کردیم:
Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. Public PhoneEvent1 As PhoneEvents End Sub Sub Service_Create 'This is the program entry point. 'This is a good place to load resources that are not specific to a single activity. 'https://www.b4x.com/android/help/phone.html#phoneevents PhoneEvent1.Initialize("PhoneEvent") End Sub Sub Service_Start (StartingIntent As Intent) End Sub Sub Service_TaskRemoved 'This event will be raised when the user removes the app from the recent apps list. End Sub 'Return true to allow the OS default exceptions handler to handle the uncaught exception. Sub Application_Error (Error As Exception, StackTrace As String) As Boolean Return True End Sub Sub Service_Destroy End Sub Sub PhoneEvent_ConnectivityChanged(NetworkType As String, State As String, Intent As Intent) 'NetworkType - WIFI or MOBILE. 'State - One of the following values: CONNECTING, CONNECTED, SUSPENDED, DISCONNECTING, DISCONNECTED, UNKNOWN. If State = "CONNECTED" Then Else ToastMessageShow("DISCONNECTED",True) End If End Subدر خط 38 برای state وضعیت های گوناگونی که از همشون میتونید استفاده کنید، که چون گفتید وضعیت اتصال اینترنت بررسی بشه حالت state فقط گفته شده
موفق باشید.