1

Currently I'm following a tutorial on a website I found to make an Android project. The thing is I'm stuck at setting the API URL.

It's unclear to me how to get the URL of the API even thought the author provided link to download the API.

By the way I am doing my project on local host.

Link of the website:

http://www.duchess-france.org/accelerometer-time-series-and-prediction-with-android-cassandra-and-spark/

Link of the API source code:

https://github.com/MiraLak/accelerometer-rest-to-cassandra

Kairong
  • 13
  • 3

1 Answers1

0

It's described in the following link how to setup the project:

First you have to start the cassandra

https://github.com/MiraLak/accelerometer-rest-to-cassandra#start-cassandra

Then you start the application

https://github.com/MiraLak/accelerometer-rest-to-cassandra#start-the-application

Then try if this all works:

https://github.com/MiraLak/accelerometer-rest-to-cassandra#use-the-api

If you are having trouble making the requests, try some app like https://www.getpostman.com/ It makes it very easy to send the requests to your application that you just started if you followed the above links.

After you tried out sending in the requests and that you verified that it all works on localhost you have to find your local ip address.

I guess your phone will be on the same net (or even wireless) so you have to find out your local ip of your computer ... I guess this link will do: https://www.google.com/?q=how+to+find+my+local+ip

Once you find your local ip you have to update the URLs

In your REST API requests, change the localhost part with the ip address that you've found i.e. :

/POST http://localhost:8080/activity/acceleration

will become (If your local computer address is 192.168.1.1)

/POST http://192.168.1.1:8080/activity/acceleration

I think this should do it, comment if you are stuck somewhere.

Also note that port 8080 might not be allowed on your local network or even at pc's firewall. So this might not work right away. You would have to google a bit on how to open a certain port on your pc.

The best would be to open a browser on your phone and just type in the url:

http://localhost:8080/activity/acceleration

(don't forget to exchange localhost with your local ip address)

Should this work you are all set.

If by any chance you are using the emulator then this answer might help: Accessing localhost:port from Android emulator

Community
  • 1
  • 1
Marko Švaljek
  • 2,071
  • 1
  • 14
  • 26
  • I have successfully install the Cassandra database and clone the android application (https://github.com/MiraLak/AccelerometerAndroidApp) But i stuck at start the application (https://github.com/MiraLak/accelerometer-rest-to-cassandra#start-the-application) and testing the api(https://github.com/MiraLak/accelerometer-rest-to-cassandra#use-the-api). I am also kind blur on how to get the url such as http://localhost:8080/activity/acceleration (is it i just create a folder name activity and put all the thing inside it just as the www folder of wamp server?) – Kairong Apr 17 '17 at 15:05
  • do you have some error message `gradle build && java -jar build/libs/accelerometer-rest-to-cassandra-1.0.jar` should work fine. Do you have gradle installed? https://docs.gradle.org/current/userguide/installation.html – Marko Švaljek Apr 17 '17 at 15:15
  • Honestly i dont know what it mean in Start the application gradle build && java -jar build/libs/accelerometer-rest-to-cassandra-1.0.jar – Kairong Apr 18 '17 at 08:51
  • just go to the command line, to the project folder that you downloaded and type this command in. `gradle build && java -jar build/libs/accelerometer-rest-to-cassandra-1.0.jar` – Marko Švaljek Apr 18 '17 at 08:51
  • Do u mean this C:\Users\Kairong\Downloads\Compressed\accelerometer-rest-to-cassandra-master – Kairong Apr 18 '17 at 08:59
  • i use cd and link to the API folder and key in the command :gradle build && java -jar build/libs/accelerometer-rest-to-cassandra-1.0.jar but it show me an error – Kairong Apr 18 '17 at 09:06
  • gradle is not recognize as internal or external command,operable program or batch file – Kairong Apr 18 '17 at 09:10
  • I already mentioned in my answer you should install gradle. Use google and install it. Just read mu answer very carefully please. – Marko Švaljek Apr 18 '17 at 09:11
  • Okay and sorry about that cause i thought that gradle is android studio's gradle – Kairong Apr 18 '17 at 09:16
  • I direct command prompt to the API folder and run the command Configuration and execution is being process – Kairong Apr 18 '17 at 09:35
  • Does it mean it works for you now? – Marko Švaljek Apr 18 '17 at 09:35
  • I think yes cause Spring configuration is running and just done – Kairong Apr 18 '17 at 09:38