I'm writing a chat application on Android using the Parse SDK (1.5.1) in which i use obj.saveInBackground(SaveCallback) to create a new chat message on the cloud. The problem is that sometimes the SaveCallback never get called (I put a log inside the callback and that log never be printed out).
This usually occurs when i continuously send out about 20-30 chat messages, for each message, i use saveInBackground to create it, but the callback just be called for the first messages (for example, it was ok to create message 1 to 30, but for message 30-40, the callbacks were not called and they couldn't be created).
It seems that when the problem occurs, all the "ParseRequest.NETWORK_EXECUTOR-thread-xx" threads are in the Wait status (maybe they are waiting for results sent back from server?).
Please take a look at the application's threads snapshot when this problem occurs.
Is there anyone encountered a similar problem before? Could you please give me advices how to deal with it?
Thanks!
I faced similar problem in case of files, so I used recursion function. may be you have to call recursion method of saving messages until all messages are saved to parse...
Related
H, I miss a lot the old time when users could comment on crashes in Android.
Now I realise that the best way to reproduce something like this would be if the app could detect when it was open for the first time right after a Fatal error, so I/the app can advise the user to send a personalised comment on how the crash happened.
Is there a way, using Firebase/Crashlytics, to know that the app crashed previously, when opening an app?
If there is an uncaught exception in an activity (or service) the activity is forcably closed and the previos activity of the app is shown. If the last Activity causes the crash the app is closed.
What you can do to detect this situation is to register a global-uncaught-exception-handler that writes `firebaseException=true" to a file/app-settings if the exception comes from firebase before calling the previous global-uncaught-exception-handler.
In every Activity-s onCreate you can load firebaseException and act according (do not forget to write firebaseException=false after.
I have never worked with Crashlytics but i assume that it also hooks into uncaught-exception-handler so it is important that Crashlytics is initialized before you set your own handler and that your handler calls the previous uncaught-exception-handler when done
You may use custom Crashlytics webhooks to notify your service about crashes and reach back next time is opened.
I'm trying to determine whether or not I download data in my android application. I can do this by making the method return true when it does download data, but the listener doesn't seem to be invoked until all other code is finished running (meaning it waits until a pause in your code). So I'm wondering if there is a way to sort of "forcibly" invoke these listeners? Perhaps by creating the listener in a different thread? Would this work or would it be a waste of time? I've already tried to sleep on the main thread for a few seconds, but that doesn't seem to do it either. If it wouldn't work, could you explain when exactly these listeners are invoked? Thanks in advance.
To add onto my question, I am NOT using the realtime database. I understand how realtime triggers work, but I am using the Firestore, so I am only getting data once, not getting realtime updates :)
As you have already noticed with the API calls that deal with reading and writing data are fully asynchronous. This means that the call always returns immediately, without blocking the code to wait for a result. The results come some time later, whenever they’re ready, since it may take some time for this. Depending on your connection speed and the state, it may take from a few hundred milliseconds to a few seconds before that data is available. So Firebase, already is using another thread (other than the main thread) to get the work done.
Calling a synchronous function on your app’s main thread could freeze the app indefinitely, which is a terrible UX. On Android, it could also soft-crash with an Application Not Responding (ANR) dialog.
Doug Stevenson, has explained in his post everything that you need to know about Fireabse asynchronous behaviour and what you need to do/avoid when dealing with Firebase.
It seems to work fine but after sometime all calls to saveEventually and saveInBackground are not saving data to parse (there is no callback and there is no error message as well). It seems it is silently discarded. When this happens, we are still able to fetch data from Parse i.e. all read queries work. We are using local storage. The updates start working again once we clear the app data. What could be causing this? How can we debug the requests that are silently discarded?
You are using a synchronous function saveInBackground. If you want to have callbacks, you need to call the asynchronous version saveInBackgroundWithBlock instead.
Please read the Parse documentation carefully before posting a question here.
I have a multi-Threaded android application. One of the things my application does is saves various data to a database on a server via webservices. I was trying to figure out why things were not saving to the server correctly, and saw in one of my log files, that the application objects onCreate() method and constructor were called in the middle of one of the requests going up to the server. These request are in the background and are sent via an intentservice.
I have my application set to catch unhandled exceptions and log them, and I did not see anthing in there. The application onCreate() and constructor was called, the application was kicked back to the main/first screen, the user then had to re-login, and it seems that the database was wiped(which is something else I am wondering about).
So, my main questions are: Why did the application object onCreate() and Constructor get called(why did the application get killed), why did the database get wiped when the above happened because if I do a force stop from inside of settings, applications, it never kills my db.
two words: low memory
I have the same problem. No solution for now. Try to take advantage of the onLowMemory() method, maybe the OS will spare your app.
My application object gets restarted randomly (not any time) when I am coming back from an external application (ex. camera or gallery) for onActivityResult().
Hope that helps someone.
If the application is not a service, but a 'normal' application that calles your intentservice, it is subject to the normal application lifecycle: this means it will get killed when in the background.
Look for the explaining image on this site: http://developer.android.com/guide/topics/fundamentals/activities.html
Take note of the red "Process is killed" part on the left, an the subsequent "onCreate()" afterwards.
I've actually seen very similar behaviour that was caused by a NumberFormater trying to parse a null String. After the call to parse(), the application simply reset itself back to the splash screen with no errors at all. Wasn't fun to track down, pretty much stepped through half the code base trying to find out what was happening - the debugger disconnected and the app restarted when stepping past the parse call.
I have been working on a chat application and I need some suggestions to go about it. I have a server. Whenever a user logs into my app, and selects some user by searching, and sends a message to him, it will be stored on the server. Then my app checks if any a new message has arrived for me. If any message comes, it will be notified to the user. For achieving this, I have followed this method to update the UI whenever a new message comes.
And when the chat continues for more than 3 minutes, the app starts becoming slow. How to go about the problem?
If the app is sluggish that means there is a memory leak somewhere, or you are over logging, or doing something that you shouldn't be doing on the UI thread. Maybe you're polling the server too much?
By the way using TextView for chat is primitive, use the transcript mode for ListViews.