Get application package name that currently showing activity - android-activity

By using activityManager.getRunningTasks you can get the current running applications in android.
How ever it does not tell you which of those tasks activity is showing right now.
How do I get this information?

To get topmost activity you will need to interrogate the first task returned by getRunningTasks:
ActivityManager activityManager = (ActivityManager)getSystemService(Activity.ACTIVITY_SERVICE);
RunningTaskInfo info = activityManager.getRunningTasks(1).get(0);
ComponentName topActivity = info.topActivity.getClassName();
BTW, the word is that getRunningTasks will be deprecated in Android L, so keep in mind.

Related

Maneuver issues in Turn By Turn Navigation with HERE maps in Flutter

Thanks in advance.
We have to use HERE map's Turn by turn navigation feature in one of our Flutter application, we have added billing in the developer account and have created the necessary keys.
When we try HERE map examples they have provided, we get everything except maneuver instructions that shows the user when to turn right/left/go straight for some distance etc.
I'm new to this and I have no idea how to get this, we never get events on the listener and it only shows updating there, am I missing something ?
this is how it looks right now, Updating...
I think we should be getting the progress here, but we are not getting it here...
_visualNavigator.routeProgressListener = Navigation.RouteProgressListener((routeProgress) { }
Please look into the provided example app. It shows here how to get the maneuver actions.
Your screenshot shows a different app, so make sure everything works with the example app, at first. The app offers to run a simulation mode. This should work. If you run the example app with real GPS updates, you may need to go outside and move to get location updates. This should also work.
If this still does not work, it could either mean that your device has an issue with getting GPS locations. Some iPads, for example, lack support. Or that you have disabled getting location updates. You can cross-check this when trying the positioning_app example from the same repository that shows how to get location updates.
A last point may be to clarify what events you get and what you miss: There are multiple event listeners providing real-time information during guidance - if you have only an issue with maneuvers, then most likely you can solve your issue by following strictly the code of the example app.
Note that previous HERE SDK versions, prior to HERE SDK 4.13.0, only provided empty maneuver instruction texts during guidance when they have been taken from the route instance. Make sure to take this information from the VisualNavigator instead.

VSCode exits while debugging a flutter app

It seems like vscode is trying to present data in the Locals and/or Watch for a large object but after about 10 seconds, it will kill the app and give the message "Exited (sigterm)" in the debug console. I can pinpoint it to one example where I break on a line immediately after this line:
Uint8List inputBytes = Uint8List.fromList(List.filled(100000000, 0));
I can see "Locals" spinning around but nothing happens and then the app terminates. Is there a setting that can prevent this somehow? Maybe it can cap the represented data at a certain length instead of trying to print it all out?
(I believe this is a vscode specific problem because when I repeat these steps in Android Studio, it doesn't have this issue)
Thanks.
This is a bug in the debug adapter. It should know this is a list and fetch a paged view of the elements, but it's currently fetching them all. For me it doesn't crash, but it also doesn't respond within several minutes.
I'm working on a fix that will let VS Code page through the data:
This will ship in an upcoming Dart/Flutter SDK release.

Run background task in Android using MVVM pattern

I working on android app using MVVM pattern. I need to perform some background math calculations in my ViewModel class. This task will read some data from file A and then save results in few other files. And return an Int result when it's done to the MainActivity. My question is how can I achieve this? Searched a lot in the internet but with no success. Any help will be appreciated. Thanks!
A background task in Android means that you want that task to execute when the application is in the foreground/background state. It also means that the task will be executed if the device has been rebooted, or the application has been closed/minimized. Work Manager class is perfect for such a purpose.

NSWorkspace's 'frontmostApplication' doesn't change after initial use

I'm trying to get an update of the current active (foreground) application. Even across computer screens. I'm using this code to try to do it:
print(NSWorkspace.sharedWorkspace().frontmostApplication?.localizedName)
This loops in a command line application every 3 seconds, and prints to console. It works with any application open as active when it first starts up.
However, it does not change from the first app afterwards.
1. Why is it doing this?
2. What is the proper code to make it work?
3. Is there a way to simply get the app name every time the forefront application changes? (preferably in swift or obj-c)
Is there a way to simply get the app name every time the forefront application changes?
Use the NSWorkspace notification NSWorkspaceDidActivateApplicationNotification.

Coded UI - Add-ons

I'm using VS 2013 with CodedUI to automate UI tests on an application that is not built by my client (it's an implementation project). When inspecting the UI Control using inspect or coded UI, I see that the Automation ID keeps changing and I have no real way (beside position based) to capture my controls (the application is developed in Delphi).
So I'm wondering if there exist some library or add-ons (or something not even related to Coded UI and VS) that can help with this? For example some tools that can capture a screen shot of the control and then map it (the screenshot) to an Control Id that I will define and use that to automate?
Wow....I was able to find a way to do what I need using sikuli (http://www.sikuli.org/) checkout this post. Ill actually try it out tomorrow. But I found on the web (link below) that it`s possible.
From Coded UI we can call the sikuli script like that:
Process process = new Process();
ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.FileName = #"D:\Sikuli\ds.bat";
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
(code from) https://answers.launchpad.net/sikuli/+question/232233 , read this post guys!