I am making an Android app using HTML5 on Netbeans IDE. I am using the Cordova framweork to build. Until now, everything is OK except, I cannot make the splashscreen works.
I consulted the Phonegap documentations but in vain. Here what I did below:
The splashscreen plugin is already added in the Cordova plugins
section on Netbeans IDE.
I put the PNG images in the platforms/android/res/drawable/* folders.
I checked the parameters of the splashscreen in the XML Config file
which is located in res/xml/config.xml. It seems the parameters
are OK just like on the documentation.
I included the configurations in the XML Config file which is located in the WWW folder.
And finally, I copied and pasted the JavaScript codes in my
index.html file in the Head section just like on the documentation as
shown below:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
navigator.splashscreen.show();
}
Here are the two Phonegap documentations links:
http://docs.phonegap.com/en/3.3.0/cordova_splashscreen_splashscreen.md.html
http://docs.phonegap.com/en/3.3.0/config_ref_images.md.html#Icons%20and%20Splash%20Screens
So, where is the mistake? Thank!
you need to set this -
<preference name="SplashScreen" value="splash" />
<preference name="SplashScreenDelay" value="10000" />
in config.xml
Related
I have an error when I run my app on ionic cordova run android.
My error is : Connection to the server was unsuccessful. (file ///android_asset/www/index.html)
I try to resolve it with forums that exists with this solution :
1)Rename your index.html to “main.html”
2)Create a new “index.html” and put the following content into it:
<!doctype html>
<html>
<head>
<title>title</title>
<script>
window.location='./main.html';
</script>
<body>
</body>
</html>
Or modify in the config.xml this line :
<preference name="SplashScreenDelay" value="3000" />
to this line :
<preference name="SplashScreenDelay" value="70000" />
But when I run my app after saving my new code, the error still appear and when I return into my code, I see that the code is still the same and not has been modified (even if I modified it like I sayed previously !)
Someone know how to resolve my problem ?
Thanks in advance,
Caroline
I had that error with one application and I solved it with Crosswalk.
ionic plugin add cordova-plugin-crosswalk-webview
After installation you may have to adjust the design but the error will no longer appear.
More about Crosswalk.
Optional config.xml settings:
<preference name="loadUrlTimeoutValue" value="60000" />
<preference name="AutoHideSplashScreen" value="false" />
Try updating your Cordova android platform:
ionic platform remove android
ionic platform add android
Add and Remove android platform
ionic platform rm android
ionic platform add android
It's not really an answer but it allowed me to see my app without the error message.
When I run my app with the terminal ionic cordova run android the error still persist.
But if I run my app with Android Studio it's works !
I installed cordova-plugin-splashscreen but this doesnt help me.
What lines should I add to my config.xml file and where to place the splash.9.png file?
Previously (before updating my Cordova version to the latest one) splashscreen was working fine with the following options:
<preference name="splashscreen" value="splash" />
<preference name="splashScreenDelay" value="10000" />
and one splash.9.png file in res/drawable folded.
What am I doing wrong?
Add your splash screen in respective drawable folder to match for all density devices.
and dont mention the value screen.png in preference.mention as like .(make sure your value is the file name of your splash image)
Reference Link
Finally I got it!
The problem was in the external ad SDK - AppJolt. As soon as I turned it off it began working again!
I have an Android Phonegap proyect and I'm trying to use the Splashscreen plugin Cordova provides. I think I have everything correctly set... Here are the pieces of code I think are relevant.
Config.xml
<widget ...>
...
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="15000" />
<plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
</widget>
Index.html
<script type="text/javascript" charset="utf-8">
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
navigator.splashscreen.hide()
}
</script>
I have correctly installed with the CLI the plugin and the splash itself is in the res/drawable* folders in the Android project as I think it should be, but regardless of what I try to do, the splash is not showing. Not even a default one. Not even if I disable the navigator.splashscreen.hide() function (in case it was too fast).
I'm absolutely lost now, have been trying tweaks for a week but I just can't see it.
I'm using cordova v3.6.3 in my android project.
I read a API & Plugin Documentations but, I confused the some options in config.
but, I found a perfect solution.
1. above all, you don't need to use
"navigator.splashscreen.hide()" or ".show()" in Android project.
2. refer my directory structure for understanding clearly.
3. Add following codes into your config.xml file.
※ Do not change the value="screen".
you just change the src and delay value for your splashscreen image.
[Config.xml]
<platform name="android">
<splash src="www/res/screen/android/screen-default.png" />
</platform>
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="4000" />
4. delete a "screen.png" file from drawable directory for understanding clearly.
5. build your project on your command line (cordova build android)
and, look again drawable directory.
I'll promise, you'll success. :-)
I was having the same issue after the 2.5.1 CLI update. If i run the same project in the VisualStudio ionic simulator all works fine. It also works fine when I run the app in the bowser with Telerik Platform. I just need to comment out navigator.splashscreen.hide(); in my project for the latest CLI simulator or I just get a plain white screen.
James
I have created a jquery form which has a script to generate an xml file. I want to save this generated file to an SD card on my Android tablet.
I just for the life of me can't figure out the script needed to save it.
I have this script on the .js used to create the XML
$('#ResultXml').val(newXml);
$('#SaveLink')
.attr('href', 'data:text/xml;base64,' + btoa(newXml))
.attr('download', 'SiteVisit.xml');
$('#generated').show();
}
and a "SaveLink" button on my form that calls the script. This works on my desktop computer but does nothing on the android that the form is designed to deploy on.
I have added the permissions
<preference name="android.permission" value="WRITE_EXTERNAL_STORAGE" />
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
<preference name="AndroidExtraFilesystems" value="files,files-external,documents,sdcard,cache,cache-external,root" />
<gap:plugin name="org.apache.cordova.file" version="1.0.1" />
to my config file (I am using PhoneGap Build)
Any help with this would be more than appreciated
Using PhoneGap you can use the cordova plugin file:
https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md
If you don't want to use phonegap, you can create an interface between your activity and your webview:
http://developer.android.com/guide/webapps/webview.html
I am using phonegap plugin and I could not get it to work. In the plugin, there is a plugin.xml and may I know how this file should be set up.
I have mine configured as below and it does not work.
<platform name="android">
<config-file target="res/xml/config.xml" parent="plugins">
<feature name="GAPlugin" >
<param name="android-package" value="com.adobe.plugins.GAPlugin"/>
</feature>
</config-file>
<source-file src="src/com/learnchn/pinyin/GAPlugin.java"
target-dir="src/com/learnchn/pinyin" />
<source-file src="libs/libGoogleAnalyticsV2.jar"
target-dir="libs" />
</platform>
plugin.xml is a file that is meant to be read and executed by tools such as the plugman to install a plugin to a platform. If you are not using such a tool then you may try to do the steps manually. Basically insert <feature> to res/xml/config.xml and copy src files on <source-file> to target-dir.
However I doubt that the plugin.xml you have posted is valid. The value for "android-package" parameter should point to the plugin implementation. The value "com.adobe.plugins.GAPlugin" would suggest that there would be a corresponding source file or a library with that class name added as part of the installation. However the only file that is added with a close name is "com/learnchn/pinyin/GAPlugin.java" which has a different package name.
At first you have to build your project with phonegap. Navigate to the location where you want to create your project and do the following:
phonegap create test com.example.test Test
cd test
phonegap local build android
Now you have a working android project in your "platforms/android/" directory which you can import in eclipse. Download the GAPlugin and unzip it. Then just use plugman to install the Google Analytics Plugin.
plugman install --platform android --project (Path to your phonegap android project) --plugin (path to the GAPlugin)
Now everything should be set and the plugin is installed. The next step would be initializing the plugin in your index.html to track every page visit. Add the GAPlugin.js
<script type="text/javascript" src="GAPlugin.js"></script>
You should add the following code after you received the "deviceready" event.
document.addEventListener("deviceready", onDeviceReady, false);
var gaPlugin;
function onDeviceReady() {
gaPlugin = window.plugins.gaPlugin;
gaPlugin.init(successHandler, errorHandler, "UA-********-*", 10);
// Put this function everywhere you want to track something
gaPlugin.trackPage( nativePluginResultHandler, nativePluginErrorHandler, "index.html");
function successHandler() {}
function errorHandler() {}
function nativePluginResultHandler() {}
function nativePluginErrorHandler() {}
}
This approach worked for me. I'm using Phonegap 3.0 with the CLI.
Hope this fixes your problems ;)
If u want to add simple google Analytics setup then its quite easy just follow the below steps
1:- Add libGoogleAnalyticsV2.jar in libs folder 2:- Add analytics.xml file inside res->values, it binds the trackingid with the app,u can google for this file 3:-Add import com.google.analytics.tracking.android.easyTracker; in the activity file and use EasyTracker.getInstance().activityStart(this); in onCreate function.
Thats it, you are done with Google Analytics basic setup