Does anyone know how does MondgoDB works on Android.
Does it work locally and you the data gets replicated later? Does work only online with just a web backend?
MongoDB has downloads for several operating systems. However, Android is not one of those systems.
People use MongoDB as a "web service" for storing data, but it does not have any features to support multi-master replication or your occasionally connected mobile scenario.
If you need these types of features, you'll want to check out CouchDB which specifically targets this scenario with Android Couchbase.
I'm going to revive this thread and say that MongoDB's Java driver IS currently compatible with Android. Some novice developers might have trouble getting their apps to use MongoDB's java library, so I'll just outline what you have to do (though all of this could be obsolete by the time you're reading this).
Go to your app build.gradle file. Add this "compile" entry under your dependencies (you will probably have to replace the version):
dependencies {
...
implementation 'org.mongodb:mongo-java-driver:3.0.3'
}
As you can see, the driver's version as of this post is 3.0.3. You can find the current version by searching "mongo-java-driver" or any related terms at http://search.maven.org.
If you're connecting to an external database, you will of course need to add the INTERNET permission to your manifest. Connecting to one is pretty simple. Here's an example. Replace the username, password, host domain, port, and database name:
MongoClientURI uri = new MongoClientURI( "mongodb://username:password#www.example.com:12345/db-name" );
MongoClient mongoClient = new MongoClient(uri);
MongoDatabase db = mongoClient.getDatabase(uri.getDatabase());
Since this is network related, you will need to run all of that in an AsyncTask class.
Following the java tutorials on https://www.mongodb.org/ should be relatively straightforward from here on out.
Dory mongoDB Server
Great new Android application
No Need to root your Phone and You Can Run your js File From anywere.
MongoDB (from humongous) is a free and open-source cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with schemas.
Usage:
1: install Dory mongoDB Server
2: run your Server
3: install Dory node.js
4: run this code in your js file:
Code:
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test', { useMongoClient: true });
mongoose.Promise = global.Promise;
var Cat = mongoose.model('Cat', { name: String });
var kitty = new Cat({ name: 'Zildjian' });
kitty.save(function (err) {
if (err) {
console.log(err);
} else {
console.log('meow');
}
});
Enjoy. 😉
Unfortunately Mongo Java Driver 3.8.0 is not compatible with Android anymore: https://gitlab.com/mvysny/umn/issues/1 and they don't even claim Android support. Maybe following the unofficial fork or trying GnuSasl could help? mongodb 3.x driver Android compatibility
MongoDB is also available for android
The only problem is that it does not have well-structured documentation for android..
I recently managed to connect my android application to the remote database
here is a sample unit application
https://github.com/i-sachinkumar/MongoDB-for-Android
Its readme file contains all the steps to be followed in the back-end as well as in the android studio
Reactivating this Topic again after 2 years.
I was looking for an android app exactly like MongoDB Compass, but couldn't find "exactly" like it. So deciding to make one (and open source it)
Based on links given in #Astral1990's answer, I found this.
Now for a gist:
Gradle file: (more info here)
implementation 'org.mongodb:mongodb-driver-sync:4.2.3'
For creating the client: (more info here)
MongoClient mongoClient = MongoClients.create("mongodb://user1:pwd1#host1/?authSource=db1");
Then other things:
// get db
MongoDatabase database = mongoClient.getDatabase("test");
// get collection in db
MongoCollection<Document> coll = database.getCollection("myTestCollection");
// list collections (permission has to be present)
for (String name : database.listCollectionNames()) {
System.out.println(name);
}
Queries and others
It isn't possible to install MongoDB in android devices because the MongoDB's latest releases doesn't support android device's CPU architecture.
But I read an article on codipher.com and i gave it a try and it finally worked, i was able to use MongoDB on my android phone.
Here is the link: https://codipher.com/install-mongodb-on-android/
Related
I'm developing an Android application that uses U.are.U 4500 fingerprint reader to identify users. I already have a backend server, that uses SQL Server, to store and register user data and now I need my app to be able to read the user fingerprint and verify if this fingerprint matches any of the fingerprints on the database. Does anyone know a SDK that is able to do this comparison?
I'm using asia.kanopi.fingerscan package to read the user fingerprint and I already have the scan working, now I only need to get this image and compare to the data on the SQL database. I saw a few answers here on StackOverflow telling me to use openCV library for Android, but none of them could give me any lead on how to do it.
I based my development on this tutorial: https://medium.com/touch4it/fingerprint-external-scanner-with-usb-database-sdk-64c3ec5ea82d, but unfortunately I couldn't find the SDK IDKit Fingerprint SDK Mobile anywhere.
How can I sucessufully match the image with the one stored on the database?
For those who are still looking for an answer to this problem. It's been a while since I actually implemented my solution and, when I did it, I added this line to my app gradle file:
com.github.lmone:SourceAFIS-Android:v3.4.0-fix3
But now I can't seem to find the github link anywhere. Maybe the repository got deleted. If someone find it, please send it to me so I can update my answer here.
Besides that, if you can still add the library to your Android project, the basic idea is to use a FingerprintMatcher to compare two FingerprintTemplate.
Example:
FingerprintTemplate probe = new FingerprintTemplate().dpi(500).create(digital_byte_array);
while (result.next()) {
byte[] imgCandidate = digital_to_compare;
FingerprintTemplate candidate = new FingerprintTemplate()
.dpi(500)
.create(imgCandidate);
double score = new FingerprintMatcher()
.index(probe)
.match(candidate);
if (score >= 40) {
// Found a match
}
}
In my case, I found the performance a little slow. It was usable, but nothing compared to Android's built-in fingerprint device. Also, the bigger your digitals collection, the longer it will take to find a match.
The score of the match is up for you to decide what suits better your project. 40 was a reliable amount in my case. The same goes to the FingerprintTemplate dpi.
Also, the method .create() receives a byte[] as parameter.
EDIT
I found this link and I'm almost certain it is the library I used, but under a new repository name:
https://github.com/robertvazan/sourceafis-java
The docs looks just the same as the code I used: https://sourceafis.machinezoo.com/java
To match a user on server side, you have to use an AFIS server : https://en.wikipedia.org/wiki/Integrated_Automated_Fingerprint_Identification_System
Here some providers of AFIS solution:
http://www.neurotechnology.com/megamatcher.html
https://www.nec.com.au/expertise/safety-security/identity-access/fingerprint
https://www.innovatrics.com/innovatrics-abis/
https://www.dermalog.com/products/software/civil-afis-abis/
http://www.m2sys.com/automated-fingerprint-identification-system-afis/
Ok so I have been stuck here for about more than a week now and I know its some dumb mistake. Just can't figure it out. I am working on a project that is available of two platforms, Android & iOS. Its sort of a facial recognition app.
When I try to create/access collections from iOS application and python script, they both access the same collection from my AWS account.
But when I try to access from Android application, it creates/accesses it's own collections. The collections created by Android app are neither accessible anywhere other than this Android app nor this android app can access collections created by iOS app or python script.
I have tried listing collections on all these three platforms. iOS and Python list exact same collections while the collections listed by Android app are the ones created by an android app only.
Here is the code I am using to list collections on android:
mCredentialsProvider = new CognitoCachingCredentialsProvider(
mContext.getApplicationContext(),
"us-east-2:4xbx0x6x-9xbx-xax7-x9xf-x5x0xexfx1xb", // Identity pool ID
Regions.US_EAST_2 // Region
);
mAmazonRekognitionClient = new AmazonRekognitionClient(mCredentialsProvider);
ListCollectionsResult listCollectionsResult = mAmazonRekognitionClient.listCollections(new ListCollectionsRequest().withMaxResults(20));
Log.i(TAG, listCollectionsResult.getCollectionIds().toString());
This is the log result:
[i_facesbxyxuxqxbxvxlxwx6x7xex5xmxfx, i_facestxnxaxoxoxqxaxwx4xtxuxwxoxrx, root_faces_data]
This is the python code I using to list collections:
import boto3
client = boto3.client('rekognition')
response = client.list_collections()
print(response['CollectionIds'])
This is the result:
['i_facesbxyxuxqxbxvxlxwx6x7xex5xmxfx', 'root_faces_data']
That's it. Nothing else. Just this code. You can see that one is showing 3 collections while other is showing two.
I am using the exact same region and identity pool ID in iOS app and it's listing same collections as in python.
The reason I think iOS app is fine because the collections listed by both iOS and python are same.
Is there anything I need to change? Is there any additional setup I need to do to make it work?
Please let me know. Thanks.
So like most of the time, I saved myself.
Turns out when we pass cognito credentials to Rekognition client in Android, it does not use the same region as that of Cognito. So we have to explicitly set region of Rekognition client as well. Like this:
mAmazonRekognitionClient.setRegion(Region.getRegion(Regions.US_EAST_2));
And that's all.
Im building mob app for ios and android using xamarin studio on Mac and i want to connect to a mysql DB . so Ive downloaded the MySql connector from the below link : http://dev.mysql.com/downloads/connector/net/
and referenced it in my code and added the below code :
MySqlConnectionStringBuilder conn_string = new MySqlConnectionStringBuilder ();
conn_string.Server = "serverIP";
conn_string.UserID = "user";
conn_string.Password = "pssword";
conn_string.Database = "DBTest";
MySqlConnection conn = new MySqlConnection(conn_string.ToString());
conn.Open();
conn.Close()
When i build the solution ,the build is successful but when I run the solution ,it will give me the following error :
System.TypeLoadException has been thrown Could not load type 'MySql.Data.MySqlClient.MySqlTrace' from assembly 'MySql.Data, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'.
at
conn.Open();
I found later that this version is not compatible with xamarin.ios or xamarin.android profile .
After long research ,the choices available are :
-Use a MySql.Data.dll assembly built against a PCL profile that is supported by Xamarin.Android or Xamarin.iOS
-Recompile the MySql.Data source against the Xamarin.Android or Xamarin.iOS profile assemblies.
Does anybody have a workable DLL or was able to go through the above solutions or if there are any other ideas ?
Really appreciate it
I think the general approach when connecting to remote databases from a mobile app is to call a webservice (preferably rest based service with JSON). This way your logic for connecting to a MySQL, Oracle, SQL server database is solely on the server. For connecting to local databases on the device generally most folks will use SQLite. Hope this helps.
As of my opinion it won't be wise to connect directly to a MySQL database from an iOS app.
Personally I would need to make a web-based backend using REST, JSON or PHP. Or even a combo :)
Check this link for understanding the logic behind it: http://codewithchris.com/iphone-app-connect-to-mysql-database/#connectiphonetomysql
Otherwise try check your thread at the Xaramin forums :) Link for others
We are using Cordova along with AngularJS for iOS and Android applications.
One big disadvantage of iOS are the long review times from Apple. In Google's Playstore, your app is available nearly immediately, or within a few hours. But Apple takes ages to review your app, even when it's only a small change.
So I was thinking, if there is a way to support some kind of live update.
That means, I could provide a ZIP file or something else with a new codebase, my app checks for updates and then installs the new files.
I've read something from appmobi, but are there any open source solutions?
cordova-app-loader is an easy to use plugin to update app files via 3 simple steps:
check() for a new manifest
download() files
update() your app!
It supports android and iOS
I don't know of any ready made solutions for that, but it should be easy enough to program something like this on your own.
Here are some points to get you started and to consider:
If you want to distribute updates via zip, you need a nativ plugin which handles the extraction
You might not be able to override files in the default location of your app (depending on OS). So, all files you want to update in the future have to sit in a folder your app has read/write access to (iOS: e.g. Library or Documents folder)
Now you simply need to download the zip-package, unpack the zip to your chosen directory, and restart/reload your app.
you will not be able to update native plugins!
Apple probably doesn't like that, since you are able to change the whole application without passing
their review process
I'm doing this inside my cordova app and haven't had any issues with ios app store review.
I'm using Jquery's ajax function to download both a javascript and a css file from a server that I can change without an app store approval and then I can inject those scripts once they downloaded on app startup.
I tried using the cordova File api and I'd then save the file locally, but offline support ins't the important to me at the moment and Jquery's ajax is much simpler.
Here is the jquery code I use. I have a bundle id that I use to detect if a new javascript file is available, otherwise jquery's ajax caches the previous requests to speed up download time.
This solution lets you have a subset of your code be dynamic. I still have a base set of code that is bundled with the app, along with native plugin js and native code which would need to go through the app store. But this atleast lets me push bug fixes without going through the app store.
Otherwise, I'd look at a solution like this: http://docs.build.phonegap.com/en_US/tools_hydration.md.html
function insertScript(version) {
var scriptUrl = "";
try {
// get javascript file...
scriptUrl = mobileWebServiceUrl + "/DynamicContent/Bundles/Scripts/dynamic";
scriptUrl += "_" + bundleVersion.replace(/\./g, "_") + ".js?v=" + version;
console.log("downloading script: " + scriptUrl);
// Allow user to set any option except for dataType, cache, and url
options = {
dataType: "script",
cache: true,
url: scriptUrl
};
// Use $.ajax() since it is more flexible than $.getScript
// Return the jqXHR object so we can chain callbacks
return $.ajax(options).success(function(response) {
console.log("insertScript success");
dynamicContentScriptLoaded = true;
});
} catch (e) {
//console.error(e);
ReportError("problem downloading javscript: " + scriptUrl);
}
}
function insertCSS(version) {
try {
// get css file...
var cssUrl = mobileWebServiceUrl + "/DynamicContent/Bundles/Css/dynamic";
cssUrl += "_" + bundleVersion.replace(/\./g, "_") + ".css?v=" + version;
console.log("downloading dynamic css: " + cssUrl);
$.ajax(cssUrl)
.success(function (response) {
console.log("successfully downloaded dynamic css");
var script = document.createElement("style");
script.type = "text/css";
script.innerHTML = response;
$('head link').each(function () {
if ($(this).attr('href').search('MobileFrame') > -1) {
$("#MobileFrameCSS").before(script);
}
});
dynamicContentCssLoaded = true;
// TODO: implement caching at a later date
//if (isPhoneGap())
// saveFile("DynamicStyles", response);
});
} catch (e) {
ReportError("problem downloading css");
}
}
Well, Adobe offers exactly that service in their Phonegap Build service. It's called Hydration.
The example shows using it with Android and iOS platforms, so I guess they made it compatible with the iOS Dev Program License Agreement.
If you are using Cordova, you probably will have to switch to the Phonegap CLI if you want to use their build cloud services, which is basically the same as Cordova's with some extra commands to upload to their cloud, etc.
I think there are some plugin like Splashscreen wich also have some minor changes (using <gap>for params into config.xml instead of <preference>). Again, if Hydration solves the problem for you, the changes are minor and you get a really nice feature.
I think the best choice would be to not try to do this with Phonegap, but rather identify your dynamic parts and implement these in Javascript.
Yes, I mean you should indeed use Javascript yourself without Phonegap, for example via JavaScriptBridge:
https://github.com/kishikawakatsumi/JavaScriptBridge
It may require more work initially to redesign your app into a "static" part (your PhoneGap app) and dynamic part (dynamic created views via JavascriptBirdge), and interacte seemlessly between them. But in my opinion, that will be ultimately the best software design.
However, also make sure you still meet Apples AppStore requirements.
The Meteor framework provides exactly this functionality when combined with PhoneGap. It's even sanctioned by Apple in the latest Developer Agreement. Here are some technical details and then some about Apple's view on it.
I think there is no such solution is available, but you can do it by programmatic way.you can update your cardova app by fetching files from server and updating it.
Check out CodePush from Microsoft. Works with Cordova and React Native.
Appears to be very similar to the "live update" feature from Ionic Cloud.
If you migrate to capacitor, the successor of Cordova there open source solution now.
Capacitor-updater, is the only alternative to ionic AppFlow.
The updater allows you to manage update by yourself, store your zip update where you want and use the download method.
How to start
npm install #capgo/capacitor-updater
npx cap sync
Then in your main JS, this is required to let the updater know the update is valid
import { CapacitorUpdater } from '#capgo/capacitor-updater'
CapacitorUpdater.notifyAppReady()
And lately after checking yourself the current version need update:
const version = await CapacitorUpdater.download({
url: 'https://github.com/Cap-go/demo-app/releases/download/0.0.4/dist.zip',
})
await CapacitorUpdater.set(version); // sets the new version, and reloads the app
After many request of people didn't want to do that themselves, I started Capgo a business to manage all the update process.
All is open source and can be replicate on your own as well.
Doing things for Capacitor is now my main activity, I produce open-source plugin as my main channel of Marketing, I'm solo founder and bootstrapped.
Hope my tool will help you !
I am trying to develop a Moodle Android app. I am using MoodleREST source code for my reference.Is there any other documentation on Moodle site which documents moodle core webservice functions with their required params.
I have found list of functions here http://docs.moodle.org/dev/Web_services_Roadmap but could not get proper documentation on how to call these functions with required params from mobile client using REST.
I am new to moodle and still learning it, so my question can be a little naive so please bear with it :)
This could be helpful http://docs.moodle.org/dev/Creating_a_web_service_client
And if you have some administrator access to Moodle, go to
yourmoodle/admin/webservice/documentation.php , or
Administration > Plugins > Web services > API Documentation.
There is API with documentation. (Dont know if there is better way though :/)
D.
AIUI you need admin to access the most comprehensive web service API, as described by #Dolfa. You'll need these docs and/or the source if you're developing against their REST API. The API docs are generated from the source, presumably so they accurately reflect the API in the installed version.
You could:
Browse the code on github
Clone the version you intend to program against so you can browse the code locally
Install it and give yourself admin so you can browse the API docs.
If you don't want to go through the hassle of setting up a local Moodle instance, you may be able to figure out a way to run the php that generates the docs.
Once you have a rough idea of an API call, you can often find out the details by looking at responses to command-line requests e.g.
curl 'https://your.domain/webservice/rest/server.phpmoodlewsrestformat=json' --data 'wsfunction=core_enrol_get_users_courses&wstoken=[your_ws_token]' --compressed | python -m "json.tool"
gives the response
{
"debuginfo": "Missing required key in single structure: userid",
"errorcode": "invalidparameter",
"exception": "invalid_parameter_exception",
"message": "Invalid parameter value detected"
}
indicating that the function requires a userid=[userid] argument.