How to send array to java (android) only with hotspot connection? - java

first off all sorry about the non-smooth english.
I have a problem with get data from user to my database or to string in my android java code.
I created website until now and i'm using my mobile as server.
In order to connect this site i turn the hotspot on and from a pc or other device i wrote the ip address with the port in the browser's address bar. for example, 192.160.42.1:8081.
My problem is that i have contact form in the site and i need the user will fill his details then i will get it in the android code (when he clicks send).
So can the user in the web click "send" and i will have a script that creates a new record in my Sqlite database? It will work for IE,Chrome,FireFox,Safary and android tablets browser? or i can pass string with his details from the contact form? (from the javascript to the java).
Notice that i dont have internet connection except the hotspot.

Bit unsure at what you are asking but if you just want to store the data locally then use an sqlite database from within your application, if you want to send data to an external website then in your code check for a internet connection and send a json string to your website and let a script there handle whatever you want to do with the data. If you dont have an internet connection then you could store the data in a sqlite database and send it when there is an connection.

Related

How to handle Android to MySQL updates when smartphone is offline

I am currently working on a forum-like Android app which interacts with a MySQL database through JSON and PHP scripts. On certain occasions, the app has to send updates to the database, e.g. when a post to the forum is made or updated.
My question considers the situation that the smartphone is offline, i.e. doesn't have a internet connection thus cannot connect to the server, and tries to post something to the forum. However, due to the offline status, it cannot interact with the database immediately. In this situation we want to handle the messages in such a way that the post is sent to the database on the next instnce when the device connects to the internet.
What exactly has to be done on the app side to achieve that?
I guess the post has to be buffered in some directory locally and the app has to check the internet connection constantly. Does anybody know how to do that? Does JAVA provide certain functions for doing this?
Thanks in advance!

Sending push notifications from a webview app

I'm working on a responsive website which I will then integrate in an Android webview to build an app. This website is a kind of social network with a built-in notification system.
What I would like to achieve is to be able to send push notifications from the built-in notification system of my website into the right user's phone. I have already built native Android apps and have included some push notification systems... But it was a native app, so I was able to catch the Android device ID to identify the user. In this case, I have a responsive website (into a webview app) where the user logs in / register with HTML, jQuery, PHP languages, not Java. So I'm not able to get the Android device ID.
I had an idea to do that but I'm not sure if it's the best one, so please correct me if I'm wrong :
The user starts my app on his phone
If it's the first time he launches it, we send a request to my
server with the Android device ID + IP address of the user that I store in the DB (in Java language to my server, before starting the webview)
The webview starts
The user creates an account and I check on my website if an entry exists in the DB which matches the user's IP address. If that's the case, I can create a new entry in my DB with the new created user ID and his device ID. Then, it's easy to send him push notifications.
I think it's maybe a little difficult as a solution, but what do you think about it ? Or do you have some suggestions to help me to achieve this ?
Thanks!

how to get acknowledgement from php to android for received data

i am sending username and password to php pages for authentication. want acknowledgement from php to android if password matched or not. username and passwords are saved in mysql database. php file is connected to mysql database.
If I'm not mistaken, when you are calling the php, you can get your result (validation) and echo it.
If the operation is long, you can use a queue structure, and check for your position in the queue and for it's results when executed.
If username and password are sending by the android app, so just read the result of your get or put request, your php page can send the result easily for you. but if another client is sending the username/password and android app is going to receive login data, there are two way
pulling: add a function in your php server to receive last login
data from database and call it in your android app, periodically.
Event base: add a socket server in your android app and send data from php
function to your android application by socket based on it's logging event, in this way you
receive the login event on time.
I do not recommend the second way, because it have some limitation and it's hard to implement in mobile platform, it needs android service and you must make sure that socket server is always running.

Save user details from javascript into java

This is my situation:
I have a website stored in my mobile, I'm using "kws" to make my mobile as server, ofcourse when i turn on the hotspot in the mobile.
When an user will connect to my hotspot he will type unique ip and port and then enter to my website.
In my website there is place to leave details (email,phone number, name, etc..).
I actually want to take this details and send it to the java android program that is manages the website (i built android app to this mobile that manage the site, she switch the hotspot on/off ,etc..).
In the java code I want to get the details and write them to file or write them to my sqlite database in order to send it to specific email when i will be able to connect to the internet (when i connect to internet i turn off hotspot and the site isn't active anymore.)
The browsers it needs to support are: Internet Explorer, Chrome, Firefox.
How can i do it? don't forgett that the only connection i have is the hotspot in the mobile.
OK, so to solve that i used Websockets. Now i can pass data from javascript to java.
I used this: Writing a WebSocket Server.

Android SQLite and Desktop Sync

I am unable to figure out what is the best way to achieve a scenario like this:
Working on a project that would have android application as client.
User will take their device with the android application installed to field/visit and capture/punch/key data through out the day. This data would be stored locally on the device in SQLite database.
The data captured in SQLite needs to be exported out and imported into the desktop app (it could be java or .net based) for further processing.
Other points:
A. User could connect the phone via usb to desktop.
B. data flow would always be in one direction (i.e. Phone to Desktop).
C. No internet connection on the phone
My dilemma is how to access the sqllite database programmatically in desktop application? Are there any JDBC drivers that could read data from the sqlite database from a device connected via USB to the computer?
This is just a way to do what you want, there are more ways to do it but from my point of view is the most accurate and scalable.
You would have to make a webservices server on Java, PHP, etc ... with a database MySQL, MongoDB, etc ... and so the mobile device is synchronized with the database that was the cloud.
Thus after a desktop client would connect to the webservice to bring the data in order to process it on your desktop client.
EDIT:
You can view this post's
send-data-from-android-to-pc-via-usb
transferring-data-usb
bi-directional-data-transfer-through-usb-between-an-android-device-and-a-pc-mac

Categories

Resources