1

I realize this question has been asked many times in a various way, however, all of these answers given are from roughly 5-7 years ago. With the new android API's, most of these answers are methods given which have been depreciated.

I know it can be done, because there are many apps on the play store that can do it, like Appblock which recognizes an app opening and then going back to the home page, or AppLocker where it recognizes an app that opens and creates a pin lock overlay.

Both of these apps are examples of a service used to identify the package name of the current activity that is on top.

Now, How can I get the package name of an app that opens so I can use it in a service which goes to the home screen if a specific app is open.

I'm working on an android app that allows the user to check off what apps to block from opening, and then if the app is opening just send the user to the home screen.

here are a few of the bunch of stack overflow questions I've gone through(I've been searching for an answer for this for a week)

How to get package name from anywhere?

how to getTopActivity name or get current running application package name in lollipop?

Android: How can I get current opened application name on screen

all of these answers don't help because they use depreciated methods in the new Android API's

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • @ShaluTD did you even read his question ? He has even linked that same question as one that uses depreciated methods and is looking for a solution that can be presently implemented. – Karan Shishoo Mar 20 '18 at 07:28
  • Sorry. I thought its already asked. – Shalu T D Mar 20 '18 at 07:32
  • haha thank you @casualcoder. Yes it has been asked, but they were all asked like 5-7 years ago when the API's allowed the methods that have been answered for. – Abdo Getrick Mar 20 '18 at 07:52

0 Answers0