Flash on Android 4.x

biometrics

Active Member
Licensed User
Longtime User
Our application uses WebView in Basic4Android V2.52. We can display Flash on Android 2.3 and 3.x but not on Android 4.0.3. The built-in browser on Android 4.0.3 also uses the underlying WebView and can display Flash. We suspect that the default WebSettings related to PluginState may have changed between Android versions and are unsure whether this are set explicitly in B4A.

Our initialisation code looks like this:

Sub Globals
Dim libWebView As WebView
End Sub

Sub Activity_Create(FirstTime As Boolean)
libWebView.Initialize("libWebView")
Activity.AddView(libWebView, 0, 0, lScreenWidthInPixels, lScreenHeightInPixels)
End Sub

Sub PlayFlash
libWebView.LoadUrl("file://" & sPath & "/Media/" & sFlashFilename)
libWebView.Visible = True
End Sub

How do we go about implementing WebSettings.setPluginState(ON) in B4A?

Has Basic4Android WebView been able to display Flash files with Android 4.0.3 (or 4.x) on any platform?
 

biometrics

Active Member
Licensed User
Longtime User
I've tried this now:

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" />
<supports-screens android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="true"
   android:hardwareAccelerated="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

But get this error:

B4X:
Generating R file.                      Error
AndroidManifest.xml:10: error: No resource identifier found for attribute 'hardwareAccelerated' in package 'android'
 
Upvote 0

biometrics

Active Member
Licensed User
Longtime User
Even with the hardware accelerated attribute set to True, we are still not seeing flash video.

Looking at the Java code for the built-in browser, it uses WebSettings.setPluginState to pass on one of three values from the user interface: ON, ON_DEMAND or OFF. Looking at the Android 4.0.3 code itself, it seem to default to OFF.

How would we go about setting WebSettings.setPluginState(ON) in Basic4Android?
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
You can try this code:

B4X:
Sub SetPlugInsOn
   'Your WebView must already be Dimmed and Initialized
   Dim r As Reflector   'Uses the Reflections Library
   r.Target = 'Your WebView name goes here like: r.Target = WebView1
    r.Target = r.RunMethod("getSettings")
    r.RunMethod2("setPluginsEnabled", True, "java.lang.boolean")
End Sub
 
Upvote 0

biometrics

Active Member
Licensed User
Longtime User
Solved

My manifest editor had this and Flash did not work:

<uses-sdk android:minSdkVersion="4" />

With the following it does work:

<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14" />
 
Upvote 0
Top