How to get mobile device information through java? - java

How to get mobile-device information through java or java script ?
I need to know whenever a customer from mobile phone enters into my Website

You have to read the User-Agent header from the request.
See more on : Detecting Device Type in a web application

Related

Identify Http Request Devices

I am trying to make a spring web application and it will be requested from multiple devices (e.g. Android phones and iPhones). I need to identify the device which sends a request in order to recognize it in a later stage. How am I to achieve that in java?
A sample scenario: User signs in using a Samsung A7 and another user signs in using an iPhone 8.
I need to track and store the actions by the device. I think I need the user of a device to log in every time in order to show all actions executed by this related device. I need to recognize the device for every request here and also I will need to show to the user all logged-in devices.
I have tried to achieve this with a mac address but I think it's not effective.
when type on cmd "ipconfig/all" the following list appear but which physical address should choose between all of them ??!!!!
and i try this java code to get mac address but a NullPointerException is occurred
InetAddress address = InetAddress.getByName(HttpRequestHelper.getRemoteAddress());
NetworkInterface ni = NetworkInterface.getByInetAddress(address);
byte[] mac = ni.getHardwareAddress();
Are you using a native app for mobile or yours is only a website?
Any way the only way is recognize user agents headers to know the device and you can use for example the device token push address that is mostly unique id.
If yours is only a website you can store the device with a generated id or random, save to your database and on browser cookies

Send android data to XAMPP server Java file input and then send back to android device

I am creating an authentication system where I get some value( let us say "x") after processing the android application. I want to send the value "x" to the server where I have a java file and it needs to be run on the server end(may be using php by passing the argument as the value "x"). After running, I need the output to be sent back to the android device to display it.
Leads how to implement such short structure will help me complete the system.
You need to create a class that extends AsyncTask, and then use your php source that u would normally use for login. Here's a link that might help you out: Android, PHP authentication
Try using HTML request. I am not sure how is this implemented. Any one can comment regarding it.

Is there a way to communicate to a Java Swing app running on a PC from a cell phone?

I've developed a Java Swing app running on a PC to match skill sets from resumes to client requirements, e.g. : client asked for Java,Html,Sql, it will load all resumes and extract text from them then search for the above keywords and find the persons with the skills.
But my boss asks : "Can I use it form my cell phone ?"
My answer is yes and no.
Yes, you can call someone running this app and search for the match and then email it to you.
No, it's not a mobile app, you can't run it from your phone.
But I'm thinking : is there a way to communicate from a cell phone to the PC running this app without using a web server ?
Like this : on the phone open a browser and enter, as address, the IP of the PC running the app, then give it a parameter, something like a url, for example : http://123.4.56.78:80/My_App?A=Java&B=Html
And in my app running on the PC at [123.4.56.78], it listens for messages on port 80, and send back the results.
Even if it can't send back the results, it can always email the results.
So the critical question is : can it get messages on a certain port sent from a cell phone ?
I found the answer : com.sun.net.httpserver
There are many samples at : http://www.programcreek.com/java-api-examples/index.php?api=com.sun.net.httpserver.HttpServer
Include a mini httpserver in a Swing app, and it will be able to communicate with a cell phone.

Redirect certain websites from an android phone using php

Is it possible when a user is using the internet on an android device and they go to a specific website they will get redirected to another static webpage by a php script. The IDE I am using is android studio.
Unless you make your own browser app it is not possible to access default or chrome or any other browser. Though you can make your php link that can do it so. Like... www.customlink.com which redirects to www.customlink2.com or anything, but it is from php side, not from andoid... :)
yes you can do that in php.
use the header function in php
Eg: header('Location:http://your_url.com');
You don't need any code on the android device. Take a look at this answer here on how to detect a user on a mobile device using php and then simply redirect him to another url.

How can i call my page using sms?

I want to develop a web application in JSP ,in which a user can sent their id using their mobile number and after that they will get their data like total amount,balance etc.
I am not getting how can i do this?
If you can provide any api name and example that will be great for me.
Thanks
You accept user phone no with some form persist it.
You map phone no with user account
Write a service which will send SMS to mobile no, after reading user data on timely basis.
Here you can check how to send sms from JAVA
To interact with a GSM Modem (such as a mobile phone), you can use SMSLib. You will have to write some sort of backend though since SMSLib is a Java library.
AFAIR using the WAP protocol automatically sends the MSISDN (phone number) included into the WAP request. This may be a starting point (get the client to execute a WAP request to your server).

Categories