The application (apk file) cannot be installed on Android TV v11. Android TV Xiaomi
What could be wrong and how can it be fixed?
Что может быть и как возможно исправить?
What could be wrong and how can it be fixed?
Что может быть и как возможно исправить?
B4X:
#Region Project Attributes
#ApplicationLabel: Меню
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: true
#IncludeTitle: false
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
Private LastUrl As String
Private ButFocusX As Int
Private ButFocusY As Int
Private ButBack As Int
'Private PressBack As Int
Private UrlList(10) As String
Private menucount As Int
'------------------------------------------------------------------------------------------
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
UrlList(0)="https://prtv.su/46543"
UrlList(1)="https://prtv.su/46543"
UrlList(2)=""
menucount=0
Private MenuView As WebView
Private LeftMenu As Button
Private RightMenu As Button
Private RefreshButton As Button
Private ImageView As ImageView
Dim sf As StringFunctions
sf.Initialize
Private ButSet As Button
Private ButExit As Button
Private Label1 As Label
Private BU As Button
Private BL As Button
Private BD As Button
Private BR As Button
Private BE As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime=True Then DisableStrictMode
ButFocusX=0
ButFocusY=0
ButBack=0
LastUrl=""
ReadFromFile
Activity.LoadLayout("Menu")
ImageView.Bitmap = LoadBitmap(File.DirAssets, "font.jpg")
' -------------------КНОПКИ УПРАВЛЕНИЯ-------------
BL.Visible=False
BR.Visible=False
BD.Visible=False
BU.Visible=False
BE.Visible=False
Label1.Visible=False
'--------------------------------------------------
LeftMenu.Color = Colors.Cyan
RightMenu.Color = Colors.Cyan
RefreshButton.Color = Colors.Green
ButSet.Color=Colors.Cyan
ButExit.Color=Colors.Cyan
ImageView.Height=LeftMenu.Height*6
ImageView.Top=MenuView.Height/2-LeftMenu.Height*3
LeftMenu.Top=MenuView.Height/2-LeftMenu.Height/2
RightMenu.Top=MenuView.Height/2-RightMenu.Height/2
RefreshButton.Top=MenuView.Height/2-RefreshButton.Height/2
ButSet.Top=MenuView.Height/2-LeftMenu.Height*2
ButExit.Top=MenuView.Height/2+LeftMenu.Height
LeftMenu.Visible = False
RightMenu.Visible = False
RefreshButton.Visible =False
ImageView.Visible=False
ButSet.Visible=False
ButExit.Visible=False
If sf.Len(LastUrl)>0 Then 'если программа запущена не первый раз
MenuView.LoadUrl(LastUrl)
Else
LeftMenu.Visible = True
RightMenu.Visible = True
RefreshButton.Visible =True
ImageView.Visible=True
ButSet.Visible=True
ButExit.Visible=True
ButBack=1
End If
End Sub
Sub Activity_Resume
MenuView.LoadUrl(LastUrl)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
MenuView.LoadUrl(LastUrl)
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean
Label1.Text=" "&KeyCode
If KeyCode = KeyCodes.KEYCODE_BACK Then ' НАЖАТА КНОПКА НАЗАД
' ПРИ НАЖАТИ 3 РАЗА КНОПКИ НАЗАД - ВЫХОД ИЗ ПРИЛОЖЕНИЯ
menucount = menucount + 1
If menucount = 3 Then
Activity.Finish
End If
'-----------------------------------------------------
Label1.Text=KeyCode
LeftMenu.Visible = True
RightMenu.Visible = True
RefreshButton.Visible = True
ImageView.Visible=True
ButSet.Visible=True
ButExit.Visible=True
LeftMenu.Color = Colors.Cyan
RightMenu.Color = Colors.Cyan
RefreshButton.Color = Colors.Green
ButSet.Color=Colors.Cyan
ButExit.Color=Colors.Cyan
ButFocusX=0
ButFocusY=0
ButBack=1
Return True ' Возвращаем True, чтобы предотвратить дальнейшую обработку события
End If
If KeyCode = KeyCodes.KEYCODE_DPAD_LEFT Then ' НАЖАТА КНОПКА НА ПУЛЬТЕ - ВЛЕВО
menucount=0
If ButFocusX=1 And ButFocusY=0 Then
ButFocusX=0
ButFocusY=0
LeftMenu.Color = Colors.Cyan
RightMenu.Color = Colors.Cyan
RefreshButton.Color = Colors.Green
ButSet.Color=Colors.Cyan
ButExit.Color=Colors.Cyan
Return True
End If
If ButFocusX=-1 And ButFocusY=0 Then
ButFocusX=1
ButFocusY=0
LeftMenu.Color = Colors.Cyan
RightMenu.Color = Colors.Green
RefreshButton.Color = Colors.Cyan
ButSet.Color=Colors.Cyan
ButExit.Color=Colors.Cyan
Return True
End If
If ButFocusX=0 And ButFocusY=0 Then
ButFocusX=-1
ButFocusY=0
LeftMenu.Color = Colors.Green
RightMenu.Color = Colors.Cyan
RefreshButton.Color = Colors.Cyan
ButSet.Color=Colors.Cyan
ButExit.Color=Colors.Cyan
Return True
End If
Return True
End If
If KeyCode = KeyCodes.KEYCODE_DPAD_RIGHT Then ' НАЖАТА КНОПКА НА ПУЛЬТЕ - ВПРАВО
menucount=0
If ButFocusX=1 And ButFocusY=0 Then
ButFocusX=-1
ButFocusY=0
LeftMenu.Color = Colors.Green
RightMenu.Color = Colors.Cyan
RefreshButton.Color = Colors.Cyan
ButSet.Color=Colors.Cyan
ButExit.Color=Colors.Cyan
Return True
End If
If ButFocusX=0 And ButFocusY=0 Then
ButFocusX=1
ButFocusY=0
LeftMenu.Color = Colors.Cyan
RightMenu.Color = Colors.Green
RefreshButton.Color = Colors.Cyan
ButSet.Color=Colors.Cyan
ButExit.Color=Colors.Cyan
Return True
End If
If ButFocusX=-1 And ButFocusY=0 Then
ButFocusX=0
ButFocusY=0
LeftMenu.Color = Colors.Cyan
RightMenu.Color = Colors.Cyan
RefreshButton.Color = Colors.Green
ButSet.Color=Colors.Cyan
ButExit.Color=Colors.Cyan
Return True
End If
Return True
End If
If KeyCode=KeyCodes.KEYCODE_DPAD_UP Then ' НАЖАТА КНОПКА НА ПУЛЬТЕ - ВВЕРХ
If ButFocusY=0 Then
ButFocusY=1
ButFocusX=0
LeftMenu.Color = Colors.Cyan
RightMenu.Color = Colors.Cyan
RefreshButton.Color = Colors.Cyan
ButSet.Color=Colors.Green
ButExit.Color=Colors.Cyan
End If
If ButFocusY=-1 Then
ButFocusY=0
LeftMenu.Color = Colors.Cyan
RightMenu.Color = Colors.Cyan
RefreshButton.Color = Colors.Green
ButSet.Color=Colors.Cyan
ButExit.Color=Colors.Cyan
End If
End If
If KeyCode=KeyCodes.KEYCODE_DPAD_DOWN Then ' НАЖАТА КНОПКА НА ПУЛЬТЕ - ВНИЗ
If ButFocusY=0 Then
ButFocusY=-1
ButFocusX=0
LeftMenu.Color = Colors.Cyan
RightMenu.Color = Colors.Cyan
RefreshButton.Color = Colors.Cyan
ButSet.Color=Colors.Cyan
ButExit.Color=Colors.Green
End If
If ButFocusY=1 Then
ButFocusY=0
ButFocusX=0
LeftMenu.Color = Colors.Cyan
RightMenu.Color = Colors.Cyan
RefreshButton.Color = Colors.Green
ButSet.Color=Colors.Cyan
ButExit.Color=Colors.Cyan
End If
End If
If KeyCode = KeyCodes.KEYCODE_ENTER Or KeyCode = KeyCodes.KEYCODE_DPAD_CENTER Then ' НАЖАТА КНОПКА НА ПУЛЬТЕ - ENTER or Center pad
menucount=0
If ButFocusX=-1 And ButBack=1 And ButFocusY=0 Then
LastUrl = UrlList(0)
MenuView.LoadUrl(LastUrl)
LeftMenu.Visible = False
RightMenu.Visible = False
RefreshButton.Visible =False
ButSet.Visible=False
ButExit.Visible=False
WriteToFile(LastUrl)
ImageView.Visible=False
ButBack=0
End If
If ButFocusX=0 And ButBack=1 And sf.len(LastUrl)>0 And ButFocusY=0 Then
MenuView.LoadUrl(LastUrl)
LeftMenu.Visible = False
RightMenu.Visible = False
RefreshButton.Visible =False
ImageView.Visible=False
ButSet.Visible=False
ButExit.Visible=False
ButBack=0
End If
If ButFocusX=1 And ButBack=1 And ButFocusY=0 Then
LastUrl = UrlList(1)
MenuView.LoadUrl(LastUrl)
LeftMenu.Visible = False
RightMenu.Visible = False
RefreshButton.Visible =False
ButSet.Visible=False
ButExit.Visible=False
WriteToFile(LastUrl)
ImageView.Visible=False
ButBack=0
End If
If ButBack=1 And ButFocusY=-1 Then 'Выход
ButFocusX=0
ButFocusY=0
ExitApplication
End If
Return True
End If
Return False
End Sub
Sub WriteToFile(urlFile As String)
Dim text As String = urlFile
File.WriteString(File.DirInternal, "LastUrl.txt", text)
End Sub
Sub ReadFromFile
If File.Exists(File.DirInternal, "LastUrl.txt") Then
LastUrl=File.ReadString(File.DirInternal, "LastUrl.txt")
Else
Log("Файл не найден.")
End If
End Sub
Private Sub LeftMenu_Click
LastUrl = UrlList(0)
menucount=0
MenuView.LoadUrl(LastUrl)
LeftMenu.Visible = False
RightMenu.Visible = False
RefreshButton.Visible =False
ButSet.Visible=False
ButExit.Visible=False
WriteToFile(LastUrl)
ImageView.Visible=False
End Sub
Private Sub RightMenu_Click
LastUrl = UrlList(1)
menucount=0
MenuView.LoadUrl(LastUrl)
LeftMenu.Visible = False
RightMenu.Visible = False
RefreshButton.Visible =False
ButSet.Visible=False
ButExit.Visible=False
WriteToFile(LastUrl)
ImageView.Visible=False
End Sub
Private Sub RefreshButton_Click
menucount=0
If ButFocusX=0 And ButBack=1 And sf.len(LastUrl)>0 Then
MenuView.LoadUrl(LastUrl)
LeftMenu.Visible = False
RightMenu.Visible = False
RefreshButton.Visible =False
ImageView.Visible=False
ButSet.Visible=False
ButExit.Visible=False
ButBack=0
End If
End Sub
Sub DisableStrictMode 'Android 4+ не позволяет приложениям выполнять сетевые вызовы в основном потоке. Для этого ограничения есть веская причина: такие вызовы приводят к зависанию пользовательского интерфейса, и через 5 секунд Android покажет диалоговое окно «Приложение не отвечает».
Dim jo As JavaObject
jo.InitializeStatic("android.os.Build.VERSION")
If jo.GetField("SDK_INT") > 9 Then
Dim policy As JavaObject
policy = policy.InitializeNewInstance("android.os.StrictMode.ThreadPolicy.Builder", Null)
policy = policy.RunMethodJO("permitAll", Null).RunMethodJO("build", Null)
Dim sm As JavaObject
sm.InitializeStatic("android.os.StrictMode").RunMethod("setThreadPolicy", Array(policy))
End If
End Sub
Private Sub ButSet_Click
End Sub
Private Sub ButExit_Click
ExitApplication
End Sub