PhoneGap Downloader plugin in Android - android

I am new to Phonegap and I am currently developing an android app using jquery mobile and Phonegap.
I googled a lot on how to use the downloader plugin and how to call it in your Html file which contains the link of the file you want to download with the downloader plugin but couldn't find any working example.
Can anyone here please provide me with a simple working demo of the PhoneGap downloader plugin so that I will get relevant information on how to use it. Or help me in implementing the plugin and calling it on the specific url.
Thanks in advance. :)

I've used a downloader plugin quite a long time ago with phonegap 2.2 and it was quite easy to use.
Is this the plugin you are trying to use? or maybe this one?
The fist one seems to have been updated for the phonegap 2.7+ format so maybe usable in a phonegap 3 project, except that you won't be able to install using the CLI and will have to had the plugin manually in platform/android or you could write a plugin.xml yourself.
To use it, you just have to follow the instructions in the readme.md or read the original article in http://www.toforge.com/2011/02/phonegap-android-plugin-for-download-files-from-url-on-sd-card/
Again I haven't tried to use it in recent versions of phonegap and am not sure if the plugin should be updated to be compatible.
Edit:
For each file you have to call:
window.plugins.downloader.downloadFile("http://server/file.txt", {overwrite: true},
function(res) {
//function called when the file is downloaded
//the file content is in res
}, function(error) {
//function called in case of error
}
);
if you need to download several files, you could download the next file in the function called in case of success.

Related

monaca dosen't load www/index.html

I'm using monaca(onsenui-react) to create cordova app.
After type monaca preview I have checked app on browser like this.
But the index.html wasn't one I expected.
I mean have edited the www/index.html, but it's not loaded on browser.(I don't know what index.html was loaded)
Of course I typed monaca preview after edit www/index.html.
Does anyone can help me?
You need to run monaca transpile to transpile (kind of a compilation) your code into the www folder.
Using monaca preview will use the "webpack.dev.config.js" configuration to generate a compilation to a temporary folder. Using the "transpile" command will use the "webpack.prod.config.js" to compile your code into the www folder.
One more thing: monaca uses a strage combination of folders and package versions (most of them deprecated) to transpile, so I recommend you to do this manually if you are not using the monaca tools (the online paid stuff).
Recently I made a repo with everything already set up (using Onsen UI and React, also Redux - which is easily removable), using the latest version for every npm package (Webpack 2 being the most important, instead of the version 1 used by monaca) and keeping everything in your project folder (in your package.json, like it should be). You can find it here.

Cordova spatialite database for android not working

I am am trying to use spatialite plugin from
https://github.com/DisyInformationssysteme/Cordova-spatialite-storage
for my cordova application,
but the problem is that when i try to create database it shows me
Database open failed, aborting any pending transaction.
I dig a lot for alternative solution for using spatial feature, but unfortunately couldn't succeed.
We had the same problem but it looks like we managed to find a workaround. It seems that Cordova-spatialite-storage plugin has some issues with opening/creating a database if database does not already exist. If database exists, you should be fine but only if you also added cordova-plugin-file plugin.
Try these steps:
copy existing spatialite database to device (e.g. file:///storage/emulated/0/Download/database.sqlite - just for the sake of testing, later you should move it to more appropriate location)
add cordova-plugin-file plugin
check if cordova-plugin-compat plugin is also added
add cordova-spatialite-storage plugin
Try to open database with name: 'file:///storage/emulated/0/Download/database.sqlite' and run some spatial queries. It should work.
Please let me know how it went.

How to download a file from FTP and store it locally with Cordova?

I'm struggling for some days to do that. Without success.
I've found two ways that I think reasonably to follow:
1: Plugin cordova-sftp-plugin.
I see that it is writted to deal with 'secure ftp', but why wouldn't work in an ordinary non secure ftp? Nothing was metioned about it.
I've tried so, applying the 'Use Example' from the official page, the code fells in the success callback function, but when I list the local directory, nothing was changed! It gives me no clue about what goes wrong! In true, the software does not detect nothing wrong.
Before the previous steps, I did not forget to precautionally install and enable the 'cordova-plugin-file', 'cordova-plugin-file-transfer' and 'cordova-plugin-network-information' and to add the <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> in the AndroidManifest.xml. Tryied to save files in cordova.file.externalRootDirectory and cordova.file.externalRootDirectory + "/Downloads/. Nothing worked.
2. The macdonst FtpClient plugin.
Searching for my issue, one of the first pages that appears is How to ftp a file over to a server from PhoneGap/webapp?, and beyond some further search I've found another one in a relatively old post mentioned the successful use this plugin in a Cordova application. So I can consider this plugin as a stable choice.
The problem with this method comes earlier: I coundn't even build the application after a manual installation proccess. May it is a problem in the manual installation proccess.
The official plugin documentation teachs to install it in a PhoneGap application, and not a Cordova. The steps was not replicable to Cordova, due to some differences in paths and configuration, and some others links also supports the plugin installation solely in Phonegap, not Cordova.
I also tryied follow the steps in the http://antonylees.blogspot.com.br/2015/01/how-to-manually-add-cordova-plugins-to.html and Manually install Device plugin (and others) into cordova 3.0 to manually add the plugin. The steps in the first link also was not well replicable, and although the second one are more straitfoward, also does not solved the issue.
Building it gives me a java error compilation. The first error output (what uses to cause all the following errors are):
E:\danilo\Documentos\projetos_cordova\ftpDownload3\platforms\android\src\com\phonegap\plugins\ftpclient\FtpClient.java:27:
error: package org.apache.cordova.api does not exist
import org.apache.cordova.api.CallbackContext;
Very strange. May I have to search for the org.apache.cordova.api jar file and put in the lib folder? Also, I did not forget to put the commons-net-2.2.jar in the project libs folder.
Can anyone have some suggestion to succeed this? I just want to download a file through ftp protocol and save locally and so, if there's an alternative method to succeed, it will be appreciated too.
Thanks in advance.

Phono Mobile SDK integration with Phonegap

Iam trying to integrate Phono Mobile with Phonegap.
I did the following steps:
Add the Phono Plugin
Copy the contents of libs to your PhoneGap libs directory. This includes:
armeab/libg722.so
phonogap.jar
srtplight.jar
Copy 'jquery.phono.js' to your PhoneGap 'www' directory and include it in your app (e.g. index.html)
Added com.phono.android.phonegap.Phono res/xml/plugins.xml
voxeolabs.net,phono.com access origin also added
But Phono object was not being initiated. Please correct me if iam doing anything wrong.
Thanks
Simple try links like
Call me!

Unity Android plugin - package rename issue

I'm developing a simple plugin to Unity Android, that displays an image from the web.
I've created a Jar using my Java files, and loaded it (in a blank Unity sample application) using AndroidJavaClass.
All worked fine, but then I've wanted to rename my Java package.
From now on - I can't see the image. The plugin doesn't even trying to access it.
I've changed the package name in the Java files, and also in the AndroidManifest.xml and in the CS file that's calling it.
The Jar compiles successfully, the application runs on the device, but... nothing.
I've also created a new application that uses the plugin with his new name, but no success.
What have I done wrong?
Or - what can I do to make it work?
Thanks,
Keren
Why would you code a plug-in to display a web image ?
Just use unity native WWW call, then put the result in a texture.
Look at the unity docs.

Categories

Resources