As I understand the share contract for Windows 8, when I provide some information in a share contract, I should see any installed apps that are capable of consuming that information. I have the following code:
request.Data.SetText(myString);
However, when I select Share, I'm presented with only the mail app. What I'm after is a way to launch a work processor (e.g. MS Word) from my app. Is there something else that I need to do to mark the data I'm sharing as "compatible" with Word? Or is this just not possible because Word is a desktop app?
You cannot use the share contract to move data from a Windows Store app to a desktop app. If you look at Sharing and Exchanging Data - http://msdn.microsoft.com/en-us/library/windows/apps/hh464923.aspx - it states, "One advantage the clipboard has over sharing is that it's the only way to move data from Windows Store apps to the desktop, and vice versa."
It's true that you can't share data to desktop apps, also the target app needs to register itself as a share target for sharing to work.
You mentioned though that you wanted to launch Word. This is possible using the Launcher class if you have a Word file that you need to open:
var file = await ApplicationData.Current.LocalFolder.GetFileAsync("Test.doc");
await Launcher.LaunchFileAsync(file);
Related
Is it possible to get a handle on a file which is opened by any external app via my application?
Using Cloud-Storage Apps as an example, I would like to track changes to a file opened via the Storage-Provider App, so the manipulated file can be uploaded again afterwards.
There are two possible answers here, depending on what kind of app you're implementing.
For general tracking purposes, you can try using the ContentsChanged event of the StoreFolderQueryResult/StorageFileQueryResult classes within Windows.Storage.Search. That is, you create a file or folder query for what you want to watch, and then register an event handler. Generally speaking, this works well for stuff on the local file system; it's not guaranteed if you're trying to run a query on files/folders whose backing store is elsewhere.
The subject is too detailed to be described here, but you can refer the "File and Folder Queries" in Chapter 11 of my free ebook Programming Windows Store Apps with HTML, CSS, and JavaScript, Second Edition, page 607. Even though I focus on JS as a language, the discussions of WinRT APIs like this are useful when working in any language...plus the ebook is free so there's nothing to lose.
The other mechanism would be useful if you're implementing an app that provides the interface to a cloud storage backend, like the OneDrive app that's part of Windows. In this case you'd want to use the CachedFileUpdater contract. See Appendix D, page 1288, of my aforementioned book.
Our Team is trying to build multiple Windows 8 Store Apps for an enterprise.
How do we maintain a common session for all apps(where we store data which need to be shared)?
How do we enable direct interaction between the apps developed i.e. sharing objects or string(JSON) among the apps?
There is not built in way to do this. Realistically you probably have three options to share data between applications.
The first is to use the cloud / web services. This makes the most sense as you'd have full control about what is shared, authentication etc. Using libraries such as SignalR could let you add real time functionality between the applications as well as multiple users.
The Share contract, by using custom data formats you could enable the apps to share specialised data between each of them. This can make sense if the user has a set of data they want to send to another application to enable a quick piece of workflow as the Share target is only partially launched. This also is limited in that it's enabled by user action.
Custom protocol handlers, by giving each app it's only protocol my-custom-app:///some-action?param1=value etc then you can pass data between apps, note this launches the app in question when you launch that uri. This would be best for more longer running scenarios.
I'd suggest a combination of all three depending on the user action. Cloud services to store the data for the user and then a mixture of Share and Protocol to enable to the user to smartly move the apps seamlessly.
Here exactly the same question as yours. In short: there is no such ability. Sometimes I think that it will be easier to share data via Internet that in device.
I'm developing an app on the Windows desktop so Win7 users have the app, but for Win8 users I'm also developing a Metro app.
My problems are,
if a user opens a file (e.g. "Blue.xyz"), I want an app to come up that asks which environment to open it in, but first it has to find all the apps that can open the file and display them.
Then I need to pass the data as a parameter to the app Chosen.
In the .NET framework 4.5.1, I can't find the System.GetEnvironmentVariable command so I can create a common location for both environments to access. These are my options:
Comment for clarification.
Regarding your 3rd question, the function is there, just now showing on MSDN page:
After having an inspiration, I found some code that can get pretty close to what I want.
Dim filepicker As New Windows.Storage.Pickers.FileOpenPicker
CommonFolder = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary
I should just be able to tack this on the end after that:
CommonFolder.Replace("\Documents","")
and it should give me "C:\Users\someuser" and then I can add "\MyAppStorage"
Thanks for all the help though! This code isn't very clean, so feel free to edit and make it better!
I am new to Windows Phone 8 development. Would like to know if there is a way to store a file received to a particular location on device. It could be using an API, through ActiveSync or MDM.
Thanks in advance.
Windows Phone 8 doesn't allow for free-for-all direct access to the user's hard-drive to read or write files. You'll have to use usecase specific APIs depending on the type of media you're trying to store. I've answered a similar question in the past regarding WP8's read-write access for known file types # Windows Phone 8: Media file access
A few highlights:
Your app can use IsoStore to read & write files only accessable to your app. See IsolatedStorageFile API or ApplicationData.Current.LocalFolder API for that.
You can store pictures using MediaLibrary.SavePicture or MediaLibrary.SavePictureToCameraRoll methods.
You can store songs using MediaLibraty.SaveSong method.
Other then those APIs I'm not familiar with any other file write APIs to the OS from the top of my head. You can probably use a remote server, but that's pretty much it.
Can someone provide me an easy explanation of the difference between Contracts and Extensions in Windows Store Apps?
I have read this article: http://msdn.microsoft.com/en-us/library/windows/apps/hh464906.aspx, however, in some of the examples it isn't clear why one is a Contract and not an Extension and vice-versa.
Thank you.
When you "extend" a native function of Windows 8, like taking pictures or picking files - then your app is an "extension". It is more a category of apps based on their function. Contracts, in contrast, are just leveraging the charms and device capabilities. //End
To summarize:
Many apps will use contracts.
Few (very few?) apps will be extensions.
A contract is an agreement to consume and/or supply data in a specific format, often between apps as is the case with the Share contract. Contracts result in activations and are most often invoked directly from the Charms Bar (Search, Share, Settings, PlayTo) or the Start Menu (Launch).
An extension is an agreement between your app and the operating system. It is a way to extend the OS functionality with your app. AutoPlay for example allows the OS to launch your app when an item of a particular type is selected. Camera Settings will allow you to customize the camera settings provided by the OS when the user is configuring the camera.
So in general I think of contracts as app-app or app-user and extensions as app-OS, but it is obvious some are gray areas (like File Picker, I would consider that more an extension than a contract, but it is categorized as a contract).
A contract is like an interface with the common windows 8 charm bar features such as share & search.
You can make you app available to either provide to, or receive from these contracts.
An extension is where you might say, my app id used as a third part component, or as the link suggests says your app handles files of a particular extension and presents itself as a handler perhaps for that file type