Background synchronisation in android - java

I'm new to Android development and currently trying to build an app where users can write messages to each other. However, I can't find anything on how to implement background synchronization so that notifications are displayed even when the app is closed. I have already read about services as they sounded promising but apparently they are not meant for this kind of tasks.
Online I only found examples with Google's Firebase, but I want to use my own servers.
I thought about it like this:
The client app connects to the server every n seconds and updates its message database. If a message is added that is marked as unread, a notification is triggered.
I don't know if I'm just googling the wrong things or have another thinking error but I can't find anything about it except some firebase examples.

Related

How can Android apps access messenger chats?

I want to write an Android App that analyses chats. For each messenger, for each contact, I want to get a list of all messages sent and received (since installing my app). The key thing here, is that I want the list of messages to be in order. My app should support as many messengers as possible. What would be the best way to do this?
I researched and found a few ways to access messengers' messages:
Using accessibility services
(Related: How to read window content (using accessibilityService) and evoking UI using draw over other app permission in Android?)
to read the screen content of other apps that is annotated with accessibility labels
caveats:
the messenger needs to have accessibility implemented correctly
I have to filter which text blobs are relevant
Using NotificationListenerService
to get the content of notifications for received messages
caveats:
only gets content of messages for which there was a notification
except for their time, there is no order of the messages given
taking screenshots and doing optical character recognition
caveats:
probably insane
When I get the messages, I still have to order them. For this, I think, the accessibility services are my best bet as I could use the date information on screen in most messages, and also their position on the screen.
However, there is still an edge case. As I understand it, accessibility services can only see the content currently on the screen. The user might also use another device to chat while the device with the app installed is powered off. Thus, once the device with the app installed is powered on again, the app might not be able to see the old messages written while the device was powered off (until the user scrolls up again).
Are my assumptions correct? Do you know of a better way for my app to read/sort the messages?

How to let your app take data from apps that are already installed by Android

I want to make an app that takes info/data from other apps that are already installed on my phone ( Android ). By example: Let's say I want to make an app that shows how many messages I sent to each person with my phone. Then I would like to get my app linked with the message app on my phone and count how many times I sent someone a message , get that data, and put it on my app.
When I search for this problem, one 'solution' I found was working with intents, but it's NOT that, by far as I know, you can use intents to share data between apps you created yourself. I want to be able to get data from apps that I did not make. HOW? Thanks already
You can't, otherwise it would be a security issue, think about a bank app... In Android all the apps are fisically separated into different directories.
You can access data only from apps that expose methods, like Intent.

Recording Touchscreen Interactions in Android outside Application

Is it possible to create a service that collect touch screen interaction data? I have seen that this could be possible in earlier versions of Android but seems to be much more difficult to achieve now. I have found many questions on Stack Overflow that already attempt this solution but don't offer a solution. The problem is also outlined here.
I wish to record the x and y coordinates of each tap and swipe interaction for medical analytics of different user groups. This includes recording scrolling data in (for example) the web browser. So far I can't get it to do this outside of the default application. How can I build a service for this?
I have tried adapting the code here, but nothing seems to work outside the application when other applications are running.

How to create an app to consume real time notifications

I want to create an app to consume real time data from an API. This API give me information about different temperatures. When a certain temperature is exceeded my app need to notify the event to the user.
This app need to run in Android and a web browser. So, my problem is the architecture... My app need to be a websocket or a REST API?
Any help is appreciated!!
You need a notification service, and google has something like that for us...
how does this works??
Take a look at the image below,
you need to register your android app in the google service, and your web interface will need an id, so everytime you want to push something to the android, your web interface instead will push it to the google server with the Id of the app, then google (no matter how) will localize your app, and even if its not running, they will get the notification,
behind the scenes there is a couple of thing that you must do, bu nothing like launching rockets from the NASA.
I will suggest to take a look to some tutorials
in order to start with the registration of your app, get the api key etc etc..
In addition to what #Xoce showed, Amazon has the SNS service which will push notifications to you. Or, if you application is a web based application inside of a native (i.e. Cordova), I've used PubNub for JavaScript based events.
A word of caution though - you'll need to define "real time" for your application. There will be a slight latency between the event and what your application sees no matter what stack you choose. When I think real time I think in terms of microseconds of delay. You may have seconds of delay. If this is a "hey, your house temperature is above a threshold" type of application then that is fine. If this is "hey, your nuclear reactor temperature is above a threshold" then this may not be the way to go.

Android - library/app communication

I've worked with Android in the past, but haven't done anything super-advanced or what I'm about to describe so need some guidelines as to what the best approach/method is to do this before I proceed.
I'm not entirely sure how to google this, so it's best to explain.
I want to build an Android library project preferably with the source undisclosed. I read this can be done as follows: Create another jar that the Android library project references. However, not sure if all of the source code can be private. If anyone can point me somewhere, that would be great.
Asides from that, the library needs to expose an API for any Android app to use, and some sort of event mechanism to broadcast an event when certain events happen (e.g when the app is in foreground etc).
A scenario would be:
1) User loads the app which has the library embedded
2) The embedded library detects that the app has loaded and 'sends an event' to the app
3) The app captures the event and does some stuff specific to the app + an API call to the library
I guess what I'm interested mostly is figuring out what the best ways are to capture the callbacks by the app, once the library has sent some event to the app and to reduce the burden on the developer having to spend too much time implementing what needs to be done when certain events are captured.
Hope this makes sense.

Categories