We get a flash message after a call finished.I need to take the details and store into sqlite db.
I need to get the duration and cost of that call from the flash message.
Then how to take this information.
You just use broadcast receivers to get the message. After that you have to parse the string to get the details like cost and time. But the main problem is different service providers have different format of flash messages. So you have to manage all these difficulties.
If I understand you want to be notified when some call is finished for storing the information in a sqlite database, right?
You can use a BroadCastReceiver that notifies you when the call state changes, here a brief explanation.
I don't sure if with the broadcast you get all the call information, if not you can always open the call log content provider example
Hope it helps :)
Related
Play store has numerous apps those creates fake call logs.But, sometimes it's important to detect is that call log real or fake to save yourself being a fool. Can anybody tell me how can we detect same?
If these apps are writing to the actual android call log, I don't think there is much you can do against that.
However, you might want to try the below solution, which can maintain your own call list based on the device behaviour.
In Android you can listen for incoming and outgoing calls, using a BroadcastReceiver. Here is a good tutorial for it:
https://www.codeproject.com/Articles/548416/Detecting-incoming-and-outgoing-phone-calls-on-And
If you implement it correctly, you will only receive events from calls being executed for real. So you can save them in your app's call log.
So, I want to learn this synchronization strategy instead of just using the simpler MessageAPI, but am really struggling with how to successfully implement this.
My project is like this: I make queries to download a small amount of text from an API, via my phone. I will make these queries every so often, haven't really decided on how often just yet. The data will update the watch, which should hold onto the last data received. After that first download occurs, I send data using a DataMap, to the Android Watch. I only send that once, because I believe that sets up a channel to continually send updates when ready. If that is wrong, please correct me.
My main question is this: what if the Android phone's app closes? Then the data object goes to null, and gets sent to the Watch as null? Or, should I send an object from a long-running service or shared preferences on the Android phone, so that the object is never null?
Think of the Data Layer as more of an event system, i.e., you update your data and you're notified on the other side when the data is updated (created, changed, or deleted). You don't have to worry about if the Activity is killed after that. Even if the data was 'deleted', you would be notified it was deleted.
On the Wear device, you would listen for the changes via a Service or Activity and update UI, DB, etc. accordingly.
It probably make sense to read through this Android training guide. (It isn't too long.) The Handling Data Layer Events section is probably the most useful.
I'm making an application that detects incoming text messages.
When a message is received, the application must perform a certain action, depending on the sender and the content.
The problem is that the application must work at all times.
Detecting messages works through a BroadcastReceiver class. Via a Toast message I can see that the application (open or closed) receives the message.
The problem then is that I must perform certain actions, which are stored in a local database (DB40). But I can't access the database when the application is closed.
So, how can I perform database access and run other code (like making the phone vibrate, or play a ringtone) when the application is closed?
Thanks in advance
You can access the DataBase... because you are getting the context from the receiver, from the context create the instance of the Database and go further according to your requirement..
Check this...
You need to run a service to perform all the task even app is closed.
Just go through with few sample and study:
http://developer.android.com/guide/components/services.html
Do you know about Services?
You can use service as back-end to perform action on incoming messages or can use database.
Database need only 'Context' object for read/write and service provide 'Context' object by 'getApplicationContext()' method.
If you have any ambiguity about answer, just give me your little code, i will give you back with solution.
I have been struggling with an approach to this problem for some time now. There is no Intent action fired off when a contact is added (as far as I know). What are my options to solve this issue?
Here are some ideas I have been playing with:
Firstly I kept a record of user locations with timestamps and periodically scan the Contacts DB and add new entries to my own DB with a timestamp. I could then compare these and try to find a decent match. I do not like this approach as it is very error prone.
Recently I've been looking at a ContentObserver for the Contacts DB, but I am not sure how to set this up so that it will constantly be observing, and not just when my app is in focus. Perhaps in a service? The documentation isn't clear to me about the life-cycle of a content observer, i.e does it die after the service/activity that registered it dies?
So really what I want is a seamless way to record where and when a user adds a contact when my app is installed on the device. It is not enough that the app should be in focus/running.
The second idea of yours is the correct one. The observer needs to be in a service as you had rightly guessed. Register the observer in the onCreate(). You will use contentProvider in the onChange of the contentObserver. You will need to maintain time when you last read the database using shared preferences. Note the changes of entries after the time stored in shared preferences. Now update the time of shared preferences to current time. Also unregister the content observer in onDestroy().
I have few question about sms logs. Some of them are on the forum but I just want to get another opinion.
First of all I have read that it is not recommanded to use Content resolver for sms(getContentResolver().query(Uri.parse("content://sms/"..)) ) because it's not in the official api. Do you think there is a better way to get this information?
I would like also to trigger an action(like starting a service) when a message is received/sent. For received messages you can add a broadcast receiver with android.provider.Telephony.SMS_RECEIVED. Is there a way to do this also for the sent messages? From what I have seen Content observer works only when application is active and I would want something that can function all the time.
I want to know if there is a way to query deleted sms(including with Content resolver).
Thank you for your time.
Do you think there is a better way to get this information?
Better? No. There is worse - to obtain root privileges and query SMS db directly.
I want to know if there is a way to query deleted sms(including with
Content resolver).
I guess when data is deleted from db there's no way to get it back.