How to check if android app user is connected to server - java

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 :)

Related

Receiving message from server instantly while android screen is locked/is in a sleep

I want to write a 'service' app that will be connected to a server, the server will send messages to the app and the phone will popup a notification to the screen instantly upon receiving the message from the server even if the phone is locked. (like Whatsapp/Telegram etc..)
Push Notifications are not instant enough.
I was thinking about using WebSocket for that, but not sure it is the best approach.
What is the best approach?
Sample code will be appriciated!
Thanks.

how to add http connectivity Checker to Android app?

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.

Save chat messages with closed app

Good evening!
I'm developing a chat application that looks like WhatsApp. I need the received messages to be saved on the user's mobile device. Until then everything was ok, because I was saving the messages when the user received the push notification on the mobile, but the problem happens when the application is closed because when the application is closed the push notification does not trigger the received push event (I am using the Onesignal to send the push).
I'd like to know how I can do this, ie get a notification and process it even with my closed application. I think it has to do this because Whatsapp does this and also Spotify also does it when I connect the Spotify to another device it automatically forces the opening of the application on my cell phone.
So my question is, how do I handle an event with the application closed or even force it to open according to a particular event?
I'm using the technology of Ionic 1 and Angular.js. For push notification I am using the OneSignal provider.
Thanks in advance for your attention and hope someone can help me. Thank you!
I'm fairly sure you won't be able to do what you're describing. There is a 'background push' feature introduced in iOS 9 that lets an app receive a payload triggered via push even when it is closed, but that's more for downloading (for example) a new edition of an online magazine, rather than lots of messages.
The difference betwen those two use cases is that if you're subscribed to a magazine, you might want the latest issue to download automatically whilst you have an internet connection, so that you have the issue to read when you're flying/on the train or whatever. A chat app... is pretty useless if you're not connected to the internet anyway, so there's no urgent need to have new messages 'pre-downloaded'
Even if you could do it, I don't think it would be best practice as there's too many scenarios where people won't have internet anyway so you're going to be left without the full message history when a user opens the app (not to mention push notification delivery is not tracked or guaranteed), so you're going to have to do some sort of query when the app launches to download new messages anyway.
If you've got code already that checks and downloads new messages while the app is open, that's great. But if its closed, you'll just need to run some sort of query on launch to download unread messages or something like that

Sync Google Account programmatically without going through the setup screen

I have a scenario where I have a server that holds username/password. So upon launching my android app and the user it authenticated I would like to automatically sync his account (Gmail for example) without going through the traditional setup screen.Are there any public googe/gmail APIs that I could use for this purpose. Any help at this point would be greatly appreciated.

Android app question: services?

I am currently programming an app that is supposed to get the users' calls and SMSs log and send them to a remote mysql DB.
I have a preferences screen and a checkbox for calls and another for sms logging and I want that when the user clicks in the checkboxes and then saves the preferences clicking a button, the logging starts to work (depending on whether the checkboxes were clicked or not).
My question is, should I implement each of the logging feature in services?
Remote or locals?
I'd like the logging working ALWAYS until the users unticks the checboxes and saves preferences.
Should I send the data to the DB every x hours, or just storing everything in a SQLite DB in Android and then sending everything by the end of the day?
This is my first android app and as you can see I have no idea :)
Thanks everybody for your help!
Cheers
I am finally using a remote service, as I want the service to be running even though the application might not be running, and will just send the data every 24h, so much better.
Thanks for your help!

Categories