does anyone had success in posting from android emulator to GAE? - android

does anyone had success in POSTing from android emulator to GAE? I am trying and I am getting Unknown Host Exception.
Do I need to do some settings in emulator? Please help me. I am using HttpClient and HttpPost, and also set uses INTERNET permission.

I did post to GAE in an application I wrote about a year ago at the university, but didn't have any special problems. What do you mean exactly by posting to GAE? Posting to a webapp deployed on a publicly accessible GAE? Or behind authentication? Or locally on your development environment??
If you want to access GAE running locally on your development environment, you need to use this IP: "10.0.2.2" which represents your local machine, basically your webapp would then be at http://10.0.2.2:8080 (see my post here for more details about that)
Otherwise, if you have issues with Google Authentication from your mobile Android app to a GAE hosted application, it is always good to take a look at open source apps which do the same and see how they handle it. Here are two which came just to my mind..
http://code.google.com/p/chrometophone/
http://code.google.com/p/android2cloud/

Related

Rest Api Link build

I have made a rest api with database for an Android app. I have made this in php in my localhost. Now I want to access it from my Android app. How can I access it through URL in internet. I am totally new to this, plz give me in details.
This question, brings back so much memories. You need to tunnel your local host packets to the public internet. There are many tools, but the main one i use is NgRok.
Details
Test mobile apps against a development backend running on your machine. Point ngrok at your local dev server and then configure your app to use the ngrok URL. It won't change, even when you change networks.
Don’t constantly redeploy your in-progress work to get feedback from clients. ngrok creates a secure public URL (https://yourapp.ngrok.io) to a local webserver on your machine. Iterate quickly with immediate feedback without interrupting flow.
A note of interest. if your app currently as a https signed certificate you might need to add some extra classes, if not you good to go. Read up here.
Guide lines for local public hosting.
Create your webserver(php,node.js etc) , start it, and verify on localhost:port
Start ngrok, its simple visit the website, the instructions are there
Ngrok will give you a url, that url is public anyone can access it, while your computer is powered on
On android side, use a http client, such as Volley, Http2 or Retrofit.
You have a few reading up to do

Socket.IO Client fail to connect to Socket.IO nodejs server after latest Openshift update

I have a nodejs v0.10 server with socket.io (v0.9.16) running on Openshift, for the past 2 months it has no problem receiving data from my Android apps connecting to the server using AndroidAsync (https://github.com/koush/AndroidAsync). Suddenly after Openshift upgrade its service on 25th Feb the Android app fail to connect to the server. Every time the app tries to connect the server, the server will output an error, I run Socket.IO in debug mode and this appear (debug: destroying non-socket.io upgrade).
Funny thing is, the same server also host my web client running the same socket.io library, and it has no problem whatsoever with the web client. Can someone please point me to the right direction? I am connecting to the server with http://www.xxxxxx.com:8000/ where 8000 is the websocket port given by Openshift.
I read that "destroying non-socket.io upgrade" might due to invalid/incompatible socket.io js file, I tried to do a manual check on the socket.io file by typing this in my browser
http://www.xxxxxx.com:8000/socket.io/1/
I got this return code:
An-vI1BJofr45j9c_GmH:60:60:websocket,htmlfile,xhr-polling,jsonp-polling
PS: My Android code hasn't been changed, and so is my server code.
PPS: I have successfully connect in localhost environment and my own server. So the problem is most probably originated from Openshift, not sure what have been updated to break it.
All of a sudden it works again without any code changes. I would however recommended anyone using my approach of connecting to backend server to have a http push backup just incase any future server updates breaks it again.
Would appreciate if anyone from Openshift can help clarify this to prevent sudden death on running production apps. Thanks.
Make sure to check OpenShift Online's system status page to see if your apps have been impacted by a system outage. (fyi: we run on top of AWS)
I would definitely consider using one of OpenShift Online's paid hosting plans for production quality applications. Apps that are created using paid plans go onto a separate array of machines (more resources), and are configured to be more highly-available (no sleeping due to inactivity).
Hope this helps answer your question. Please close if so.

Local testing for Android App using Cloud Endpoints for Google App Engine

I am developing an Android app that uses Google Cloud Endpoints on Google App Engine (in Python) for its backend. The Android app authorizes the user using Google Play Services on the Android device, and it all works fantastically.
However, now that I have actual users, I'd like to be able to test this all locally before deploying any app engine API changes to production, and I haven't figured out how to have the Android app talk to my local development server anywhere. The testing recommendations suggest that I just do some manual tinkering with API Explorer, but as I'm using the Endpoints Proto Datastore for my API, which makes the Android development easy, it also makes the API Explorer basically useless, since the calls I need to make are far more complicated than what I can generate by hand.
One answer to this question suggests that there is a way to point the Android client at the local server, but while I can use the --host argument to have the dev_appserver's default server listen on something other than localhost, I can't seem to find a way to do the same for the API server. And even if I could do that, it might only be the first step to a full end-to-end local testing setup for my Android app.
Can someone post more details on how I might do this, or short of that, please enlighten me on the best practices for testing Android apps that use Google Cloud Endpoints on App Engine? Thanks in advance for any answers.
Alright, finally got it working, thanks for the tips, Dan! Here are the remaining details that would have saved me a few hours - hopefully this is helpful to someone else.
1) As I expected and mentioned earlier, dev_appserver.py needs to be run with --host=0.0.0.0 so that it can listen on the local network.
2) In order to properly parse the ID token to make the user authentication work, you need to have the PyCrypto library installed - it is not installed by default, so just having it in your app.yaml isn't enough. I found the binaries for Windows here.
3) Then, in my generated Tictactoe.java-equivalent class, I had to change the DEFAULT_ROOT_URL to be http://<my-local-machine>:8080/_ah/api/ (which is where my local machine is running), so that requests went to the local network. Alternatively (and perhaps less invasively), you can use builder.setRootUrl to the same address from wherever you initialize your builder. This way you don't muck with your generated classes.
4) I also had to make the change Dan mentioned described here.
After doing those four things, everything seems to be working now and I can test my app locally - hooray!
In the local environment, the dev_appserver is the API server. If you've configured it so that it's accessible from machines other than localhost (i.e. another machine/device on the network) API requests should be accessible as well.
However, there's currently an issue with the local server and gzipped requests. Until that's fixed you'll need to disable gzipping within the client library in your Android app (see this post).

Accessing Internet through Android Application

We, two team mates and I, are trying to access a WCF web service through an Android application. We are using a JSON for the transport of objects. We have tested that the service can be called through HTTP via google chrome, internet explorer and the android browser on the emulator.
We have already set up the internet permission in the android manifest using
<uses-permission android:name = "android.permission.INTERNET"/>
We are using the HttpClient and the HttpResponse objects, to connect to the WCF Server.
Currently we are attempting to access the server both locally on the machine that the emulator is being run on, and one that has been hosted on the local network.
Our problem seems to be that we cannot connect to any server through our app, whether it is our server we are trying to connect to, or any other server.
We have already tested the server connection with a windows phone program using http, which seems to work fine.
Are we missing something obvious? We really do feel like we are banging our heads on a brick wall.
Many thanks for any advice given and if any more information is needed please feel free to reply.
Use 10.0.2.2 as IP for the server running on the same machine as the android Emulator...
Try using Traceview http://developer.android.com/tools/help/traceview.html to find out where the problem is happening. You can use it to create a trace file showing the status of the network connection and where it is failing.

Phonegap / Converting website for mobile use

Currently I am building an app using phonegap for the Android and iOS systems. Essentially, it will be a website but I am running into some difficulties due the cross domain requests I need to make via ajax (same origin policy). Im wondering if its better to make the website on my own servers, where PHP is allowed, and then use a wrapper/frame in phonegap to emulate the site? How would that work?
Help appreciated
You shouldn't be having this problem at all. PhoneGap apps are loaded on the device as local file:// pages, and the cross-domain security policy does not apply to them.
From the PhoneGap FAQ:
Q. I want to create an application for phonegap to access externally deployed web services via AJAX. How can i resolve the issue with the
cross-domain security policy of XmlHttpRequest?
A. The cross-domain security policy does not affect PhoneGap applications. Since the html files are called by webkit with the file:// protocol, the security policy does not apply.
(in Android,you may grant android.permission.INTERNET to your app by edit the AndroidManifest.xml)
If you are having issues with cross-domain requests then consider using something like jsonp as the data interchange format. Where are you requesting the data from?
If I understand correctly, you want to create a PHP proxy for a cross domain service so that you can access it with your mobile app using phonegap? This is a pretty common thing, its done a lot in Flash as well to get past cross domain restrictions.
For one of my demos I need to access Google Images from Flash. To do so I created a VERY simple PHP proxy on my server called imageproxy.php. Here's the complete code:
<?php
readfile($_POST['url']);
?>
Yep, thats its. So in your case, if you were using this PHP proxy on your server, you would send this proxy your target URL as a post variable and the proxy makes the request and returns the response via readfile().

Categories

Resources