Play video in splash screen with Xamain.Forms.Android - xamarin.forms

I am trying to play video on splash screen with Xamarin.Forms.Android. When I start the application all I can see is a white blank screen. After the video is completed, my main activity loads as expected. I don't see any exceptions about VideoView in debug log. Can you please help or redirect me? Thank you.
I am using Xamarin.Forms shared project. I installed latest versions of Xamarin.Android.Support libraries. I created a splash layout and splash activity. Minimum Android version is 4.4 and target version is 8.1 (API level 27). I put the video in Resources\raw folder as video.mp4 file.
SplashLayout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center"
android:id="#+id/appSplash"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<VideoView
android:id="#+id/splashVideo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
styles.xml:
<resources>
<style name="MyTheme" parent="MyTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette-->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#1A1E83</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#1A1E83</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#2B9E94</item>
<!--<item name="android:textColorPrimary">#FFFFFF</item>-->
<item name="actionMenuTextColor">#FFFFFF</item>
<item name="android:textColorSecondary">#FFFFFF</item>
<item name="android:colorActivatedHighlight">#android:color/transparent</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">#style/AppCompatDialogStyle</item>
<!--Back Button OverWrite-->
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#FF4081</item>
</style>
<style name="DrawerArrowStyle" parent="#style/Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">#FFFFFF</item>
</style>
<style name="AppToolbarTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:colorBackground">#FFFFFF</item>
<item name="android:textColor">#FFFFFF</item>
<item name="android:textColorPrimary">#FFFFFF</item>
</style>
<!--<item name="android:windowBackground">#drawable/splash_screen_land</item>-->
<style name="MyTheme.Splash" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowActionBar">true</item>
</style>
</resources>
VideoSplashActivity.cs
[Activity(Icon = "#drawable/icon", Theme = "#style/MyTheme.Splash", ScreenOrientation = ScreenOrientation.Portrait, MainLauncher = true, NoHistory = true)]
public class VideoSplashActivity : AppCompatActivity
{
VideoView videoView;
static readonly string TAG = "X:" + typeof(VideoSplashActivity).Name;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Log.Debug(TAG, "VideoSplashActivity.OnCreate");
//set layout view
SetContentView(Resource.Layout.SplashLayout);
//access video view
videoView = FindViewById<VideoView>(Resource.Id.splashVideo);
//access the video
string videoPath = $"android.resource://{Application.PackageName}/{Resource.Raw.video}";
videoView.SetVideoPath(videoPath);
videoView.Start();
videoView.Completion += (sender,args)=>
{
SimulateStartup();
};
}
protected override void OnResume()
{
base.OnResume();
SimulateStartup();
}
private void SimulateStartup()
{
Log.Debug(TAG, "Startup work is finished - starting MainActivity.");
StartActivity(new Intent(Application.Context, typeof(MainActivity)));
}
}
part of the debug log
D/X:VideoSplashActivity(20832): VideoSplashActivity.OnCreate
D/Mono (20832): DllImport searching in: '__Internal' ('(null)').
D/Mono (20832): Searching for 'java_interop_jnienv_call_nonvirtual_object_method_a'.
D/Mono (20832): Probing 'java_interop_jnienv_call_nonvirtual_object_method_a'.
D/Mono (20832): Found as 'java_interop_jnienv_call_nonvirtual_object_method_a'.
D/Mono (20832): DllImport searching in: '__Internal' ('(null)').
D/Mono (20832): Searching for 'java_interop_jnienv_call_void_method_a'.
D/Mono (20832): Probing 'java_interop_jnienv_call_void_method_a'.
D/Mono (20832): Found as 'java_interop_jnienv_call_void_method_a'.
D/Mono (20832): Assembly Ref addref Xamarin.Forms.Platform.Android[0xa55c6d00] -> Xamarin.Android.Support.v7.AppCompat[0xa55c6ac0]: 3
D/Mono (20832): Image addref System[0x9417c8c0] -> System.dll[0x91551600]: 2
D/Mono (20832): Prepared to set up assembly 'System' (System.dll)
D/Mono (20832): Assembly System[0x9417c8c0] added to domain RootDomain, ref_count=1
D/Mono (20832): AOT: image 'System.dll.so' not found: dlopen failed: library "/data/app/[PackageNameHere]-1/lib/arm/libaot-System.dll.so" not found
D/Mono (20832): AOT: image '/Users/builder/jenkins/workspace/xamarin-android-d15-9/xamarin-android/external/mono/sdks/out/android-armeabi-v7a-release/lib/mono/aot-cache/arm/System.dll.so' not found: dlopen failed: library "/data/app/[PackageNameHere]-1/lib/arm/libaot-System.dll.so" not found
D/Mono (20832): Config attempting to parse: 'System.dll.config'.
D/Mono (20832): Config attempting to parse: '/Users/builder/jenkins/workspace/xamarin-android-d15-9/xamarin-android/external/mono/sdks/out/android-armeabi-v7a-release/etc/mono/assemblies/System/System.config'.
D/Mono (20832): Assembly Ref addref netstandard[0x9417c620] -> System[0x9417c8c0]: 2
D/Mono (20832): Assembly Ref addref Xamarin.Forms.Platform.Android[0xa55c6d00] -> Mono.Android[0x9417b960]: 32
D/Mono (20832): Assembly Ref addref [AppNameHere].Droid[0xa55c49c0] -> Rg.Plugins.Popup[0xa55c5c80]: 2
Loaded assembly: System.dll [External]
D/X:VideoSplashActivity(20832): Startup work is finished - starting MainActivity.

protected override void OnResume()
{
base.OnResume();
SimulateStartup();
}
It seems the problem is "SimulateStartup()" method in OnResume override. I removed it then video played as expected.

Related

How to supply hiveconf variable from hive oozie action

I want to supply variable as hiveconf namespace from my hive-oozie action, how to do that?
<action name="setupAct">
<hive xmlns="uri:oozie:hive-action:0.2">
<job-tracker>maprfs:///</job-tracker>
<name-node>maprfs:///</name-node>
<script>
XYZ.hql
</script>
<!--how to add variable to hiveconf-->
<param>DB_NAME=test</param>
</hive>
<ok to="ok" />
<error to="error" />
</action>
The values inside param element are supplied as --hivevar namespace to hive.
Below is application log, the param element gets added as hivevar:
------------------------
DB_NAME=test
------------------------
Hive command arguments :
--hivevar
DB_NAME=test
-f
test.hql
For hiveconf in Oozie, Use the configuration element.
<hive xmlns="uri:oozie:hive-action:0.2">
<job-tracker>maprfs:///</job-tracker>
<name-node>maprfs:///</name-node>
<script>
XYZ.hql
</script>
<!--how to add variable to hiveconf-->
<configuration>
<property>
<name>hive.default.fileformat</name>
<value>Parquet</value>
</property>
</configuration>
<param>DB_NAME=test</param>
</hive>

EasyAdminBundle entities labels translations

I'm unable to configure translations. My config.yml has (among others) this entry:
easy_admin:
entities:
Blog:
label: app.blog
class: AppBundle\Entity\Blog
I've also created a translation resorce: messages.es.xliff with this entry:
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="es" target-language="es" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="app.blog">
<source>app.blog</source>
<target>Blog</target>
</trans-unit>
</body>
</file>
</xliff>
but the translated literal doesn't appear in the left menu.
Thank you very much for your help.
At last I've changed the name of translation ressource to EasyAdminBundle.es.yml and now everything works fine.
Ensure you have the translator service enabled. In app/config/config.yml:
framework:
translator: { fallbacks: ["en"] }

Symfony2 - "Invalid Resource Exception" when translating twig template

I am trying to translate labels in my twig template located in Resources/views/User/ folder:
<label for="username">{% trans %}Username{% endtrans %} </label>
And the following is a section from my login.ka.xliff file located in my project under "translations" folder:
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="1">
<source>Username</source>
<target>მომხმარებელი</target>
</trans-unit>
</body>
</file>
</xliff>
and this is my route to the login page:
login:
path: /login/{_locale}
defaults: { _controller: ExampleBundle:LogIn:login }
requirements:
_locale: en|ka
I have two problems:
When I try to open the login page with a locale (say, ka) I get the:
500 Internal Server Error - Twig_Error_Runtime
1 linked Exception:
InvalidResourceException »
I know I can get the locale from request using $request->getLocale(); but how do I specify that login page should use login.ka.xliff file for translations?
Ok, I seem to have provided not enough info, so here it is:
I put my translation file in Example:MyBundle:Resources:translations (this is what I meant above "in my project").
I get exception when rending my login view and the following is the full version of the exception I get:
"An exception has been thrown during the rendering of a template ("") in ExampleMyBundle:User:login.html.twig at line 32.
500 Internal Server Error - Twig_Error_Runtime
1 linked Exception:
InvalidResourceException »"
And yes, I did try clearing cache each time I made changes, but it didn't help.
And also, I added the complete version of my login.ka.xliff file.
Thanks again!
Your xliff file seems to be invalid - it should look like this: ( containing the xml-namespace, body, ... ).
<!-- messages.ka.xliff -->
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="1">
<source>Username</source>
<target>მომხმარებელი</target>
</trans-unit>
</body>
</file>
</xliff>
The file should be named messages.ka.xliff if you haven't actually specified a different translation domain in your template!
{{ 'Username'|trans({}, "login") }}
... or configured a different default translation-domain in your template ...
{% trans_default_domain "login" %}
<trans-unit id="1">
<source>Username</source>
<target>მომხმარებელი</target>
</trans-unit>
... is an invalid xliff-file.

App in development hangs every second time it is run

This is a fairly straightforward question for such odd behaviour, but that is exactly what my app is doing on the Playbook. I open the app the first time and it runs perfectly. I close the app, and then open it again and it hangs/freezes after the first action I perform with it. I then close the app, it seems to reset itself, and then opens and runs perfectly the next time.
I am using the latest WebWorks and am debugging on the PB with a debug token. My previous app (written/tested on pre OS2.0) worked, and continues to work, just fine.
I am pleased to post code if you would like, but it may be a waste of space. In an effort to root out the problem, I wrote a quick Hello World app that writes one item to an HTML5 database on the playbook (my main app also uses WebDB), and that app, as simple as it is, has exactly the same behavior. All my apps function fine in Chrome.
If anyone has any thoughts about what could be causing this behaviour, please post a reply.
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="helloworld.js"></script>
</head>
<body>
<input type="text" id="testDBInput"/>
<button type="button" onclick="testDB()">go</button>
</body>
</html>
JavaScript Document:
var taskdb=openDatabase ("helloworldDB", "1.0", "test database", 10*1024*1024);
taskdb.transaction(function(tx)
{
tx.executeSql("CREATE TABLE IF NOT EXISTS maintable (id integer primary key autoincrement, nametitle TEXT)");
});
function testDB()
{
var testTitle=document.getElementById("testDBInput").value;
taskdb.transaction(function(tx)
{
tx.executeSql("INSERT INTO maintable (nametitle) VALUES (?)", [testTitle], function (tx, results)
{
});
});
}
blackberry-tablet.xml:
<?xml version="1.0" encoding="utf-8"?>
<qnx>
<icon>
<image></image>
</icon>
<author>***edited for privacy***</author>
<authorId>***edited for privacy***</authorId>
<platformVersion>1.0.0.0</platformVersion>
</qnx>
config.xml:
<?xml version="1.0" encoding="utf-8"?>
<widget xmlns=" http://www.w3.org/ns/widgets"
xmlns:rim="http://www.blackberry.com/ns/widgets"
version="1.0.0.0">
<name>Tester</name>
<description>
PB Tester
</description>
<rim:orientation mode="landscape"/>
<rim:loadingScreen onFirstLaunch="true" >
</rim:loadingScreen>
<author>***edited for privacy***</author>
<icon src="bdicon.png"/>
<content src="index.html"/>
<feature id="blackberry.app" required="true" version="1.0.0.0"/>
<feature id="blackberry.ui.dialog" required="true" version="1.0.0.0"/>
</widget>
It sounds like the javascript crashed when the appli hangs. testDB() has few lines, you can insert alert() to see which line is not reached

Spring MVC Static Resources partially work

I have a basic directory app that works fine except that it seems to only sometimes find the static resources that I’ve configured using the mvc:resources tag. My search of the board found problems related to handler mappings, but my problem seems to be different.
Specifically, when the PersonController is called via a method mapping to “/person”, it returns personlist.jsp using the view resolver and correctly finds and uses the static css and js files. No problems.
When the same controller is called via another method mapping to “/person/{familyid}” ( narrows the person list to a particular family), it returns the same personlist.jsp…but now it fails to find or use the css and js files (though it does display the correct data).
I don’t understand why there is a behavior difference since both scenarios use the same Controller, the same return String (return “personlist”), and resolve to the same JSP (ie. with the same Head section links for the css, js).
I looked at what came back in the browser for each case using ‘view source’, and both pages return the same head tag rendering for the css and js linking:
<link href="resources/css/directory.css" rel="stylesheet" type="text/css"></link>
<script type="text/javascript" src="resources/scripts/jquery-1.7.min.js"></script>
<script type="text/javascript" src="resources/scripts/directory.js"></script>
I thought the problem could be with my tag mapping, so I also tried this:
<resources mapping="**/resources/**" and
resources mapping="resources/**"
but no help.
Am I approaching the use of static resources properly here (and what is the right resources tag mapping if that’s the problem)? Thanks.
I am using Spring 3.0.6 and my css and js files are located under /WebContent/resources/css and /WebContent/resources/scripts respectively, which are mapped using the mvc:resource tag (see below).
PersonController:
#Controller
public class PersonController {
private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
/**
* Simply selects the home view to render by returning its name.
*/
List<Person> personList;
Boolean familyCalled = false;
#Autowired
PersonService personService;
#RequestMapping(value="/people", method=RequestMethod.GET)
public String people(Model model) {
logger.debug("Received request to show peoplelist page");
System.out.println("Running inside people() method of PersonController");
personList = personService.getPersons();
familyCalled = false;
model.addAttribute("personList", personList);
return "personlist";
}
#RequestMapping(value="/people/{familyId}", method=RequestMethod.GET)
public String familyMembers(#PathVariable("familyId") String fid, Model model) {
System.out.println("Running inside familyMembers() method of PersonController");
personList = personService.getPersonsInFamily(fid);
familyCalled = true;
model.addAttribute("personList", personList);
return "personlist";
}
Servlet-Context.xml (without namespaces):
<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
<!-- for transactions -->
<tx:annotation-driven/>
<!-- Needed for #PreAuthorize security on methods -->
<aop:aspectj-autoproxy/>
<context:annotation-config />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="resources/" />
<!-- Enables the Spring MVC #Controller programming model -->
<annotation-driven/>
<!-- Resolves views selected for rendering by #Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<context:component-scan base-package="com.c3works.preps" />
</beans:beans>
personlist.jsp (Head section):
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</meta>
<title>XXXXXXXXXXXXXXXXXXX</title>
<link href="resources/css/directory.css" rel="stylesheet" type="text/css">
</link>
<script type="text/javascript" src="resources/scripts/jquery-1.7.min.js">
</script>
<script type="text/javascript" src="resources/scripts/directory.js">
</script>
</head>
Your URLs are relative and therefore the browser is looking for the resources in the wrong place. (Check the resulting HTML code)
One solution is to use the <spring:url> tag to build the urls of the resources.
<spring:url var="banner" value="/resources/images/banner-graphic.png" />
<img src="${banner}" />

Resources