Just a bit of app background, this app allows users to click on a number from the application and redirects it to the phone app.
And once the call is done, it will redirect the user back to the app then it retrieves the call information of this particular number (such as timestamp, duration, etc)
However, I come across a race issue where I don't get the latest call log on some phones; meaning Android writes the call log after the app reads the CallLog provider (I can't be certain for how big this window gap).
To put this in simple technical flow:
User click the phone number on the app
Broadcast receiver is triggered
App start Phone activity
Call ends after some period
Broadcast receiver listen to the event
Get call details
With this in place, is there some steps that I missed? or do you have a better solution to handle this?
Thanks.
Related
Could someone please help me figurate how to make an app that has no icon and starts at the startup?
I want it to start in every startup and keep running all the time, because I want to Toast the name of the sender each time there's an incoming SMS.
I'm not sure what you mean by "hidden" as the O/S generally tries to avoid allowing you to hide behavior from the user. What you want to do is discussed in this question Trying to start a service on boot on Android. That will enable you to launch a service and then by watching for the appropriate intents related to SMS messages you can create the toasts you desire.
The app
So I'm developing a chat app using GCM. The app works as follow: In a list of users, I can choose with which one I want to talk. Then a request is sent to this user and he has to accept it in order to start the chat. It's like the first user opens a chat room and wait for the other o join in. Im doing all this communication using special flags through GCM messages. Note that a user only exchanges messages inside a "chat room". There's no notification for him if he is outside a chat room.
The problem
When a user leaves the chat room I make him send (through onDestroy()) a message through GCM to tell the other user that he is disconecting and therefore the other user won't be able to send him messages anymore. But what if this first user leaves the chat room without calling onDestroy()? (Like closing the app, the app crashes, internet goes down, etc...)
Solution so far
When the user sends or receives a message I update his last_seen attribute on my database so I can know more or less if he is still online. So I have a cron job on my server checking from x to x seconds if the users of an active conversation are online and closing it if one of them are not. Note that the proccess of updating the user last_seen attribute is really heavy since I have to make an HttpRequest everytime I receive a GCM message (when sending I already have to make an HTTPRequest, so its not a big problem) and that's why I don't like this solution...
Question
Any ideas on how to know if the user is not there anymore?
Thanks in advance, any ideas are welcome
You could perfectly use the onStop() method of your chat room activity:
Called when the activity is no longer visible to the user, because another activity has been resumed and is covering this one. This may happen either because a new activity is being started, an existing one is being brought in front of this one, or this one is being destroyed.
Followed by either onRestart() if this activity is coming back to interact with the user, or onDestroy() if this activity is going away.
Set the status as online as long as that event doesn't trigger, if it does, send the last_seen parameter and assume he is no longer in the chat room.
My app "syncs" all the contacts on a phone with the server. However, part of the requirement is that if any contact is inserted, updated, or deleted then the sync must happen again to maintain data integrity. I know about registering a ContentObserver on ContactsContract.Contacts.CONTENT_URI, but any such observer would have to be unregistered on the Activity's onPause(), and thus would not get notifications if the app wasn't running at that moment.
I also do not want to implement a content observer in a service, since services aren't permanent either. Plus, I don't like the idea of running something in the background 24x7.
So, is there any way by which I can detect that the contacts have changed since a sync? I do not need a real-time notification, so it's ok if this detection only happens when the app is run next.
I am using a broadcast receiver in my app, to display a photo on BOOT_COMPLETED. However, I noticed that if I receive a phone call on my phone, the photo is displayed in front of incoming phone call activity, so I can's see who is calling me and what is worse - can't answer the phone.
What is the best way to override this behavior?
you could add another mechanism for listening to phone calls events, and if you detect that the phone is ringing (or the call was answered), you won't show the activity...
in any case, please don't show such things. no user likes popups go out of nowhere.
instead, use notifications to tell the user something has happened.
I want to fire an event when the user opens his messages from a particular sender. I am thinking of using a Service which fires that event when the user opens his messages.
First, I would like to know if this thing is feasible? I mean, is it possible to get the info that the user has opened his messages (of a particular user in Android)?
Second, is using Service the only way I can get through it? Is there any other method?
Thank you guys in advance :) ...
I mean, is it possible to get the info that the user has opened his messages (of a particular user in Android)?
You fail to say what sort of "messages" you are referring to, or what app those "messages" would be viewed in.
That being said, unless the app's developer is leaking private data (like "message" recipients) via some broadcast Intent, you cannot get the information you seek.