I am trying to develop this scenario in Android studio and was wondering if its possible.
User A presses a button in the app and broadcasts their location to a server. If User B/C/D is nearby, they receive a notification that User A is broadcasting until User A decides to stop. (Maybe an alarm?).
Can I implement this with GCM? I have worked with it before.
How can I constantly broadcast my location (like in uber) to the server when the app is open? Do I do a separate java class that has a thread or runnable?
Hope these questions can be answered.
Related
I am developing an app that allows users to receive notifications from two places: 1) from a calendar event notification and 2) from an alarm/reminder notification. The notifications work when I have the app open but I want them to work when the user has the app closed or not currently running. Is there a way to do this? Please let me know if I need to send any code!
I am using Google Voice in my android app, and I am connected the app to Bluetooth module, each time I call the Google Voice, the app try to connect to Bluetooth again, each time Google voice window Popped up, the connection lost, and once the window disappear, and the connection comes back again. So, Is there any way to keep them connected even I call the Google Voice window? Any ideas or help I will be appreciated.
You need to create background service for your problem. If you need persistent connection with your Bluetooth you can use intent service. If you are using android studio then it is very easy to create service. Just make sure you must have all necessary information about services and how to make then persistent in background.
Because of this your application will drain your device battery drastically. Make sure service is closed when application exit or all activities are finished.
See this link for more information
https://developer.android.com/training/run-background-service/create-service.html
Place the Bluetooth related processing in a Service. Make the service foreground service.
Activity can connect/disconnect from service anytime.
In my android application i am using android push notification everything works fine until the user forces the application close(It happens always nowadays especially with the task monitoring application available in the play store).No more notifications are visible or possible.After some googling i found that From android 3.1, if the user force closes an app, it will stop to be notified of any broadcast until the user does not start your the again.
Is there any solution to prevent the broadcast receiver killing or any other possible (like making a Que of messages that aren't received by the device and send them later)?
if the user force closes an app, it will stop to be notified of any broadcast until the user does not start your the again.
sorry, that's not true. for sure.
I think you are confusing with something else: from android 3.x - broadcast receivers would never react to a broadcast until the app is launched for the first time.
if you implemented properly your GCM client side - it should work even if user force close the application. that's because the operating system waking up your application if it has the right broadcast intent filter and receiver, what mean that your application don't have to be running in order to receive this broadcast.
No more notifications are visible or possible
If your indication that the GCM not received is the fact that you don't see any Notification, then it's not necessarily true - there is no direct connection between GCM message to the system bar notifications. that's true that usually you'll show notification when push received, but it's deferentially not must.
what I'm saying basically - maybe you have a bug that takes affect after the user force close your app that causing the notifications not to be shown.
Set up:
I have a system which has multiple users. Each user will download my app onto their Android phone and use it. What I want is when any user performs a specific action (I have two in my app), I want to pop up a notification in all the other user phones.
A simple break down is like this:
Start app --> Navigate to the part where action is performed --> Perform the action --> Store the action the a DB --> Notify ALL USERS --> Pop up the same notification on all phones.
How would I go about this problem? Can anyone suggest ideas or links, cause I don't even have a clue on how to approach this.
If you are looking to send notification to all users, even if all the users are not actively using the application, then Puch Notification is a good approach.
Push notifications let your application notify a user of new messages
or events even when the user is not actively using your application.
On Android devices, when a device receives a push notification, your
application's icon and a message appear in the status bar. When the
user taps the notification, they are sent to your application.
Notifications can be broadcast to all users, such as for a marketing
campaign, or sent to just a subset of users, to give personalized
information.
Have a look at Android Google Cloud Messaging
Also I have found XMPP a good solution as described by this post.
You will find some good solutions here and here
Well, you will need a database on a server, and then you will need the app to constantly (or at intervals) query the database in the background for changes, and notify the user when it finds one. A system similar to how many apps give notifications is what I am getting at.
I am working on Push Notifications in Android. Now the issue is that I want to keep running my Push Notifications on the back ground as soon as the app start because I have no idea when the server will push the data to the devices.
The main requirement is that our corporate app is having more than 10 activities and based on the notification received, I have to bring the related activity on the foreground so that user can preform action on that or do some silent action in the background regardless the activity is in foreground.
Can somebody suggest how can I implement this type of requirement. Do I need to do it in a Service.
Thanks
An Android application on an Android device doesn't need to be running to receive messages. The system will wake up the Android application via Intent broadcast when the message arrives, as long as the application is set up with the proper broadcast receiver and permissions.
take look at this;
http://developer.android.com/guide/google/gcm/gcm.html
when message received from gcm server
onMessage(Context context, Intent intent): method of GCMIntentService gets fire,
so you write your code there
take sample example from here
https://github.com/ketanpatel25/GCM-Demo/tree/master/gcm
What you're trying to do defeats the purpose of push notifications. In push notifications, the server sends the message through Google APIs. These APIs then send a broadcast message to your app, which you listen for. Continuously keeping the app open in the background and asking the server for new messages is called polling.
Read up on the GCM documentation. Whenever you receive a message, Android will ca the onMessage(); method of your GCMIntentService.