Nativescript detect other Apps - nativescript

Is there a way in Nativescript to detect when another App opens and if so then close it based on a setting flag?
I found a plugin http://plugins.nativescript.org/plugin/nativescript-applist that will list all apps on the phone

NativeScript does not provide such a logic, neither internally nor as a plugin, afaik.
For the Android side you could realize this behavior by writing a background Service which is started at system boot time and periodically checks if apps have been started. Here is an link to an example on SO.
For the iOS side I think this is not possible, imho (correct me if am wrong).

Related

Xamarin Apple Watch Extension - Consuming simple JSON Web Service

I've built a simple Xamarin.forms app which connects to a web service and gets one piece of data and displays it.
I wanted to do the same on an apple watch (targetting a series 2 apple watch) but I just don't understand how it works.
I've added the watch project and the watch extension, created the interface... Got a "refresh" button which changes the value of the label to a hard coded value but I want to get the data from a simple web service on app startup on wake and when button is activated (similar to my xamarin.forms iphone app)
I've tried using the classes that I use on the forms app to get the data but I can't reference them. I've tried using httpclient and that doesn't work.
After googling it appears I am suppose to use a HandleWatchKitExtensionRequest delegate in the phone app to get the data in a dictionary and then display the data. I haven't been able to find any really simple examples of this, but I'm confused because since apple watch version 3 the watch has been autonomous with cell access and therefore it doesn't have the host app necessarily.
So what I'm asking, is can the watch actually consume a web service alone using a xamarin phone app and if so, is there any simple examples because I can't find any (that aren't from 2015).
Sorry if this is vague, or I sound like a newbie (I definitely am a newbie when it comes to xamarin but any pointers or help would be appreciated)
According to https://developer.apple.com/documentation/foundation/nsurlsession?language=objc NSURLSession is available since watchOS 2.0. It is used to download the content from the web and is extensively documented just don't search for watchOS specifically as it is the same on all Apple OS.
But as HttpClient uses NSURLSession it is also available, so, maybe you need to add the reference to System.Net.Http.
When I was last developing for the watch I noticed that HttpClient would never work. I had to use NSUrlSession, so this is what helped me.
Hope this Helps

Chrome app for Windows in the background, using hooks

I want to write an application for Windows that will work in the background and track some hooks, but as yet are not familiar with this development environment would like to know whether it is possible implementation of these tasks into the chrome app. Why chrome app? -Because, the application will interact with the application for android, it's simply easier to develop ...
So my questions are:
1. Chrome app in the background?
2. Chrome app and windows hooks?
If possible please bring a small example, or a manual on the implementation of the goals ...
P.S. Thank you very much for your participation and apologies for mistakes and awkwardness of speech (English is not my native language)!
I am pretty sure you will be unable to use global keyboard hooks in a chrome app. It would allow key loggers and other "bad thing"...
You can read this for more information :https://groups.google.com/forum/m/#!topic/chromium-extensions/yPGeRn9y7Dc

Xamarin.forms long running background work

I'm new to Xamarin platform. I'm developing an application for all three major platforms (WP,iOS,Android) using Xamarin.forms.
How can I sync data with my server in the background -> I need something similar to Android Service. I want to sync the data even when the user goes to a different screen of the app. It would be great if I could continue syncing the data even when the user leaves the app.
Thank you
This is the only solution i have found
http://arteksoftware.com/backgrounding-with-xamarin-forms/
in a few words:
You can't abstract background tasks in Xamarin.Forms because iOS, Android and WP works in a different way. You have to use MessagingCenter to send and receive data from specific implementations in each platform
Have look to this article: http://developer.xamarin.com/guides/ios/application_fundamentals/backgrounding/part_3_ios_backgrounding_techniques/ios_backgrounding_with_tasks/
You could provably be interested in the Transfer Background tasks.
Regards

How to track WinRT applications (in Win32 it was simple)?

In "old" times I created simple tool for Windows users, which tracks what they were doing in the front of computer (where simple activity monitor). I was using Win32 api and functions like GetForegroundWindow, GetWindowThreadProcessId, etc.
Yesterday I installed new Windows 8 and tired to run my program. I got 50% success: for "classic" desktop it works like always:).
For Metro UI I just got one application: WWAHost :( without any details.
So my question is: is there a any way for tracking active application in Metro UI?
Thanks for help
UPDATE:
I'm trying to access Metro UI app from Win32, I know that accessing Metro app from another Metro app is impossible
You see, in WinRT, your application is the top-most application. And when your app is not the top-most application then your threads are suspended and the kernel will not schedule any more operations for your app. End of story.
This means what you are wanting to accomplish cannot be done in WinRT. You are thinking more like a resident app or a service with access to the desktop. Those apps have two advantages. 1) they are always running. And, 2) they have the API to do what you are wanting.
WinRT intentionally puts apps in a sandbox so that the user's experience, performance and battery life are protected. Your scenario and scores more like yours underscore the continuing need for desktop apps. (as long as there is a continuing need for those types of apps ;)).
Sorry, if this is bad news.
As for enumerating other apps. This is also not possible. You cannot know if another app is installed or if it is running. You can call out to another app through protocol activation or file activation or (in a sense) through the share contract. But you are unaware if they get the message and if the user has it installed in the first place. And this is by design.
It is worth mentioning that you can pinvoke to Win32 APIs in your WinRT application. It causes lots of problems and can create a headache to get certified into the store. But even then, not all APIs are open to you. And you will find this particular use case is a non-starter.
I am sure this will not be possible. With Windows 8 'Metro' only a single application is active. All other applications will be in a suspended state whilst the topmost application is running. This makes it impossible to write an application that monitors other applications which are currently executing.
See the numerous articles on the Windows 8 app lifecycle.

Auto-update with Windows Phone 7 and PhoneGap

I'm thinking of developing a Windows Phone 7 application using PhoneGap and have a few questions around functionality available. I haven't developed a WP7 application before nor used PhoneGap so forgive me if some of the answers to these questions are obvious.
Does PhoneGap support the capability to update HTML/JS/CSS/Images hosted by the WP7 app? I imagine it's possible to easily download new content, but whether one can update or extend the existing files PhoneGap is using for the application is not clear. Given that the application functionality will be primarily driven by HTML/JS, I assume it's possible to download updated HTML/JS asynchronously and update the content on the device. In effect, this would be tantamount to updating the application without downloading a new version of the application through the MarketPlace. Assuming this is possible, what are the chances that an application which does this will pass the application verification process?
Are there any specific restrictions/guidelines that one should pay more attention to when developing an application using PhoneGap? I doubt there are but it would be helpful if anyone has any specific advice in this area.
Any help would be appreciated.
1) The short answer is yes.
The long answer is that you will need to do some native (in this case C#) dev to make that happen. I don't know the specifics of PhoneGap, but I know you can call C# methods from the JS. So you would call a method to download the data and store it in the IsolatedStorage, and then maybe have a callback to the JS to let it know it's done. Otherwise, there may be a way to download the image in JS and pass it to the code behind, but unless the PhoneGap guys have specifically catered for this scenario then I highly highly doubt it.
1.2) Yes, this will pass cert just fine. It is not up to MS to determine how/why/when/where you get your content. They don't make any money out of you updating an app, so they won't care whether you work out your own content delivery system.
2) Maybe not exactly the answer you are looking for - but if you make an app in PhoneGap, or any other non-native way, the app-gods will strike you down. To put it simpler, PhoneGap and everything like it is crap. Not the actual framework (I'm sure they put a lot of work into it), but the results. Seriously, the moment you run a non-native app you can tell how terrible it is. I don't know how to stress this enough. It's really worth developing it natively to every platform.

Resources