Handle an Activity that is pushed to the foreground [duplicate] - android

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Listen to ActivityManager events?
Is it possible to know immediately (not by listing / iterating over processes in the background service with intervals) which app (and which activity) has been pushed to the front, perhaps using some kind of broadcast information? I want to know globally which app has been pushed to the front, not just for activities within my app.

It doesn't look like it's possible, at least not without modifying the Android source. Take a look at the source of ApplicationsProvider.
This is a similar question: Listen to ActivityManager events?

Related

Youtube mini player in Android app programmatically [duplicate]

This question already has an answer here:
Android - YouTube Api player on floating window using service
(1 answer)
Closed 3 years ago.
Want to realize same functionality(mini-player in-app only)
currently, I realized it using fragment on the foreground. But it works only when 1 activity. And if use many activities fragment will be recreated and it's not ok when user watching the video.
So, maybe someone can recommend a better solution/example.
I have checked the solution with widgets(Not for this case).
I realise that you discarded the widget possibility but i would still recommend you check it again in this example.
It shows and updates data on one xml which you could expand on screen and reuse or discard if needed.

How to access Android hardware by pressing volume key [duplicate]

This question already has answers here:
Listen to volume buttons in background service?
(14 answers)
Closed 5 years ago.
I am making an application and I want to make app in such a way that user directly open that by using volume key, suppose user click twice the volume+ or volume- buttom and the app will directly open without home screen or without any interuption.
I want to add this functionality using the code in Android Studio. If anyone know how to add this, please help...
What you are asking for is not App/Code nor Android Studio related but device related, If the Original Equipment Manufacturer will allow a device to have a shortcut button it could be possible to achieve that on those devices.
Cheers.

Activity change icon programmatically [duplicate]

This question already has answers here:
Android use a different icon for recent apps
(2 answers)
Closed 6 years ago.
I have 2 activities and they must be run separately.
Now, I'm starting second activity using FLAG_ACTIVITY_MULTIPLE_TASK and FLAG_ACTIVITY_NEW_TASK.
.
QUESTION: How can I change icons of the activities?
As I remember, it's possible, as Google Chrome used them before. How this feature called?
UPDATE: Icons are dynamic, so I need to change them programmatically
This is handled by ActivityManager.TaskDescription
https://stackoverflow.com/a/28100891/3815843
PS: On Android running applications are called "Recent Apps". I always googled Task manager, Intent manager. That's why I didn't found any info
I think you question is duplicated. See other same question.
This, for example!
Just set android:icon for each activity separately in manifest. Works for me.

Android-Activity & Fragment not getting instance after some time of Background ideal time of Application [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
Case : 1
When I am using 5 to 6 application with my Application running in
Background. After that when I tap to My Application it comes
foreground and not getting proper instances.
Due to that my Code is not working written in onResume method.
How can I manage the instances before and after it kills by the Android OS it self?
Null pointer Exception is created in OnResume() method is called in Activity Life Cycle.
When your application is put in background, ie. by pressing Home screen then Android might more likely kill your app process to reclaim its resources (mostly memory) - this is more probable if you switch to several other applications. When your app process is killed - then all the instances (also static ones) are killed too.
When your app is being closed - ie. you pressed Home button - android will allow you to save its state inside ie. Activity life cycle methods. When you are showing your app back, android will call life cycle methods in various components which will allow you to recreate instance state from before app was killed. This is a large topic, you can read more here: http://developer.android.com/training/basics/activity-lifecycle/recreating.html

how to keep app active or restart when killed? [duplicate]

This question already has answers here:
How to prevent an android activity to get killed
(3 answers)
Closed 9 years ago.
I'm trying to create an app that sets an alarm if the screen is off for too long. This will be checked in the background every 5 minutes. Unfortunately android kills my app sometimes and I need to keep my app active in the background. What is the best way to do this?
I was also thinking about restarting every 5 minutes if the app is killed. Is this a better way to keep my app mostly active in the background? How to do this? Or is there a better solution for me?
Maybe restarting the way like Facebook does?
I would recommend having a look at Mark Murphy's WakefulIntentService.
I think i fixed it by using a simple service that does nothing except for an infiit loop of logging.

Categories

Resources