Minimize Windows 8 Store App while tracking location with GPS - c#

I'm working on a metro app and am having trouble finding how not to show the application.
We recently deployed tablets to our field reps, and need to add gps tracking. GPS is much easier to deal with in the metro libs (it's like 4 lines of code vs. unmanaged) so we're hoping to be able to push a metro app instead of spending time coding a winforms/wpf desktop app (the tablets are full version windows, so it's an option if we can't hide a metro app. I feel like it should be possible though as the start screen tiles update automatically without opening the main program).
In WPF, it's fairly simple to make a window invisible. I'm creating the metro app in wpf, but it uses different libs than desktop and I may just not know how to do it.
In desktop programs, it's fairly simple. You do something along the lines of:
<Page
x:Class = xxxxxxxx
..
Visibility="Hidden">
Unfortunately, with metro, the only options I have are collapsed and visible. Collapsed doesn't seem to have any effect, unless it's just because it's not deployed and visual studio shows it anyway...
So basically I'm trying to figure out if there's a way to start the program minimized or hidden so that it doesn't interrupt the field reps every time it takes their location.

If you really want to make a metro app and want it to run "minimised" you will need to look at background task. To start the background task the user would still need to start the app at least once, futhermore background task have limitation how how often and how long they can run. Also there is a lot of constraint on deploying a windows store app if you cannot publish it in the store.
If your goal is to just have access to GPS through C# apis, the GPS is actually one of the winRT api you can use from the desktop, you can find a tutorial on how to access winRT api from the desktop here
Here is the complete list of winRT api accessible from the desktop (You can find Geoposition class among them).

Have you looked into creating a background task that transmits GPS? The background task can run without the app running.

I am not entirely certain you can voluntarily minimize a Windows Store App on a user's behalf. I see nothing in IntelliSense about it, nor have I found anything online or see any app do it.
However, be aware that deploying the app without using the Windows Store -- sideloading -- requires Windows 8 Enterprise edition computers joined to the domain OR Windows 8 Pro with a sideloading key ($30 per key, purchased in packs of at least 100.) Perhaps a WPF app with unmanaged code is worth the money and effort.

Related

Create non UWP apps in C# and XAML?

Short backstory, I need to create an App for my computing coursework, and since I'm quite the procrastinator I wanted to make an app that shuts down processes that users waste time on.
Therefore I looked up how to make Windows 10 apps and stumbled across Microsoft's own "C# Fundamentals for Absolute Beginners" and "Windows 10 Development" for absolute beginners. I spent over 20 hours watching these videos over the past few weeks.
Now I have designed nearly all the UI in XAML over the past few days and now when working on the Code behind in c# I noticed that System.Diagnostics.Process could not be found, I tried to work out why and eventually stumbled across this answer which made my jaw drop (TLDR it's because it's a UWP app): Missing reference to System.Diagnostics.Process
I do not need my app to run on the Windows Store, all it needs to run on is my computer however messy the solution may be, but I really need access to that class to shutdown processes. I really want to make the app in C# and XAML though and I'm not sure if I can do this whilst having access to the System.Diagnostics.Process class.
I am really running out of time for this project and I can't just change my idea as the problem definition essay has already been marked, etc and that would take forever to rewrite.
I am open to the idea of just writing the application fully in C# if there's really no way I can use XAML without making a UWP app. But I'm not sure what's the easiest way of doing this/what project type so any help would be appreciated.
I feel very angry at Microsoft for not making it clear that "Windows 10 Development for absolute beginners is" actually "Windows Store Development for absolute beginners". I do not want my app on the Windows Store so if I could force reference the process class that would be great!
You need to develop a Desktop app (WPF). With WPF you also use C# and XAML, however you can use all .Net Framework.
UWP (Store apps) need to run in devices like Surface RT (Windows RT), Lumia 920 (Windows 10 Mobile), XBOX and Hololens so they use only a part of the full .Net Framework (they use the .Net Core Framework). UWPs run in a sandboxing so they usually don't have access to system APIs (low level access like create a IP package). In this case you should use WPF.
Your problem is one of the reason, I think that StackOverflow use the tag uwps and win-universal-app.

Windows 10 uwp sticky background service?

I'm trying to convert an Android app to Windows 10 UWP. On android its easy: when boot completed, app service is started. It connects to controller over internet, fetches system state and all data (temp sensors, pumps, valves, etc) and keeps everything in memory. Foreground app can get data as soon as service gets them and display values, charts realtime. After closing foreground app, service keeps working, I still have all system state and I can play alarm sound if needed.
Is it possible to do [almost] same functionality on Windows 10 uwp?
I cannot find a way to start service with windows. Service started with foreground app is stopped when foreground app is closed. SocketBackgroundTask keeps connection perfect, but system state is lost with service.
Should I save system state to file and analyze all data after each renew? Data flow varies from once in 10 minutes to ~10 per second.
Or should I forget Windows 10 as limited platform?
I am designing a similar piece of sensor control software, and I have found UWP/Win10 to be limiting. We ultimately resorted to using Assigned Access to keep the app permanently in the foreground.
Assigned Access
Assigned access assigns an app to an account. So when Mr. Bob logs in, the app starts full-screen, and it cannot be closed, and if it crashes, it is restarted.
Note that the only way to access other parts of the system is to hit ALT-CTRL-DEL and log in as a different user. That might be bad for some, but if you have critical process monitoring going on, then it's probably a good thing that the user can't mess about with the system or quit the app.
It's also quite simple to implement, you only need to add a declaration to the app manifest, and you need Win10 Pro or Higher.
Windows IoT
You could also look at Windows 10 IoT, when you deploy an app to it, it does pretty much the same thing. However the range of hardware is quite limited, and many of them aren't fully functional yet - RPi suffers from SDcards being inherently unreliable, and lack of graphics acceleration. Dragonboard lacks driver support for resolutions other than 720p, etc. https://developer.qualcomm.com/forum/qdn-forums/hardware/iot-development-platform/29652
Extended Execution
In addition we have experimented with using extended execution, which lets the app run in minimised state, potentially indefinitely. I have mixed feelings about it. Although the app will keep running most of the time, but if the OS is struggling for resources, the app will get suspended and won't be restarted until the user switches back to it.

Limitations of Background agents and cross-app access in Windows Phone 8.1

Basically I'm working on a project where I need to:
Have a background service that can receive small packets of data from a paired bluetooth (BLE to be precise) device.
Based on the received data, perform various functions on built-in Windows apps (media player, camera, phone dialler etc.) like switch to the next/previous track, alter volume level, take a picture, call a number etc (basically control built-in apps).
Now there was an extensive hardware part to this project which I began working on assuming that Windows Phone would offer the same level of flexibility as Android and that the aforementioned tasks could be easily performed, but now that I searched around a bit and saw the constraints for Background Agents I was dumbfounded to say the least, and by the looks of it the kind of functionality I'm looking for is completely unavailable in WP APIs. And while I couldn't find a definitive answer regarding the second task I wish to perform, I'm assuming the sandbox-style environment which WP apps run in will prevent that from happening as well.
Is there ANY way the above mentioned tasks can be performed with a Windows Phone 8.1 app or even something close?
Short answer: no.
Long answer: for various reasons Windows Phone is designed to provide ultimate control of system functions to the user. In general, all actions have to be user-initiated; even the background tasks have to be ok'd at some point. Reasons include battery life, stability, predictability.
A related policy is that no app may interfere with the operation of another. The only way apps can communicate is via launcher tasks or sharing protocols. Using these you can do things like prompt the user to dial a number.
Out of the tasks you list, the only one I can see being a feasible project is if you write your own camera app or music app that integrates with your Bluetooth device. It's either/or though, you won't be able to make a one-stop app.

Is it possible to make a WinRT service

Since WinRT have unique capabilities, I wonder if it were to make a Windows Service that is targeted to WinRT? If it were not possible, is the workaround to make an invisible WinRT/Metro application possible?
Thanks a lot.
No is the correct answer. A metro application executes inside the Metro shell and inside an execution container that creates a sandbox away from system resources, including services. For this reason a metro app cannot access a local service. Similarly, for this reason, a metro app cannot be a service.
Background tasks and push notifications through Windows Notification Services are the only way for a metro app to interact with the user while not active. Otherwise, when the application is not active (not visible), all of its threads are suspended (unlike a service).
As for background tasks, their activity is constrained identically to a metro app and limited to a single CPU second every 2 hours (there is one exception). Push notifications can execute more frequently, but are only capable of updating a tile or raising a toast notification.
The intent of a metro application is different than a traditional desktop application:
Metro applications are architecture independent (run on intel or arm). Metro applications are touch-reach, built for touch screens. Metro applications are fully hardware accelerated. Metro applications leverage the next gen hardware that certified devices offer, including unprecedented battery life. Metro applications are the only applications delivered by the Windows store.
Look, choosing a metro application does mean to concede some of the unlimited power of desktop applications. However, the gains are significant, too.
Nope this isn't possible (wither the service, or the "invisible" metro application).
You can run background tasks that may do what you are after, but without understanding your problem I couldn't say.
It depends on what you want to do.
WinRT is an API and can be accessed from Metro (Windows Store) Apps and from Desktop/C# apps.
However not the full API is exposed - see what you are allowed to access here: http://msdn.microsoft.com/en-us/library/windows/desktop/hh920511%28v=vs.85%29.aspx
Hanselman shows how to add a ref to WinRT:
Edit the csproj:
<PropertyGroup>
<TargetPlatformVersion>8.0</TargetPlatformVersion>
</PropertyGroup>
Then add a reference to Core/Windows.
http://www.hanselman.com/blog/HowToCallWinRTAPIsInWindows8FromCDesktopApplicationsWinRTDiagram.aspx

Accessing other processes in Win8 Metro-style app

I am trying to build a Windows 8 "metro-style" app that will operate as a "app killer". For those of you who have used Win8 (Tech Preview) you'll notice that once you open a metro-style app you cannot close it (without going into Task Manager and ending the process).
My challenge is that I cannot access 'System.Diagnostics.Process' from my metro-style app, nor do I know if there is an comparable alternative within the WinRT. I also thought of building a separate app that hosts a service for my metro app to interface with, but I'd like to do this with a single app.
Fundamentally, I am looking for a pattern for building Metro-style apps that leverage .NET 4.0 components, specifically to be able to enumerate and kill other processes running on the PC.
CLARIFICATION: I am less concerned with this specific application than I am with access that type of .NET functionality within a Metro-style app
Thanks
To your specific question, this functionality is not available. Apps are not allowed to interact or interfere with other apps.
To answer your more general question, the APIs available to Metro style applications is limited compared to what is available to desktop applications. C# has a subset of the .Net library available, much like Silverlight does. The same is true for C++ where a subset of the desktop Win32/COM APIs are available.
From what I understand (watching Build2011 videos) a Metro App won't be able to do that...
Interaction between processes is severally limited to specific Contracts (the charms on the right: Search, Send-to).
Think Phone, not Desktop.
You might be able to build a non-Metro Win8 app though.
Don't waste too much time on this. I expect that in a beta a close option (perhaps even a charm) will be included. Until then use a keyboard Alt-F4 or the Task Manager
C++:
Window::Current->CoreWindow->Close();
or
Window::Current->Close();
I haven't explored the difference between these two (more precisely, I don't know how CoreWindow differs from Current. I could assume though...
I'm using an Oracle VBox with Win8 on my Win7 machine to develop a C++ Metro App using VS 11. I used both of the above methods. I verified in Task Manager the app was not running on both Win8 and the Simulator.

Categories

Resources