notification for crashed app in android - android

I created an app and I want it to be on all the time. I use it on a tablet in a room. So, I was wondering if there is any chance that the app sends me a notification if it crashed or is turned off?
Thanks!

onPause() is called when you exit the application but don't close it, and onDestroy() is called when you close the application. If you want to do something when either of these two methods is called, override them in your activity and add the notification call in there.

Related

Track count of app launch in android library for analytics

I am developing an Android library for analytics. I have created a method to get all device data. Application class of the app will call this library method.
I want to track app launch count also. I tried to use the same method but Application class does not get called every time. For first app launch, got call in application class but when I tried to exit app using back press and launch again, I did not get any call.
Last option for me to track launch count is ask application to add one more call in on-create of launcher activity but is there any better way? How firebase and other analytic libraries implements this?
When you close your app by doing back press again and again. It pushes the application in background but doesn't kill it. So the application class is not initiated again. So this is not treated as App Launch.
App Launch is triggered when the user kills the app or the OS kills the app in background due to limitation of resources.
So, what you have done is fine...but if you want to beyond this you would need to implement your own logic like you mentioned (using onCreate of activity)

Is it possible to update an ongoing notification after the android app was closed?

I have this Android application with an ongoing notification and there I have a copied text from the user's clipboard. So, what I'd like to do is: Whenever the user copies a new text (when he's NOT in my app), update this text on the notification at the Status Bar.
I've looked at the ClipboardManager.OnPrimaryClipChangedListener, so apparently it's possible to detect when it changes, but how can I do it when the user already exited my app?
Is it possible? Where should I implement this?
For now, I've called the mentioned listener on the onPause(), and onDestroy() methods, and also called set moveTaskToBack(true); when the user press the back button, so it doesn't close the activity, just minimize it.
It works for awhile, but after some time it eventually stops working (when the system eventually stops the activity). Is there a workaround?
Thanks for any help at all.
If someone else had the same issue, take a look at Service and BroadcastReceiver.
Solved my problem. Did exactly what I wanted to do.

Started Service stops if application is forcestop from download App

i made a sample android app,which starts a started service by calling startService(serviceintent).
it works fine,but if i forceQuit my application from settings>app>downloaded>force_Quit.my service stops and even destroyed is not called.
i studied for 3-4 days and know about start_sticky in StartOnCommand method.i am able to achieve all aspects of service.
I want to know whatever i am achieving that service stops and doesnot restart automatically even if started as Start_Sticky is normal behaviour according to android.Can i make it restared if user force quit my application.
my manifest is correct i uses process tag also.
if i forceQuit my application from settings>app>downloaded>force_Quit.my service stops and even destroyed is not called.
Correct.
Can i make it restared if user force quit my application.
No. Nothing of your app will run again until something uses an explicit Intent to start one of your components. Usually, that means that the user taps on your icon in the home screen launcher, though there are other explicit-Intent scenarios (e.g., GCM message).

Open the same app instance

I have a simple, one Activity application.
The problem is that, if i press the BACK button, the application is minimized, but if i try to launch it again, another instance is started.
I know this because my app has plays a sound stream even if is minimized.
How can i maximize the already running instance when trying to launch it ?
I've tried with the code below, but is not working.
android:launchMode="singleInstance"
Android handles this for you. What is probably happening is you're replicating your objects in onCreate thus the "appearance" of 2 activities via a 2nd sound stream.
I don't know what is the C button ? If it is the "back key" so your application is unload from the system, when you start it again, it opens a new instance.
If you press the 'middle key', normally there is only 3 keys on a Android phone, your application is just paused and put in the background, and when you launch it again, the sytem just put your running application from the background to the foreground. No new instance is opened. There are the methods onPause() and onResume() which are triggered in this case.
Hope it can answer to your question

how to maintain a Home Button Presistent state of an app in Android?

i am working on my App. in between i pressed the Home button on the device. my app will go to the background tasks. After that i long press the home button it will show my app as a persistent state. i.e where and what i had done in my app. But i click my app in the directory window it restarts my app. i want to do if my app is in the background tasks it will wake up else it will start. how to achieve that? Any Idea?
When you do that Android will call:
onRestart()
onStart()
onResume()
You can override that methods in order to do what you need. I wouldn't recommend it, though.
Remember that if the device needs memory, it will kill your process and when you open your app again Android will call the onCreate() method of your Activity.
Check the Activity's lifecycle.

Categories

Resources