How to bind with an external Web Server in Android - android

I don't know whether the title is appropriate or not. But here is my problem that I am trying to solve.
There is a Web Server (e.g. Apache) installed in my Android device.
There is another Android application developed by me that will send an image (taken from device camera) when it gets HTTP request.
For example, HTTP request can be as below:
http://192.168.16.56:8080/camera/snapshot?width=450&height=320
When HTTP request comes, Android will take the image from camera, resize it and provide it to the client.
I can solve this issue by creating a ServerSocket in Android. But I want to use the external Web-Server (e.g. Apache).
I heavily searched in internet but didn't find any clue using external Web-Server.
How I can solve this problem?

Related

How to make android app accessible to web browser

I want to create a pair of Android app (Server - Client) using Socket to communicate with each other in real time. I found the sample here http://androidsrc.net/android-client-server-using-sockets-server-implementation/ which works. The client can connect to the server. Now I think about making the server a... "web server" (I don't know if I'm calling it the right way) that can display what they (server and client) are communicating (maybe showing their chat or calculation...).
But when I type in the address and port (eg: http://172.16.1.21:8080/) into the browser (Chrome), the result is
172.16.1.21 sent an invalid response. ERR_INVALID_HTTP_RESPONSE
I guess it was responding but with some other kind of format that the browser doesn't understand. I tried calling with postman and got the error:
Could not get any response There was an error connecting to
172.16.1.21:8080.
I tried putting an index.html to the root of the storage (/storage/emulated/0/) but no luck
The idea would be the same as the app "Websharing" on store. All you need is that the phone and the Computer is on the same network. When access the app, the browser will show the content of the phone.
My idea is to show other information. I though about creating another "display-app" to show the result, but then what if I wan't to send some custom message to all client, then I will need an another phone, which is so difficult to have. Opening another tab is much easier. I don't want to risk using online service like Firebase because the internet connection may not be stable. Just local connection is fine for me.
I don't know that is it called, a keyword would be appreciated. I tried googling and found some suggestion that to run an app called "Tiny web server", I haven't tried it but I don't wan't to use a third-party app because the installation will be complicated and not support full customization.
Thank you for your time.

How can I connect Android to ASP.NET MVC

How can I connect android to mvc ? For example I want to open my camera via google chrome, how can I control it ? People telling me to use json is that true ?
Your question is a mess.
It sounds like: I want to send a rocket to the mars people telling me that I need oxygen is that true?
Below I'll try to clarify what you need and what you want:
You need your own android application that can open camera by
server application request.
You need your own server side ASP.NET application.
When somebody opens a web page on your ASP.NET your server app should some how to establish a connection with an instance of your android application and tell it to start capturing of media-stream from the camera.
You want to send media stream from your android camera to a desktop browser
Answer:
You can use JSON as well as any other data-interchange format at point 3.
But keep in mind that your data should be transferred by some data transfer protocol - most probably HTTP.
At point 4 to work with media in a browser have a look to the WebRTC.
Kind of. Looks to me that you should explore the world of APIs in general as you are not too familiar with them. By the way a REST API is a good way to go, but you'll need a platform, a "server" to do it.
Then you will be able to control your device from a remote one.

Phonegap : Loading content of apps dynamically

I am working on Phonegap android app which should take the content from my remote server.
After searching the things I found the 2 ways of getting the contents from remote server to phonegap App :
1. Getting the content using Ajax call to remote server by returning
the json data from remote server PHP file.
2. Getting complete HTML page from remote server using Ajax.
If i am going to implement one of the above, my app is going to send the request each and every time while loading the page which i think not a good idea.
I know very well how to implement above mentioned option in my App.
but i wanted to know which one is efficient.
How i can accomplished this?
I am also using the Jquery mobile.

Accessing a file on an android device using asp.net webpage in chrome

I have an asp web page which needs to grab an xls file from the device storage area on my android tablet, convert it into bytes and store it in my SQL database.
I can do the converting and storing bit but I have no idea as to how to get the file using VB.
Can anyone tell me how I can get the file without the user having to search for it using an upload control?
I would also like to delete the file after processing..
Thank you..
Derek.
In order to think about this we need to have clear in our minds where the division between client and server exists: You've got a webserver running ASP and a client running a webbrowser on the android platform.
The file you are trying to upload exists on the client. As such any code which does the uploading will have to run on the client and, as the client is running on android, it's unlikely it'll be VB doing the uploading. You're likely to need to use a scripting language like Javascript and, if you care about cross-browser support, be careful how you do it.
The server cannot get the file directly from the client due to common security restrictions.
Once the client side script has got the file, it'd usually send the data to the server using a webservice or other endpoint, deletion of the file can then happen after that.

Android How To Simulate HTTP Communication for Offline Demo

I have an Android App which uses http communication for nearly every operation. I want to be able to demo without connection to the internet by somehow replaying the http exchange. How can this be done? So I want to somehow almost like mock objects but really mock http session so I can always demo the app on or offline. This is really a very cool thing to be able to do. Since you can demo the app easily and reliably. Does anyone know how I could do this. Replicating the whole server side is just not an options its got too much stuff. Its important not to just show screencast but the real data exchange. I just want to be able to run thru the app and replay. Maybe debug as well. Thanks
Here's a hybrid solution using similar ideas from other answers:
You could write a dead simple HTTP server that listens on "localhost:80" (or whatever the port is on the server you're targeting) and point your application to this host instead by factoring out the host name from requests. Your local server has a reference to the actual remote server and does the following:
If ONLINE, forwards the request as-is to the real server, gets the response, saves it locally either in an in-memory cache keyed by the request URL or a file named with the URL as its identifier (munged appropriately)
If OFFLINE, looks up a request in its (in-memory or file system) cache and returns the contents from the cache instead
This is kind of like the record/playback mode that #nicholas.hauschild says.
Now you can just run your app once when ONLINE, causing your localhost server to save away requests that it issues against the real server. Then when you run your app OFFLINE, it just returns these cached contents instead whenever the same URLs are issued.
Hope this helps.
If you're device is rooted, you can use tcpdump as explained in this post: http://www.vbsteven.be/blog/android-debugging-inspectin-network-traffic-with-tcpdump/
or use AndroShark (get if from xda-developers here: http://forum.xda-developers.com/showthread.php?t=725692)
or this one (wifi only): http://www.9bitlabs.com/default.aspx
I would create a "Record Mode", and a "Playback Mode" for my app.
While in Record Mode, I would write out a file each time an http request was made. The file would be named by the endpoint the request is made. The contents of the file would a collection of serialized http requests/responses broken up by line. You could then deserialize lines from this file until you find the proper request, and play back the deserialized response.
This approach would also allow you to create Record/Playback profiles, where you could record multiple different sessions (by placing the files into a different directory) and then playback from whichever profile you choose.
This whole approach could be done with a small wrapper class around the HttpClient object you are using.
One way would be to use an HTTP proxy. Redirect all web traffic to the proxy, which can be running locally on the phone. This could be done with little or no source code change.
find a way using fiddler on pc,and android app take fiddler as proxy.So the http traffic is record.
http://blog.csdn.net/grhunter/article/details/5830199
Simples solution lies in faking it when there is no connection. If there is a error in connection, make sure ur app throws some preset data rather than an error in connection thing.

Categories

Resources