You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Wordit <wo...@gmail.com> on 2011/09/12 17:55:30 UTC

Android with Remote Couch

Does anyone know whether a hosted (remote couch) is accessible from an
Android app, via an XHR call? I mean from a native Android app, not
via the web browser, which should work anyway.

I have a web app I would like to port to Android (using PhoneGap).
Installing a local couch means that users cannot share game hi-scores,
so hosted would be better. Phones/Tablets are online
anyway.

Is anybody here developing Android apps which talk to CouchDB?

Thanks,

Marcus

Re: Android with Remote Couch

Posted by Ajai Khattri <sy...@gmail.com>.
Yes, its not a problem to consume a web service from a native Android app.
 On Sep 12, 2011 11:56 AM, "Wordit" <wo...@gmail.com> wrote:
> Does anyone know whether a hosted (remote couch) is accessible from an
> Android app, via an XHR call? I mean from a native Android app, not
> via the web browser, which should work anyway.
>
> I have a web app I would like to port to Android (using PhoneGap).
> Installing a local couch means that users cannot share game hi-scores,
> so hosted would be better. Phones/Tablets are online
> anyway.
>
> Is anybody here developing Android apps which talk to CouchDB?
>
> Thanks,
>
> Marcus

Re: Android with Remote Couch

Posted by Ryan Ramage <ry...@gmail.com>.
Marcus,

Not sure I saw this in the dialog, but you can try:

allow_jsonp = true
On your iriscouch configuration. Log in to futon as admin and change.

http://stackoverflow.com/questions/3386679/connection-ajax-couchdb-and-javascript



On Thu, Sep 15, 2011 at 3:16 PM, Wordit <wo...@gmail.com> wrote:
> On Thu, Sep 15, 2011 at 4:03 PM, Keith Gable <zi...@ignition-project.com> wrote:
>> Putting couch.js on the server wouldn't bypass the cross-domain problem.
>
> Yes, in fact the script is not seen and Android complains about it. So
> the scripts have to be in the same place as the HTML file.
>
>> I would suggest ignoring anything mobile and seeing how a web page would
>> bypass the cross-domain problem to get to CouchDB, since that's the problem
>> you're having
>
> I'm not sure it's only a cross-domain issue. I use HTML5's Postmessage
> to work with cross-domain policies. That worked great when the scripts
> are in the couch and need to talk to another domain (for extra PHP
> stuff). It's a bit mind-boggling for a while, but it works, the
> Postmessage jquery plugin even supports old IE versions.
>
> I'll ask on the PhoneGap list, but I wasn't sure how much this is a
> couch db issue.
>
> Has anyone tried talking to a couch from a web app stored locally on
> your PC? I mean either just loading the static HTML file in the
> browser (now web server), or running a web server as localhost?
>
> Thanks,
>
> Marcus
>



-- 
Twitter: @eckoit
http://eckoit.com - Keep what you hear.
http://opendoorstories.com  - Create Experiences

Re: Android with Remote Couch

Posted by Wordit <wo...@gmail.com>.
On Thu, Sep 15, 2011 at 4:03 PM, Keith Gable <zi...@ignition-project.com> wrote:
> Putting couch.js on the server wouldn't bypass the cross-domain problem.

Yes, in fact the script is not seen and Android complains about it. So
the scripts have to be in the same place as the HTML file.

> I would suggest ignoring anything mobile and seeing how a web page would
> bypass the cross-domain problem to get to CouchDB, since that's the problem
> you're having

I'm not sure it's only a cross-domain issue. I use HTML5's Postmessage
to work with cross-domain policies. That worked great when the scripts
are in the couch and need to talk to another domain (for extra PHP
stuff). It's a bit mind-boggling for a while, but it works, the
Postmessage jquery plugin even supports old IE versions.

I'll ask on the PhoneGap list, but I wasn't sure how much this is a
couch db issue.

Has anyone tried talking to a couch from a web app stored locally on
your PC? I mean either just loading the static HTML file in the
browser (now web server), or running a web server as localhost?

Thanks,

Marcus

Re: Android with Remote Couch

Posted by Keith Gable <zi...@ignition-project.com>.
Putting couch.js on the server wouldn't bypass the cross-domain problem.

I would suggest ignoring anything mobile and seeing how a web page would
bypass the cross-domain problem to get to CouchDB, since that's the problem
you're having (just that it's a mobile web page). IIRC, there was a
discussion on this list about it, and someone wrote a Node.js proxy for it,
but I only vaguely remember it.

Also, sometimes PhoneGap will bypass the cross-domain restriction. For
example, on iOS 4, you can get remote JSON all day long, but on iOS 3, you
have to use JSONP.

---
Keith Gable
A+ Certified Professional
Network+ Certified Professional
Web Developer



On Thu, Sep 15, 2011 at 7:40 AM, Wordit <wo...@gmail.com> wrote:

> On Thu, Sep 15, 2011 at 2:27 PM, Ajai Khattri <sy...@gmail.com> wrote:
> >
> > Sorry are you writing a web app that runs locally?
>
> It's an Android app which needs to query a hosted/remote couch via
> Javascript.
>
> I'm using PhoneGap, so the code is Javascript, HTML, CSS, but runs as
> an Android app.
>
> Thanks,
>
> Marcus
>

Re: Android with Remote Couch

Posted by Ajai Khattri <sy...@gmail.com>.
You might be better off asking on the PhoneGap list?


On Thu, Sep 15, 2011 at 8:40 AM, Wordit <wo...@gmail.com> wrote:

> On Thu, Sep 15, 2011 at 2:27 PM, Ajai Khattri <sy...@gmail.com> wrote:
> >
> > Sorry are you writing a web app that runs locally?
>
> It's an Android app which needs to query a hosted/remote couch via
> Javascript.
>
> I'm using PhoneGap, so the code is Javascript, HTML, CSS, but runs as
> an Android app.
>
> Thanks,
>
> Marcus
>



-- 
Aj.

Re: Android with Remote Couch

Posted by Wordit <wo...@gmail.com>.
On Thu, Sep 15, 2011 at 2:27 PM, Ajai Khattri <sy...@gmail.com> wrote:
>
> Sorry are you writing a web app that runs locally?

It's an Android app which needs to query a hosted/remote couch via Javascript.

I'm using PhoneGap, so the code is Javascript, HTML, CSS, but runs as
an Android app.

Thanks,

Marcus

Re: Android with Remote Couch

Posted by Ajai Khattri <sy...@gmail.com>.
Sorry are you writing a web app that runs locally?
 On Sep 14, 2011 9:16 PM, "Wordit" <wo...@gmail.com> wrote:
> I need a bit of help accessing my hosted couch from Android please.
> Where should couch.js be? Locally inside the Android app, or on the
> remotely hosted server where the db is?
>
> My first XHR query to the couch is to get the session data with
> couch.js. I'm getting an Ajax error from jQuery while querying the
> couch:
>
> TypeError: Result of expression 'resp' [null] is not an object at
> jquery.couch.js:81
>
> I think the javascript files have to be local to the app, but that
> means couch.js cannot talk to the remote couch due to cross-domain
> restrictions. A local javascript file cannot talk to a remote script.
>
> How are you guys talking to your hosted couch from Android? Are you
> using couch.js or another method?
>
> Many Thanks,
>
> Marcus

Re: Android with Remote Couch

Posted by Wordit <wo...@gmail.com>.
I need a bit of help accessing my hosted couch from Android please.
Where should couch.js be? Locally inside the Android app, or on the
remotely hosted server where the db is?

My first XHR query to the couch is to get the session data with
couch.js. I'm getting an Ajax error from jQuery while querying the
couch:

TypeError: Result of expression 'resp' [null] is not an object at
jquery.couch.js:81

I think the javascript files have to be local to the app, but that
means couch.js cannot talk to the remote couch due to cross-domain
restrictions. A local javascript file cannot talk to a remote script.

How are you guys talking to your hosted couch from Android? Are you
using couch.js or another method?

Many Thanks,

Marcus

Re: Android with Remote Couch

Posted by Ajai Khattri <sy...@gmail.com>.
That should be all you need unless your app needs to read local data (e.g.
contacts) or location or sensor info, etc.


On Tue, Sep 13, 2011 at 4:38 AM, Wordit <wo...@gmail.com> wrote:

> Thanks, Scott and Ajai, are there any permissions or user interactions
> necessary apart from the basic Internet permission below?
>
> uses-permission android:name="android.permission.INTERNET"
>
>
> Marcus
>



-- 
Aj.

Re: Android with Remote Couch

Posted by Wordit <wo...@gmail.com>.
Thanks, Scott and Ajai, are there any permissions or user interactions
necessary apart from the basic Internet permission below?

uses-permission android:name="android.permission.INTERNET"


Marcus

Re: Android with Remote Couch

Posted by Scott Feinberg <fe...@gmail.com>.
I regularly make HTTP calls from my android applications to Cloudant (hosted
couch).

The beauty of REST.

--Scott

On Mon, Sep 12, 2011 at 11:55 AM, Wordit <wo...@gmail.com> wrote:

> Does anyone know whether a hosted (remote couch) is accessible from an
> Android app, via an XHR call? I mean from a native Android app, not
> via the web browser, which should work anyway.
>
> I have a web app I would like to port to Android (using PhoneGap).
> Installing a local couch means that users cannot share game hi-scores,
> so hosted would be better. Phones/Tablets are online
> anyway.
>
> Is anybody here developing Android apps which talk to CouchDB?
>
> Thanks,
>
> Marcus
>