how to add http connectivity Checker to Android app? - java

I'm using Retrofit2 in my app and the problem is when my app is starting if app was unable to access internet, app will crash and terminate. so i've fixed this issues with connection checker, but it's only check if internet or wifi is connected or not.
How can i make my app to check http is access-able or not? i want in my app to show server is down for minutes, and stop closing app and make them use offline to get network access again. Like whatsapp when you're offline, you can open app.
Edit 01 : App Gain access to internet, then he want to get access to php file on server, but it's not able to access it, so i want my app check if php file is exist http://simple.com/file.php then continue and show contents, and if it's not exist show a toast message that server is not available now.

Related

How to use firebase library without a VPN app in android

I made android app that uses firebase, but as the users live in Syria they should use a VPN to use my app because firebase is blocked in that country.
Is it possible to use a script or a JSON file in my app to workaround this problem?
You should try setting up your own vpn connection inside the app you're developing.
Try using this source to ease out your work.
another solution is that at runtime when your app attempts to connect with internet you can programatically reroute it's root default base connection route to your preferred IP address thus eventually solving your problem without using any external app.
Lastly,You can't try creating a service which will be installed in the backend and when the app is launched the service is automatically triggered with it and hence it will automatically route your connection to preferred vpn IP address.

App (Android) can not connect to the server

I have a problem with my android application. In Android Studio, everything looks normal since no error appears. The application is supposed to connect to the web server for data recovery. But every time I test the app on my android device or on an emulator, I still have the same message: "Appname can not connect to the server"
So, since I do not see any error on Android studio, I do not know where to look. I tried with the coordinates of two different servers, but still the same message. I have concluded that the problem is not at the level of the connection to the server, but in my code, but where?
If anyone has any suggestion, I'm a taker. If you need to see any file, let me know.

How to check if android app user is connected to server

I am making an android application which communicates with my server every time the user logs in. I am trying to make it so that the server will know when a user is logged in or not (basically keeping track of their activity). However, if the device goes offline suddenly and doesn't have time to "logout" from the server, my server will never know that it is offline until the app requests the logout method. I am using baasbox for my backend. Can someone help me fix this? Thanks in advance :)

Android Widget like WhatsApp to check connectivity and send data

I have a running Android app, which sends data to a server. If the device is not connected to the internet, it should be possible to save the data temporarily on the device. If the device retrieves the connection, it should send the saved data to the server. Even if the app is closed.
My question is, how to create a "listener" which listens on the internet connection? This mechanic should work like WhatsApp. In WhatsApp you can receive messages, even when the app is closed.
I've looked a bit around....could this be a Widget? And if it is one, how to not display it on the Home screen? I don't need to display any information there.
You can register for changes to connectivity by following the instructions at Monitor for Changes in Connectivity. When you hear that the phone has connectivity, send your data.
Sorry, I don't know enough about widgets to advise whether they'd be a good fit here.

Offline storage management for android

Theme : Newspaper updates in android application.
How to fetch or retrieve data from server and post updates on android application . How to manage offline storage means whenever there is no internet connection how the data gone be updated on android application , atleast how it consider showing updates on android application . If any one known this issue please answer about it .
I am actually using php or json as intermediate files for fetching data from server and send updates to android application but its seems to be more complex and if i wont get the permission to access the server side files , how do i manage for updates ? whether is it necessary to have permission to access the server files ?
More about the topics : if i want to syncronise the update with website , how do i handle it or implement it ? i am not asking any sort of coding here .
How to fetch or retrieve data from server and post updates on android application
use HTTPClient.
How to manage offline storage means whenever there is no internet connection how the data gone be updated on android application
I think you don't understand what offline storage means. If there is no internet connection, that's it. You are not able to update your content. Offline storage is useful if you have internet connection, but not everytime. The content you downloaded when you had internet connection can be saved to SQLLite to be loaded when you don't have internet connection.
I am actually using php or json as intermediate files for fetching data from server and send updates to android application but its seems to be more complex and if i wont get the permission to access the server side files , how do i manage for updates ? whether is it necessary to have permission to access the server files ?
Create WebService as an interface. Do not let other system to be able to directly access your files. Or just create a PHP files that basically return Json or XML Data.
Other option : create an RSS.
More about the topics : if i want to syncronise the update with website , how do i handle it or implement it ? i am not asking any sort of coding here .
Create an event to start sync using HTTPClient. If there is new update, save it to SQLLite(for offline storage) and display the content. The event can be triggered during the start of your application or clicking refresh button and if Internet exist.
Update :
There is a new framework called couchbase mobile. You can sync the local mobile db from a couch server. You can insert/update the data locally(offline mode) and then the data can be synced also to the couch server, whenever you have internet connection. This means the need to create HTTPClient is no longer necessary.
For the database, try cloudant.

Categories