Regarding the android app crash - android

Actually my android app is using quickblox backend, If app got crash somewhere then session gets destroyed but app is not getting closed. it just goes to previous activity, but user is not able to do any operation to backend means service call(saying token required).
So I want a solution that will close my application so that user again restarted the app then session will be regained or we can start the splash activity.
please give me a solution .
I will be grateful , thanks

There is an option to get the app crash data using UncaughtExceptionHandler in your application class.
So , using this you will be notified when your app will crash. but if you want to exit your app , this is not a good solution as suggested by google core team. So you should handle this using try catch and in catch again calling the service to get the token.

First it is not a good use case. Instead of that you can try to catch exception and try to recall your service at runtime.

Related

Is there any way to detect an application crash and then launch it again in Android?

I have an APP_A. It will crash when it actived for a long time. I try to find out the resolution to solve the problem but still stuck in it. So I want to try a short term solution that launch APP_B in backgroud then detect the status of APP_A. If it crash, then APP_B will launch it again.
Is there any way to detect if APP_A crash or not?
When the system force stops your application, the entire process is simply killed. There is no callback made to inform you that this has happened but there is workaround and you can try:
https://medium.com/#ssaurel/how-to-auto-restart-an-android-application-after-a-crash-or-a-force-close-error-1a361677c0ce
You can use eventbus library (https://github.com/greenrobot/EventBus) to detect your crash on every situation in your apps and send mail to your mail ID to detect the crash report by using this library (https://github.com/ACRA/acra)
One method is to get the crash through FABRIC and check the logs in ANDROID STUDIO by analysing stack trace.
ANDROID STUDIO--> ANALYSE-->ANALYSE STACKTRACE

getServerAuthCode always return null after you kill the android app in background

I found out that the Play-Game-Services Integration with GetServerAuthCode Integration does have an error when the following situation:
After I finish the integration and i call getServerAuthCode, it
bring me the AuthCode value.
After I close the app in the background and i re-open the app, the silentSignIn always fail.
Now I can't retrieve my AuthCode unless I re-signIn the app, this cause an issue as player need to always re-signIn the app when starting of the app. It doesn't bring a good User Experience.
I wish to know that is there something that i miss out during the integration? Or it is an intended feature? If it is an intended feature, is there any solution/work-around that can help me solve my issue?

Send stack trace information to backend server from android app on app crash

We are in the process of writing a realtime error handling web platform, and I am trying to find out what is the best way to send the stack trace information via an http post request back to our server as soon as the android app crash occurs.
I already use the Thread.setDefaultUncaughtExceptionHandler callback to register our callback handler so we can capture the stack trace. Hover I can't seem to make an http request right after the app crashes for some odd reason (behaviour is very weird, the response/error callbacks are not called at all if I make the request in the error handler part of the code, so my guess is the http request is not reliable at all if invoked there).
I also tried starting up an IntentService in the global exception handler so I can make the request from there but the service just wont start after the app crashes. I don't know what to try next.
I need to be able to send the error to our server straight away, without using 3rd party crash reporting services (because this is what we're building ourselves). Any hints as to what I could try next?
#CommonsWare's recommendation ACRA is a really good solution.
But regarding:
[...] post request back to our server as soon as the android app crash occurs.
[...] I need to be able to send the error to our server straight away [...]
Saving the report to send later, you can force the app to restart, and send the saved report on restart with a clean stack.
I used something like Ereza/CustomActivityOnCrash library to do it, what it does:
Allows launching a custom activity when the app crashes, instead of showing the hated "Unfortunately, X has stopped" dialog.
So basically it "kills" your crashed application, then start a fresh one with a friendly activity.
I used it to show an Activity telling the user that we already received the crash, asking to write down more directions to help us solve the issue and if the user wanted to be contacted upon bug fix.
I ended up using ACRA library following #CommonsWare's advice

PushNotifications and MVVMCross

I have a service which handles my push notification. When the app is running, everything is fine, but once the app is not running I am getting a null reference exception. I have traced it back to the following line :
newIntent = Mvx.Resolve<IMvxAndroidViewModelRequestTranslator> ().GetIntentFor (request);
This line is used to get the intent for the status bar notification so when the user clicked on it it will take him to the appropriate page inside the app. I am pretty sure that This is null because the application is not running and the MvvmCross framework did not have a chance to initialize and register the IMvxAndroidViewModelRequestTranslator.
My question is what should I use as an alternative?
UPDATE
So I dis some reading and I believe that a regular intent wont work and break my app. I was thinking about creating a dummy activity In my app which will get the regular intent I will send and move on to use the IMvxAndroidViewModelRequestTranslator (which should be not null since the app was started) and create an MvvmCross navigation request.
Any thoughts?
UPDATE 2
Tried the approach above with no luck... still failing on the same line...
So basically the question is how can I launch the app from the status bar while making the MvvmCross eco system start as well...
Thanks
Amit
So what I ended up doing is once the notification arrived and the Mvx.Resolve threw an exception I (meaning the app is not running), I saved the notification data to the app preferences and launched the app to its main activity and there I simpley checked for the notification data and if it existed I navigated to the appropriate activity.
When the Android UI starts, then MvvmCross runs Setup to initialise things like IoC, your application, etc
If you need to initialise your MvvmCross application within a non-UI setting, then try the answer from MvvmCross DataService in an Android Broadcast listener which shows how to access the same setup that the UI uses.

How to show message like "the application has crashed, but a report is sent to the admin" in android

I am new to android and my application involves lot of internet access and many times when the data that needs to come from a web service is unavailable my application crashes.
I tried to avoid as many cases as possible, but i am not sure if my application is crash free.
I am using an application named "delight circle" and sometimes that application crashes and shows me this Toast:
"The application has crashed and a report is sent to the admin"
and takes me back to the previous activity or previous action, and from here i can use the application normally again.
I have 2 questions:
How to make the application work normally after it crashes once. In my application, if it crashes then it asks me for force close and when i click it, it takes me to the previous activity(or action) but nothing works there, if i try to do anything it asks for force close again, i eventually end up force closing the application from Settings --> Applications --> myApp --> foce close.
How to send a report about what actually caused the application to crash?? Right now i have a lot of logs in every activity so, now if it crashes i can find out the exact reason and solve. But when i release the application how can i do this?
Thank You
You have to use UnCaughtExceptionHandler for this.
Here is a example,
http://trivedihardik.wordpress.com/2011/08/20/how-to-avoid-force-close-error-in-android/
Once you override the Exception Handler, you will be provided with access to the Log and from where, either you can send the error log which you get the from the SatckTrace as an Email or use Apis to do it.
I can give an answer to your second question, that is "How to send a report about what actually caused the application to crash" Try Crittercism in your code. It will help you to find the exact cause of failing the application. Not only that, it has so many features, like Live Stats, Unresolved crashes, Crash alarms and more.

Categories

Resources