How can I get my app to open the last edited file after a click in the Windows 10 Timeline? Thanks for the help.
var activityId = Guid.NewGuid().ToString();
UserActivityChannel channel = UserActivityChannel.GetDefault();
UserActivity userActivity = await channel.GetOrCreateUserActivityAsync(activityId);
userActivity.VisualElements.DisplayText = PageTitle.Text;
if (File != null)
{
userActivity.VisualElements.Description = File.DisplayName;
}
userActivity.VisualElements.BackgroundColor = Colors.Black;
userActivity.VisualElements.Content = AdaptiveCardBuilder.CreateAdaptiveCardFromJson(cardText);
userActivity.ActivationUri = new Uri("my-app:navigate?page=" + _index);
await userActivity.SaveAsync();
_currentActivity?.Dispose();
_currentActivity = userActivity.CreateSession();
From the UserActivityChannel Class, there is a GetRecentUserActivitiesAsync method, but it only get the specified number of the most recently engaged user activities sorted by the time each user activity ended. Due to the privacy protecting policy of UWP app, your app can not get the user activities from system or other apps.
Currently, in your app, you can only operate the user activities which your app created. If the file is edited by the system or other app, you can not implement the effect you want. But if the file is operated by your app, you can try to create a user activity which is for opening the file then handle the protocol activated event in your app to open it. Maybe you should see the topic track recently used files.
Related
For my application, when a user login, I display a prompt and ask if the user wants to save the password to keychain. The code saves successfully and I'm able to query the keychain for the stored password completely fine.
My question is how come when I check my phone under Passwords & Acccounts - Website & App Passwords, nothing is displayed.
The bit of code I used to save the key
public static bool SaveValueToKeyChain(string entryKey, string entryValue)
{
SecRecord record = new SecRecord(SecKind.GenericPassword)
{
Account = entryKey,
Label = entryKey,
Service = _keyChainServiceName
};
SecStatusCode resultCode;
SecKeyChain.QueryAsRecord(record, out resultCode);
if (resultCode == SecStatusCode.Success)
{
if (SecKeyChain.Remove(record) != SecStatusCode.Success)
{
return false;
}
}
resultCode = SecKeyChain.Add(new SecRecord(SecKind.GenericPassword)
{
Label = entryKey,
Account = entryKey,
Service = _keyChainServiceName,
Accessible = SecAccessible.WhenUnlockedThisDeviceOnly,
Synchronizable = true,
ValueData = NSData.FromString(entryValue, NSStringEncoding.UTF8),
});
return resultCode == SecStatusCode.Success;
}
I've also followed the solution from here https://developer.xamarin.com/samples/monotouch/Keychain/ and no luck as well. May I get some assistance.
For each application, the keychain has two access zones, a private zone and a public zone (that is, a group mode).
Private area :is a closed storage area. Each application can only operate its own private area. Any data stored in this application is invisible to other programs, and other programs do not have permission to access this private area. (Can be understood as a sandbox with a keychain).
Public area: apple provides a data sharing module between multiple apps developed by the same developer account. It is now limited to data sharing between different apps under the same developer account. This area is another data storage space that is independent of the private area. Achieve common access to some data between multiple applications.
I guess here should be the private area.You can have a try with group mode. Sharing Access to Keychain Items Among a Collection of Apps
I have read multiple articles and SO questions on the Windows Event Viewer. However, I am still unable to accomplish my goal. I have a Windows Service that I'll call "Social". I want to write information from this Windows Service to the Windows Event Viewer. At this time, I'm trying the following:
var message = "Test Log";
using (var sw = File.AppendText(AppDomain.CurrentDomain.BaseDirectory + "test.txt"))
{
sw.WriteLine(message);
}
var eventLog = new EventLog();
eventLog.Source = "Service";
eventLog.Log = "Social";
eventLog.BeginInit();
if (EventLog.SourceExists(eventLog.Source) == false)
{
EventLog.CreateEventSource(eventLog.Source, "Social");
}
eventLog.EndInit();
eventLog.WriteEntry(message, EventLogEntryType.Information);
I added the "test.txt" file just to ensure my code was being reached. That code runs fine. However, I never see my message written in the Event Viewer. In fact, I never see a new Event source get created. I was expecting to go to the Windows Event Viewer and see a new item located at "Event Viewer -> Applications and Services Logs -> Social Media Analyzer". However, I do not see that anywere.
Notably, the "Social" log exists in the event viewer. However, nothing gets written to it. The logs get written to the "Application" log instead. It's almost like the Windows Service is ignoring the fact that I want to write to a specific log.
What am I doing wrong?
eventLog.Log = "Application";
...
EventLog.CreateEventSource(eventLog.Source, "Application");
You're writing your events to the Application Log under "Windows Logs". The events should specify the Source (column) as being "Social Media Analyzer".
If you want to write to a custom log you need something like
EventLog.CreateEventSource("MyEventSource", "Social Media Analyzer");
I am implementing NFC into an Xamarin Forms existing app, initially for a Zebra TC51 (android 6.0).
The app must be pinned so that users cannot access the rest of the device.
In OnCreate, within MainActivity.cs, I have the following lines:
NfcManager NfcManager = (NfcManager)Android.App.Application.Context.GetSystemService(Context.NfcService);
_nfcAdapter = NfcManager.DefaultAdapter;
I then use the following class to receive the tag:
[Activity IntentFilter(new[] { "android.nfc.action.NDEF_DISCOVERED" },
DataMimeType = MainActivity.ViewApeMimeType,
Categories = new[] { "android.intent.category.DEFAULT" })]
public class NfcActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
//SetContentView(Resource.Layout.DisplayHominid);
if (Intent == null)
{
return;
}
var intentType = Intent.Type ?? String.Empty;
if (MainActivity.ViewApeMimeType.Equals(intentType))
{
var rawMessages = Intent.GetParcelableArrayExtra(NfcAdapter.ExtraNdefMessages);
var tag = Intent.GetParcelableExtra(NfcAdapter.ExtraTag) as Tag;
var id = System.Text.Encoding.Default.GetString(tag.GetId());
var msg = (NdefMessage)rawMessages[0];
var tagMessage = msg.GetRecords()[0];
var content = Encoding.ASCII.GetString(tagMessage.GetPayload());
// Call another function with Tag ID and contents here
}
}
}
This code works to retrieve the tag ID and contents, but only if the app is not pinned. If the app is pinned, then the NFC service window can not be displayed, and the tag is ignored.
Can anyone suggest a way around this. I do not want to use the NFCforms NUGET package due to licecing restrictions.
TIA. Pete
Given that you want to have your application running in a kiosk mode like scenario (restricting the user to access the device) a better option could be to use Zebra's Enterprise Home Screen.
In this way you can lock down the device, restricting access to notification, disabling the keyguard and more (if needed). And you can still add other apps that may be useful to the user.
In EHS' configuration you can specify that your app is launched automatically so that you're there as soon as the device is booted.
If you need to have only your app, a better solution than screen pinning maybe installing a Device Policy Controller and use the taskLockMode that has been introduced in Marshmallow for the COSU (Corporate Owned - Single Use) devices.
If still have issue you can try asking the question on Zebra's developer forum.
Disclaimer: I work for Zebra Technologies.
So I have spent the whole night looking like a zombie in the morning trying to figure out how the OS handles an NFC tap for an NDEFLaunchApp Record and I have known the following.
I'm pretty sure that there is a workaround which lets you launch a system app / third party app (if you know the product Id / GUID) from your app. As there are apps in the Windows Phone Store which I have somehow figured out what I've been trying to.
I have come up with the following code:
NdefLaunchAppRecord appLaunchRecord = new NdefLaunchAppRecord();
appLaunchRecord.AddPlatformAppId("WindowsPhone", "{App GUID}");
appLaunchRecord.Arguments = "_default";
// Creating a new NdefMessage from the above record.
var message = new NdefMessage { appLaunchRecord };
// Getting the record from the message that we just created
foreach (NdefLaunchAppRecord record in message)
{
var specializedType = record.CheckSpecializedType(false);
if (specializedType == typeof(NdefLaunchAppRecord))
{
var x = String.Join(" ", record.Payload);
// Getting the payload by GetString gets a formatted Uri with args
string result = System.Text.Encoding.UTF8.GetString(record.Payload, 0, record.Payload.Length);
// result = "\0\fWindowsPhone&{5B04B775-356B-4AA0-AAF8-6491FFEA5630}\0\b_default";
// result = "(null)(form feed)WindowsPhone&{App GUID}(null)(backspace)_default
// So this will be sent to the OS and I believe the OS will then launch the specified app by an unknown protocol
// like xxx://result
// and the app will be launched?
// So is it then possible to somehow call the following:
await Windows.System.Launcher.LaunchUriAsync(new Uri("OUR MAGIC RESULT?", UriKind.RelativeOrAbsolute));
If anyone has / can figure out a way for this, it would be a REAL Service to the WP Community as developers are restricted by Microsoft to open certain settings / apps which are actually needed by those apps. For instance (speech settings, audio settings, about settings, alarms, region settings, date+time);
APPS that possibly have a workaround:
Music Hub Tile (Launches the old Music+Videos Hub)
http://www.windowsphone.com/en-gb/store/app/music-hub-tile/3faa2f9e-6b8d-440a-bb60-5dd76a5baec1
Tile for Bing Vision
http://www.windowsphone.com/en-gb/store/app/tile-for-bing-vision/05894022-e18c-40a4-a6cc-992383aa7ee8
There are reserved uri schemes for bing and zune.
See: http://msdn.microsoft.com/en-us/library/windows/apps/jj207065(v=vs.105).aspx
Those two apps propably use these and have found some undocumented use of the scheme.
If there is an uri scheme that launches any app by guid from within your app, it is hidden well.
Currently you can only launch apps that registered for an uri scheme or file association.
I was wondering if it's possible to call the default navigation application within my Windows Phone 8.1 application. I have an address and I would like for the user to press a button and be able to navigate to that address through the default navigation app. If this is possible, how do I do it?
Thanks for your time,
Johan
You can launch turn-by-turn directions apps using the ms-drive-to and ms-walk-to schemes (depending on the type of directions you want) but you first need to get a geocoordinate for the address that you have. Since you're targeting Windows Phone 8.1, you can use the MapLocationFinder class in the Windows.Services.Maps namespace.
string locationName = "Empire State Building";
string address = "350 5th Avenue, New York City, New York 10018";
var locFinderResult = await MapLocationFinder.FindLocationsAsync(
address, new Geopoint(new BasicGeoposition()));
// add error checking here
var geoPos = locFinderResult.Locations[0].Point.Position;
var driveToUri = new Uri(String.Format(
"ms-drive-to:?destination.latitude={0}&destination.longitude={1}&destination.name={2}",
geoPos.Latitude,
geoPos.Longitude,
locationName));
Launcher.LaunchUriAsync(driveToUri);
the official solution is:
Uri uri = new Uri("ms-drive-to:?destination.latitude=" + latitude.ToString(CultureInfo.InvariantCulture) +
"&destination.longitude=" + longitude.ToString(CultureInfo.InvariantCulture))
var success = await Windows.System.Launcher.LaunchUriAsync(uri);
if (success)
{
// Uri launched.
}
else
{
MessageBox.Show("error");
}
But, there is a problem with this solution.
If you use the nokia programs (HERE), it works fine.
if you want to use waze, you have to add origin.latitude and origin.longitude.
in the MSDN page, They said that it is not necessary, but in fact, you have to write it.
I am already not enable to load moovit but if someone has an issue, it'll help me a lot.