Android Question sudden shutdown

Almora

Well-Known Member
Licensed User
Longtime User
Hi
I'm playing a video. When I close the full screen ad, it closes abruptly when I watch it again. what would be the reason.
only when the full screen ad is closed.


it suddenly turns off when I close the video and re-enter it.

B4X:
Sub Globals
Private SimpleExoPlayerView1 As SimpleExoPlayerView

Private BannerAd As AdView
Private tm As InterstitialAd

End Sub
Sub Activity_Create(FirstTime As Boolean)

If FirstTime Then
player1.Initialize("player")
player1.Prepare(player1.CreateHLSSource("http://xxxxxx.175.xxxxxxxxxxxxxxxxxxxx"))
End If
Activity.LoadLayout("1")
SimpleExoPlayerView1.Player = player1 'Connect the interface to the engin

BannerAd.Initialize2("BannerAd", "ca-app-pub-xxxxxx8358736xx/x85863xxxx", BannerAd.SIZE_SMART_BANNER)
Dim height As Int
If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
' 'phones
If 100%x > 100%y Then height = 32dip Else height = 50dip
Else
'tablets
height = 90dip
End If
Activity.AddView(BannerAd, 0dip, 100%y - height, 100%x, height)
BannerAd.LoadAd
tm.Initialize("tm", "ca-app-pub-xxxxx38358736xxx/x989xxxxx")
tm.LoadAd


End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub





Sub activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event

If KeyCode = KeyCodes.KEYCODE_BACK Then

player1.Pause

If tm.Ready Then tm.Show
Else
Activity.Finish
StartActivity(Main)

Return True
End If
Return False
End Sub




Sub tm_AdClosed
Activity.Finish
StartActivity(Main)
End Sub
 

Attachments

  • ezgif-6-e5653701e2c9.gif
    ezgif-6-e5653701e2c9.gif
    484.7 KB · Views: 188
Last edited:

Almora

Well-Known Member
Licensed User
Longtime User
1. Please use code here...tags when posting code.
?

I tested it on the real device. There is no sudden shutdown but the button opens at the second click. it does not open on the first click.
There is no error code.


3. Where is the full error you get?

I'm watching the video. I'm going out later. full screen ad looks. I close the ad. I click the button when I want to watch the video again. but it opens in the second click. the first click does not respond.
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You should use 'quotes' instead of spoilers.

I'm watching the video. I'm going out later. full screen ad looks. I close the ad. I click the button when I want to watch the video again. but it opens in the second click. the first click does not respond.
Not sure that I understand the flow. Are you showing a full screen ad above the video?
 
Upvote 0

Almora

Well-Known Member
Licensed User
Longtime User
You should use 'quotes' instead of spoilers.


Not sure that I understand the flow. Are you showing a full screen ad above the video?

test.apk

I added sample project and apk file.

I open the application. I click the button. going to video activity. opening video. showing ads. I'm coming back. showing full screen advertisement. so far there is no problem. I am not leaving the application. I click the button to watch the video again, but it does not go to the video activity. it goes on my second click.
 

Attachments

  • test1.zip
    11.3 KB · Views: 195
Upvote 0

Almora

Well-Known Member
Licensed User
Longtime User
I used this https://www.b4x.com/android/forum/threads/firebaseadmob-v1-6.108552/
but that didn't help.


opens in the second click. where am i making a mistake.


I added pictures in order for better understanding

test.apk
You can test it with apk file.
It needs to show full screen ads while testing the apk. Wait a little while watching the video and come back. then click the button again without closing the application.
 

Attachments

  • 1.png
    1.png
    9.7 KB · Views: 187
  • 2.png
    2.png
    87.5 KB · Views: 182
  • 3.png
    3.png
    191.9 KB · Views: 187
  • 4.png
    4.png
    207.4 KB · Views: 178
  • 5.png
    5.png
    16.1 KB · Views: 178
Last edited:
Upvote 0

Almora

Well-Known Member
Licensed User
Longtime User
I found the cause of the error.
it works very well now.
thanks..

new:
Sub activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event

If KeyCode = KeyCodes.KEYCODE_BACK Then

player1.Pause

If tm.Ready Then
tm.Show
Else
Activity.Finish
StartActivity(Main)
End If
Return True
End If
Return False
End Sub
 
Upvote 0
Top