I have an application that uses call activity to call people. However, when the call is made, the number will be logged to recent call list, and I don't want this to happen.
What would be the best way for the phone to not to log the calls made?
I am not sure if the recent call list uses the same database as the call log, however if it does you can just delete the call from that content provider after it is made.
Take a look at this: http://www.mobisoftinfotech.com/blog/android/androidcalllogdeletion/
Related
So I have a list that is updated from firebase.
In my mainactivity's onCreate, I set the listener for changes. However, the next line of code uses the list immediately. This line runs before my list is updated, thus causing an error.
What is the name of the concept i need to grasp in order to solve this problem?
Firebase Realtime Database callbacks are asynchronous. You'll need to learn asynchronous programming to deal with most of the Firebase SDKs. It means that method calls return immediately and expect to receive results some time later in a callback that was passed as an argument to the method. See the documentation for more information.
I was writing a set of functions for accessing/writing data to the SQLite database in my android application. Since I need to use getWritableDatabase() to get the database instance and this needs to be called in a non-UI thread, I was wondering if there a clean way to specify the same warning in the java docs of these functions?
Also, I needed one more clarification about getting handle over the database instance using getWritableDatabase(). I should call this wherever I need to write things into database right? Or can I call this once at the application level and use the same handle to access db at different places in the app?
There are no fixed rules for such things. You can only rely on conventions/style.
In other words: try to come up with explicit, unambiguous wording and make sure that this part is easy to read and quick to spot in your javadoc (check the generated HTML as well for these properties).
And then be prepared for bug reports from people ignoring your javadoc.
Rather than just leaving a warning in the javadoc, you might add validation, i.e. detect if you're on the UI thread (see How to check if current thread is not main thread), then throw an exception.
Document that exception.
I'm wondering if there is a cleaner and more re-usable way to implement the following use case:
I have a search form that sends a RPC to the server with the user entered values. The callback returns the items that match the search criteria. A search can take several seconds and we want the user to be able to alter his search criteria even if the previous search hasn't completed yet. If he does this, all previous search results should be ignored and the last result should be presented. If we don't take this in account, sometimes the newest call will return before the older ones resulting in the newest results getting overridden, which means the presented results won't match the currently entered criteria.
We currently solve this by assigning the callback to a "lastCallback" field. Each callback instance can access this field and checks whether the field is equal to itself. If not, a newer search request has been sent in the meantime and thus the results of this old call are ignored.
Does GWT provide a built-in way to handle this use case?
You can cancel the previous calls. Have your async methods return com.google.gwt.http.client.Request instead of void, so you can call cancel() on it. This would make sure your previous callback will never be called and you only ever have one ongoing request (from the client's point of view at least; you'll have several being processed on the server because cancelling a request is a client and network thing, and isn't exposed to the servlet server-side)
I think your approach is correct.
This is not a GWT issue - once a browser makes a call to the server, the server is going to respond - whether you need this response or not. So you have to have a flag someone to decide which response is unwanted.
One optimization could be to just return null or a specific exception from the server for the first request, when a second request arrives during a search progress.
I have an android application and in one of my activities I am making a call to get say "Customers", this call is made to an external API, when I get the response I get it as a JSON object. The problem i am having is that I have a ListView in the activity and when you click on of its items it shows you the details but then when you hit the back button I have to make the call again to populate it. In Samsung Galaxy 4S it seems to keep the data of the list view but in the HTC android incredible it's blank. So what I did is, make it rebind OnResume(), this fixed the issues for both BUT the consequence is making another call to that server. When its 10 or 100 customers it doesnt matter but I know that there are some accounts that have up to 5000 and I am sure it will crash.
What are my options to improve performance on this issue with Android?, I tried a static variable but at some point that object got cleared too.
How do Android applications usually handle this cases where the data is retrieved from API's and they need to be stored through out the application and there is no need to make another call for the same information?, I was thinking on static object but i want to make sure I do this the right way.
You have a couple of options.
1) You can cache the data in memory. For example you can make a static cache or cache the data within the Activity or the App object. If you are doing this in only one view and if it is not a lot of data, this might be an ok solution. However, if you have to do this for many activities and there is a lot of data that has to be cached, you might want to go for option 2. Also storing data in memory in android, does not mean it won't be garbage collected (in some cases, even if you have a reference to it.)
2) You can cache the data in the internal storage and refresh it from time to time.
You can find more info about the internal storage and how to use it here: http://developer.android.com/guide/topics/data/data-storage.html#filesInternal
Basically, you store the response within the internal storage under a specific identifier. The next time you open the activity, you check if the storage has data for that identifier and if yes, you read it and display it. If no, you make the API call.
Keep in mind, that you will have to refresh the cache from time to time.
I had the problem with ListViews on my application too. What I did is that I wrote a custom adapter and that solved the issue..
However the thing you can do is to make a global variable and save the returned results to it. When your application wants to call the server, check the variable, if it's null make the call, if it's not then just draw the ListView with the already fetched data..
Keep in my mind, to implement a refresh button, you need to skip the check.
I'm having issues with doing proper save in hibernate/entity manager in swing desktop application. I have a method that counts proper logouts from application via call to webservice. Webservice method looks like this:
public void setLoggodOutCount(User user){
user.setLoggedOutCount(12);
em.merge(user);
}
After calling this webservice method my program exits. Then when I look at my server logs I can see that there was two updates executed. One with good value=12 and one with prev value=11. Sometimes there are in good order, sometimes not. What can I do to force my update being executed last?