GCM Demo on Android Device - java

I'm following the Android GCM Demo tutorial (http://developer.android.com/google/gcm/demo.html) and I'm attempting to get the application to work on my Android phone however whenever I run the application on the phone I receive the message:
Trying (attempt 1/5) to register device on Demo Server
Then after 5 failed attempts, I get the error message:
Could not register device on Demo Server after 5 attempts
I am running the GCM Server before trying to run the application, and the GCM Server is running on my local laptop. The following server values have been set in my "CommonUtilities" file in the "app" folder in the GCM-Demo-Client project.
SERVER_URL = "http://192.168.1.100:8080/gcm-demo";
SENDER_ID = "245619476079";
I am aware that this is an internal IP address, however I ran into other issues trying to run the server on my external IP address, and I have got my Android device connected to the same WI-FI network, so I'm unsure why this isn't working.
Help please :).
P.S. If anyone has any advice how to get the GCM-Demo-Server running on my external IP address that would be great! At the moment the only external IP address I can find for my machine is the IP of the wireless modem/router, which only allows me to access the modem/router options (even if I make the GCM-Demo-Server run on that external IP address).

SERVER_URL = "http://192.168.1.10:8080";
use this url, it will register on page:
http://192.168.1.10:8080/home,
not the page
http://192.168.1.10:8080/gcm-demo ,
and can't send message.

Finally managed to work out the issue. Unsure why but after removing "/gcm-demo" from the end of the URL, my device was able to successfully connect to the GCM Server and receive messages. So the final "SERVER_URL" set within the "CommonUtilities.java" file appears as:
SERVER_URL = "http://192.168.1.100:8080";
Also thanks for the tips Nick, managed to get it working my external IP address with port forwarding, making the final SERVER_URL look like:
SERVER_URL = "http://<external_ip>:8080";
Thanks for your help guys :)

Make Sure curl is enabled in php. It Works For Me.
For example, with Ubuntu/Debian server, you need to run this command:
sudo apt-get install php5-curl
After that, restart the Apache server:
sudo /etc/init.d/apache2 restart
with Windows try enabling from wamp settings.
For more on enabling curl refer this

Related

Android Studio frontend client [running from Device] not connecting to Google AppEngine Backend

I'm running into issues getting my frontend (being built in Android Studio using Java, running through an android device connected via USB) to connect to a locally hosted app-engine backend (running as a local devserver).
Errors are as follows:
Error when attempting to call an API method with:
'apiBld.setRootUrl("http://192.168.0.x:8080/_ah/api/");'
http://pastebin.com/eqHrSLfJ
Error when attempting to call an API method with:
'apiBld.setRootUrl("http://0.0.0.0:8080/_ah/api/");'
http://pastebin.com/s7PMqiyK
-
When its run with '192.168.0.x:8080' the emulated version of the code runs fine, the app connects locally and can call API methods. I've tried suggestions from various other related posts, but nothing has solved my issue. In pom.xml Ive also been sure to enable 0.0.0.0 for the port and we're not yet using authentication.
Any ideas?
It's strange that it connects in the emulator, as the avd network address to tunnel to your computer's loopback is 10.0.2.2.
Make sure the server is running by putting the URL in the browser. You may need to change the port to something else if it is already bound (ie: xbmc web server uses 8080 by default) try 8081. Don't forget the 'httpPort' directive in your build.gradle if using android studio.

TCP connection between Android App and PC

I'm trying to create a TCP connection between my PC and Android smartphone to send text from the PC (Client) to the Android App (Server).
I found a tutorial which helped me with the code for the App which creates the server ( http://pastebin.com/z0xPSAvP ).
Now I'm struggling connecting my client with the server. The client is programmed with "AutoIt"
http://pastebin.com/tCW5bK9V
When I run the client the "could not connect to $socket" msg-box is displayed.
Could someone tell me what I'm doing wrong here?
Both devices are in the same Network (smartphone via WiFi and PC via LAN) and I checked for the smartphones IP in the smartphone settings.
First, try to access something like Google from your Android phone using its mobile browser. Maybe something still wrong with the network.
Then create a version of the server that could deliver simple HTTP response, visible from the Android mobile browser. Doing so with success eliminates firewalls and all client-related issues from the list of possible problems, making sure the server works and is accessible.
If it still does not work after you demonstrate connection between server and mobile browser, I would suggest to write the client in Java first using the this tutorial. You can try AutoIt and other more exotic approaches after you get anything working at all.

hosting my website on a LAN using tomcat server

I am badly stuck in a doubt that i have tried various ways to get it cleared and coul'nt find a solution and therefore i decided to come back to the good old place where i have never missed out on getting what i want!
I have a simple hello world jsp page that will trigger a java servlet when a button on this page is clicked. I am running it in a tomcat server that i have installed on my laptop. i am using the Eclipse IDE. so when i run my jsp page, it asks if i want to make the server up, and i will say yes and the jsp page comes up in the browser inside eclipse IDE. and i can access the same page through my system's browser (chrome) too using http:/// . (90 is the port that i have configured for this tomcat). but if i hit to the same url pattern as i have told you above on a desktop which is in the same network as my laptop is, nothing comes up and then i thought, i will hit using the IP of my laptop where the server (tomcat) is actually running, still no result.
when i googled a bit, i learnt that IIS server should be running on my windows to achieve what i want. but my doubt is: Is there a difference between IIS server and tomcat server?because tomcat is already running, do i need an IIS server?
Update - Solution
i used the private IP of my laptop and then it works!!! i was using teh public IP of my network till now so was unsuccessful!!
IIS is a web server while Tomcat is a web container. You can find more information
here
You dont need IIS to access Tomcat. Tomcat is a standalone web container which can server JSP pages you are trying to access. Simplest thing to do is try to ping your laptop from your desktop. If that doesnt work then your need to check firewall settings as suggested by another user. But if that works, make sure your port and application context name is correct.
Thanks.
As you told that you are using your public IP address to access the page but nothing happing, it's because the public IP you are seeing is not your laptop's IP. it's your router's IP. Your private IP is your laptop's IP which is assigned by your router. if you want to access the page using your public IP you have to forward that particular PORT on your router. By doing that you can easily access the page from anywhere not only from your home network but from other networks as well.
Solution i used the private IP of my laptop and then it works!!! i was using teh public IP of my network till now so was unsuccessful!!

connecting from android mobile app to a database on a laptop

I'm new to android programming so please I need your help
I want to make a mobile application that connects to a databse on my laptop through internet without configuring my router
I'm using phpmyadmin in which i created a database, and I made a file called login.php that can make sure of username and password from database
I enabled the port 80 in firewall
now i wrote in eclipse this url : http:"//192.168.1.3:80/Day%20Manager/Login.php"
the ip address is optained by writing ipconfig in cmd and getting the IPV4 address
well it's not working it's giving me NetworkOnMainThreadException
can you help me please
Have a look at this link. This might help. Ofcourse if you are going to need to access it from your application you would have to provide an intermediary php script to get it working correctly.
you said you are using phpmyadmin database, then place your php file in c:/>xampp/htdocs folder, open your browser and enter localhost/login.php then you will get output, in the same way connect to url from program then you will get the data.
note: make sure internet permission in manifest file.

Can not add google account in Google App Emulator

I am trying to implement my first Android C2DM aplication. I have difficulty in adding a google account. My machine is behind a proxy, but I have added an APN with the proxy,port,username,password details. I can go to the google account page using a browser, I have tried the http and https sites and I am able to access. But when I try to add a google account by going to settings-> Accounts and Sync-> Add Account->google->Already have a google account->signin->give details...It gives me this message..
Error message is "Cant establish a reliable data connection to the server"
When i used wire shark and checked the proxy it connecting to, It is not using the proxy I have given in the APN section. Anybody knows how do I solve this problem? I am using GoogleApp API Level 9 Platform 2.3.1.
I have managed to solve this issue, The emulator was somehow not detecting the proxy settings. Then I fired the emulator from command prompt using the below command and it all worked fine and I have managed to add the google account.
emulator.exe -avd GoogleDevice -http-proxy ###.##.###.##:$$$$ -debug-proxy
Note: # is my proxy and $ is my port, GoogleDevice is the name of the device you would like to run.
the solution I found here! :
http://www.grokkingandroid.com/using-a-google-account-in-the-emulator/

Categories