Is it possible to know the app which is opened currently? - java

I am a beginner in android development. I want to know that is it possible to know the app which is opened currently. I came to know that finding the apps which are running currently through Activity Manager (getRunningTasks()) is now removed from the Android studio. So I want to know is there any other way to know? I just want to know the app which is opened and running currently on the mobile but not the apps running in the background Could somebody please help me in this case?

You can use AccessibilityService to get event notification. But AccessibilityService are specifically for accessibility uses. If you use the service for other purposes, then the application will more likely to be downed/removed for PlayStore due to policies. Another viable option is UsageStatsManager, but with some limitations.
UsageStatsManager is not push event based system. You have to poll in few mills(depends upon the use-case)
Usage Access Permission grant/deny is not straight forward. You have to start Setting Activity with Settings#ACTION_USAGE_ACCESS_SETTINGS action and have to rely on the users understanding of how to grant permission(Since permission list may contain other applications).

Related

Launch my application when a user opens a certain application - Android

Is there a way to open my application when a user opens a certain application?
For instance, I want to launch my application's floating button as soon as the user opens Instagram. Or even better is they open the "story" camera?
This is different from inexplicit intent, since, I don't have a way of interacting with Instagram, but is it still possible?
Do I need to check with the system to see which application are currently open or is there another way of doing this?
As NomadMaker says, in general this is difficult to do because it would be a security issue. In fact, an issue like this was published as the Strandhogg vulnerability. That said, some apps (like LastPass) use/abuse the AccessibilityService API to get this information. This would be an OK way to do this if you're making an app for yourself, but is discouraged if you plan to distribute the app.

Remove android setting screen from recent list [duplicate]

I was wondering if anyone had a relatively simple solution for us.
We created an app to be used by our clients on android devices that we give them.
We would like the client to only be able to use our app and have limited access to everything else (i.e. settings, email etc.) What is the best way to achieve this without using 3rd party apps.
Thank you in advance!
This may not help but the L preview has a task locking feature included that may be of some insight, I'm not aware of how it functions as yet
Task locking
The L Developer Preview introduces a new task locking API that lets you temporarily restrict users from leaving your app or being interrupted by notifications. This could be used, for example, if you are developing an education app to support high stakes assessment requirements on Android. Once your app activates this mode, users will not be able to see notifications, access other apps, or return to the Home screen, until your app exits the mode.
http://developer.android.com/preview/api-overview.html
Hope this helped
Suppress the Title Bar & Make Your App a Launcher
Root Your Tablet
Modify System Files and Settings to hide the soft keys
On the next link you can find the complete solution for the Nexus 7 (2012)
http://thebitplague.wordpress.com/2013/04/05/kiosk-mode-on-the-nexus-7/
simple Answer is:
Lock Install button with modify system settings.
Create your own customized-ROM and apply your requirement to that ROM.
more info, visit XDADavelopers

Cannot access/control ongoing downloads after closing and reopening the Android app

My android java app has Offline Video feature like the YouTube app. I do not use android.app.DownloadManager because it does not support pausing the downloads(or as I know).
I have been using a third party download manager library(tonyodev.fetch2) and it does the work done but the problems are:
How can I make the download independent of the app closing/opening etc and also being able to control it when required from an Activity.
If I use a Service for the above problem, what do I use, IntentService or just normal Service keeping in mind I have to know about the ongoing downloads and control it(pause/stop/resume) from any activity.
I have been using android worker class which extents ListenableWorker but I cant seem to make things work as required.
I have been struggling with this for a long time now any help is welcome, or a totally new approach for this particular problem.

How to add shortcut on home screen when app gets install

I know it's not the best practice, but it is a requested feature (e.g. for business apps). When the App gets installed, I need to automatically place it on the home screen. I saw a lot of code on the internet, but all of the code only works on button click when the app starts. But I need to place a shortcut on the homescreen immediately after the app is installed and before the app starts. Is there a way I can achieve this?
PS: To make the question more clear: The app will be distributed without Google Play Store, so that's not an option.
Thanks for your help!
Best regards,
Robin
You can't run any code in your application before the user starts your application for first time during to restrictions since Android 3.1. Check this for more information
That's an optional feature of the Market app, not of the apps themselves. When designing an application , it does not receive a broadcast about itself being installed.
the first time the app launched can create it.
You can achieve that by creating a method in your main activity and call this method from oncreate and create a boolean variable andsave it in shared preferences

Get android notification from app?

I was thinking to build up an app to manage the notifications. I gave a look to the Notification Manager but i didn't find anything that could help me. I'd like to get all the notifications (that are in the notification bar). Have you got any idea? Thanks, regards.
I don't believe there's any possibility to do such thing using the public API. There are strict restrictions to what an app can access, for obvious security reasons. Each app is handled as a different user by the OS, so it has access only to public data and to the data owned by that app.
If you need this for a private project, you may consider modifying the android source code. I can't give you many details on how to do it, but I would start by looking at com.android.server.NotificationManagerService (source code here).

Categories

Resources