Connecting to a MongoDB with Android in Eclipse - android

I am currently developing an Android application, which is going to use a database from MongoLab. Another member of my team has already created a working database on mongolab.com, I am just having trouble connecting to it via Eclipse.
I have looked all around Google and at countless tutorials, but I really don't know much about what I'm doing.
The best tutorial I have found is from mkyong.com. It seems the second section labeled Java MongoDB Examples is what I am looking for, but I cannot get the library being used in those examples imported into my projects.
Is there a URL I can search for in Help >> Install New Software in Eclipse? I have downloaded the mongo-java-driver, but do not know how to incorporate that into my Eclipse.
To clarify again, I have no need to create a MongoDB, I am just trying to connect to an existing database via an Android project in Eclipse.

You must add the driver jar to your CLASSPATH, please refer to this FAQ.
If you have done this correctly Eclipse should be able to provide import for the the Mongo class if you type something like:
Mongo mongo = new Mongo("localhost", 27017);

I think you need to use the rest API provided by the Mongo Lab , not the java API. Send Http call to the server and get the response and parse it using JSON Parsor, that should do it.

Java Mongo driver 2.6 is compatible with Android.
The actual version 3.0.3 isn't compatible with Android because javax.security.sasl.* isn't implemented on Android.
I'm working on a forked version of 3.0.3 adding javax.security.sasl classes of this project https://github.com/koterpillar/android-sasl

Related

How to use Algolia in Android with Firebase content

I made an app where anyone can sell a product: you set its details and then I save it in Firebase.
On the client side (Android app) I want to be able to search for products using plain text.
I think the best way is by using Algolia but I really have no idea how to set-it up. Your help will be appreciated!
There are actually two topics in your question: how can one link Algolia to a Firebase database and how can one build an Android app with Algolia. I'll cover both in my answer.
How to link Algolia to Firebase
You will need to use a scripting language to import your existing data into Algolia and to sync the changes when your data is updated. Algolia has a guide to help you do so using Node.js.
You don't need to be experienced with Node.js to do it! Have a look at this question where an Android developer like you with no prior experience of Node.js just followed the guide:
In the first gathering of data, I just copied the integration code, did the necessary changes and ran it on Windows terminal: the data is now imported from Firebase to Algolia.
You simply need to:
Copy the code samples from Algolia's Firebase guide
Replace the credentials with yours
Run the scripts from your computer (if you never ran js scripts locally, search for a Node.js beginner's guide like this or this)
Once your data is imported in Algolia, you can move on to step 2:
How to use Algolia in your Android app
For building your search interface with Algolia, the recommended tool is InstantSearch Android. It's a toolbox that provides you plug-and-play components to build your search interface quickly: InstantSearch will handle all the network-related issues, the data-binding, and many other things so you can focus on what's specific to your app.
You can have a look at InstantSearch Android's demo apps which will show you examples what you could build using this tool, like this Media demo:
Algolia also provides an Android API Client for building apps. It lets you interact at a lower level with Algolia: you send the requests, get the results as JSONObject and decide what you want to do with it.
Most projects should use InstantSearch Android as it is built to make your development easier and faster (and it actually uses the Android API Client under the hood!)

Compile code with reference to Android without the SDK

We are building a game for Android that uses a server to allow people to play online. The server shares the same project than the application because it works by serializing classes to exchange messages between the clients and the server. So we have so classes that are both used by the server AND the android application. Of course, the server does not use Android code so that it can be run on a Desktop computer. For now, everything works fine on our PCs.
The problem is that we have almost finished the game and the server and we want to install the latter on a dedicated server. We just realized that it was not possible to compile it on the server (it is a strong requirement that we cannot bypass, we have to provide the source code that will be compiled on the server) because the Android SDK is not installed on the server and Java encounters errors while compiling the shared classes that contains Android code (not used by the server, once again). So we are in a difficult situation as we cannot require to install the Android SDK on the server just to be able to compile the program... Especially because the server never runs Android code so once compiled, the SDK should not be required anymore.
We are aware that it is a design flaw, but we cannot just delete the server and restart a new one with a better architecture right now, we are stuck... Additionally, the shared classes cannot easily be refactored as the whole architecture of the project is based on the fact that the server can serialize them and the client just has to call a method in them that runs Android-specific code.
What is your opinion about the possible solutions?
Thanks!
In Android SDK you can find a file called android.jar. For example for API level 22 its location is $ANDROID_HOME/platforms/android-22/android.jar. This file contains all the public classes and method stubs, so you can use it for compilation as a runtime dependency.

How to build MySQL plugin for Qt android?

I’ve qt-opensource-windows-x86-android-5.2.1 installed and I’m using windows 8 64bit.
I've Known that only sqlLite driver is available for android, but I want to use MySQL. So is there a tutorial more detailed than this one
explains how to build the MySQL driver for Android on windows.
Note: The Application I've built runs successfully on windows but it doesn't even open in android.
I handled same project request the Android Apps work with MYSQL.
But our solution is using RSS and external XML to read/write the database.
Sorry about that cannot really help with your problem.
If RSS and PHP page is acceptable. I think you can try with it.

how to include client libraries in 2nd android application generated by GAE Backend for the 1st android app

I have successfully developed an android application with Google App Engine as the Backend. Now I want to develop 2nd android application and want to connect it to the same App Engine of the 1st App. In short. 2 android applications with same App Engine at the backend hence common datastore.
Could not find the detailed and satisfactory answer, please provide the answer in detail. Thanks
I am assuming that the first Android application connects to the App Engine backend using a REST APIo r in general a Web Service. That is the recommended route and you should be able to use the same API in your second Android Application too !
Do give more details if this is not what you were looking for.
Surprisingly, the Eclipse plug-in doesn't really support this - it will only automatically copy the generated client files into a single project.
Fortunately, there are some (manual) solutions that are discussed here:
How to move Cloud Endpoints generated sources.jar library into Android project

how can meteor be coupled to an android app?

The meteor homepage (www.meteor.com) says in bullet point 8 ("interoperability"):
You can connect anything to Meteor, from native mobile apps to legacy
databases to Arduinos. Just implement the simple DDP protocol.
Question: Android is Java, how can it connect to meteor (js)? Any links to useful resources / tutorials would be appreciated!
DDP stands for Distributed Data Protocol and is specific for Meteor.
There is no built-in Android/Java support yet, but here is an official Meteor DDP client written in Python that you could use as a reference: https://github.com/meteor/meteor/tree/devel/examples/unfinished/python-ddp-client
More information:
https://stackoverflow.com/questions/10128430/documentation-or-code-details-on-meteors-ddp-pub-sub-protocol
How do I get a live stream of deltas from Meteor collection, for use outside of a webapp?
FYI, I wrote up a higher level Android DDP layer that takes care of client state including collection handling.
It's on github and includes Maven artifacts in Maven Central (my version of the java-ddp-client also is in Maven Central):
https://github.com/kenyee/android-ddp-client
Not sure why no one mentioned this, but there is a Java DDP client library:
https://github.com/kutrumbo/java-ddp-client
FYI, I've forked this and fleshed it out quite a bit. I started writing an Android app with it and found it missing a lot of stuff to get it to work properly:
https://github.com/kenyee/java-ddp-client
I also wrote up an Android layer over this to make things easier and will check it into Github as soon as I figure out how to get it to work w/ Gradle in Eclipse (can't get it to recognize the android-libraries plugin so none of the references to the Android library work)-:
I did write an Android app using all this stuff...look in the Play store for "Meteor.js Party" which matches Meteor's Parties sample.
Clients can communicate with Meteor through its DDP protocol (specs). Look at the list of independent DDP implementations for common platforms.

Categories

Resources