I have access fine and coarse location checked in the manifest file and first time the application runs on the android emulator (Android_Accelerated_x86 (Android 7.1 - API 25)) it logs the latitude. But if I deploy the app for the second time, third time and so on it runs endlessly even though the timeout is 10000 ms (no Exception thrown). If I close and open the emulator and deploy the app again it works again and so on. Any ideas on how to fix this?
public static class NetworkingTools
{
private static IGeolocator locator = Resolver.Resolve<IGeolocator>();
static NetworkingTools()
{
locator.DesiredAccuracy = 50;
locator.StartListening(2000, 0, true);
GetPosition();
}
public async static void GetPosition()
{
var position = await locator.GetPositionAsync(10000);
System.Diagnostics.Debug.WriteLine(position.Latitude);
}
}
Please note the remark they have on their GitHub page:
NOTICE: This project is no longer maintained. It may not work with newer versions of Xamarin.Forms.
I think it is unwise to integrate this into your project if you have the choice. Instead have a look at the Geolocator Plugin by James Montemagno.
I was having the same issue, but apparently that's the way the emulators work. There is no problem with the code, you have to open the EMULATOR Settings, go to Location and Click SEND.
More details here:
Getting Location on Android Emulator more then once
Related
I'm having trouble retrieving my in-app products for my Android Xamarin app. I'm using the Plugin.InAppBilling nuget package (version 4.0.1-beta) to implement the billing functionality. To begin, I following the documentation which states the following:
Android Testing:
- You MUST use a physical device. Emulators do not work.
- Ensure you have app in Alpha/Beta with the NuGet installed. This will add “com.android.vending.BILLING” permission for you
- Create an IAB product, make sure it is published and active
- Add a test account to the app, ensure it is the main account on device, and that account is opted-in as tester
- Validated your version code and number in your development environment match what is in the Play store.
- You MUST sign the APK even in debug mode.
Therefore I have the following specified in my Android csproj:
This is my aab package in the Play Console in Internal Testing with 2 testers:
Here are the testers also added as Licensed Testers:
However, using the following code doesn't return any products from the call to GetProductInfoAsync:
private partial async Task FetchProductDetails(bool isAdsDisabled)
{
var billing = CrossInAppBilling.Current;
try
{
//You must connect
var connected = await billing.ConnectAsync();
if (!connected)
{
//Couldn't connect
return;
}
var products = await billing.GetProductInfoAsync(ItemType.InAppPurchase, productIds);
.
.
.
}
catch (Exception ex)
{
...
}
finally
{
await billing.DisconnectAsync();
}
}
Anyone know if I missed a step? Something missing?
License Response. You have Licensed. I've always used RESPOND_NORMALLY.
I'm not using the plug in as I wrote my own using xamarin.android.google.billingclient\3.0.0. All working here.
Well, what happens when you debug GetProductInfoAsync?
As mentioned in the documentation, you need an app in Alpha/Beta. Internal testing will not work.
We're building a multi-platform (desktop- and tablet-computers) application targeting Windows 8.1 as well as 10. As we process spatial data, we offer the user the possibility to use his current location using the device's gps receiver. To allow easy adaption to the (hardware) environment, we placed the gps-logic (including the API-calls) into an external assembly that we load based on a configuration.
Recently we discovered some problems with the gps-module using the Geolocator from Windows.Devices.Geolocation-API under windows 10 (but previously running without problem on Windows 8.1), not delivering any location. Further investigation and RTFM showed up, that - under Windows 10 - we were obliged to call the RequestAccessAsync before calling for the location.
As the RequestAcessAsync-method isn't available in Windows 8.1, we decided to create a new assembly, targeting Windows 10 (and then easily being bound/used through our configuration), what worked quite well:
public Win10GpsProvider()
{
RequestAccessAsync();
}
public async void RequestAccessAsnyc()
{
//next line causes exception:
var request = await Geolocator.RequestAccessAsync();
switch (request)
{
// we don't even get here... :(
}
}
Only up to running into an exception that gets thrown as soon as the RequestAccessAsync-method is being called (in UI-thread), stating that the call has to be made in the context of an app container.
This operation is only valid in the context of an app container. (Exception from HRESULT: 0x8007109A)
The exception occurs on both, desktop as well as tablet (verified through remoted debugging).
Searching a bit more, adding the "location" as a required capability to the package.appxmanifest may help:
<Capabilities>
<Capability Name="location"/>
</Capabilities>
That's where we're actually stuck at the moment:
We don't have an UWP-application (and actually don't want/can change that, as we're targeting Win 8.1 as well and have a defined deployment workflow including setups)
We can't get the assembly run without exception as there is no UWP app/context
Is there a way to get a separate assembly that targets the Windows 10 version of the Windows.Devices.Geolocation-API and can be called/loaded by a Win32-application?
AFAIK, it is not doable to call RequestAcessAsync method and make it work in Windows 8.1 app.
But if you directly use Geoposition in windows 8.1 project, and run this windows 8.1 app on windows 10 device for example on desktop, the permission request dialog will also be displayed:
So there should be no problem if you don't call RequestAcessAsync method in windows 8.1 app.
But in case user choose "No" in this permission request dialog, we can catch the exception and launch the Setting page to force user to enable the Location setting for this app for example like this:
private Geolocator _geolocator = null;
private uint _desireAccuracyInMetersValue = 0;
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
try
{
var _cts = new CancellationTokenSource();
CancellationToken token = _cts.Token;
_geolocator = new Geolocator { DesiredAccuracyInMeters = _desireAccuracyInMetersValue };
Geoposition pos = await _geolocator.GetGeopositionAsync().AsTask(token);
// Subscribe to PositionChanged event to get updated tracking positions
_geolocator.PositionChanged += OnPositionChanged;
// Subscribe to StatusChanged event to get updates of location status changes
_geolocator.StatusChanged += OnStatusChanged;
}
catch (Exception ex)
{
await Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-location"));
}
}
This code in windows 8.1 project works fine both on windows 8.1 device and windows 10 device. And I don't quite understand what is your Win32-application for here?
I'm trying to use this MediaCapture API sample:
https://code.msdn.microsoft.com/windowsapps/Media-Capture-Sample-adf87622
but when I press Start Record to record to a file, this line never returns:
await m_mediaCaptureMgr.StartRecordToStorageFileAsync(recordProfile, m_recordStorageFile);
And no error is thrown. This computer is a Cyberpower PC. The sample DOES work on my other windows 10 computer (a mac mini) though. I thought maybe it was a codec issue but can't find any information on installing codecs so maybe that is not it--not sure. Thank you for any help or information.
Additional Info: Creating a profile like this works:
MediaEncodingProfile recordProfile = null;
recordProfile = MediaEncodingProfile.CreateWmv(Windows.Media.MediaProperties.VideoEncodingQuality.Auto);
But calling CreateMp4 instead of CreateWmv does not work.
My suspicion is that there's something wrong with your particular installation's encoders. If you can upgrade to Windows 10, with Visual Studio 2015 you can develop universal apps. The same code should work without an issue.
The Application and Voice commands are not shown in Cortana when typing "what can I say?"
I am attempting to use Voice Commands in the Foreground with Cortana and am running the Cortana Voice Command Sample and have been unable to get Cortana to show the application or Open / Perform Voice commands for the application named "AdventureWorks".
I am using the Cortana Voice Command Sample which I am running from Visual Studio 2015 locally on Windows 10 in debug. According to this link this should create an unpackage version of the sample on my local machine that I should be able to see from the Start screen which I cannot.
I have activated Microphone under the capabilities of the app and included the en-GB resources.resw file and changed the Package.appxmanifest to the Default language of en-GB to match in an attempt to ensure that Cortana's language matches with the application to eliminate that as a potential issue.
Here is the link showing that a unpackaged version of the application should be visible in the Start screen after running the app from VS (with or without debugging):
How to deploy a Metro App to the Desktop?
Cortana Voice Commands Sample:
https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CortanaVoiceCommand
Note:
The application is standard apart from me including the en-GB resource file, changing the package.appxmanifest location to en-GB and adding Microphone to the capabilities of the application. Developer mode has also been enabled on my pc.
Update: There are no exceptions happening when adding the vcd.xml to the VoiceCommandDefinitionManager.. It looks like it should be working..
I have also noticed that when running the sample I cannot see the picture of London or the microphone icon saying "listening" like in this video: https://channel9.msdn.com/Events/Build/2015/3-716 at 04:16
At this time google searches for "application not showing in Cortana" does not show any useful results.
Has anyone else had any luck getting this sample to work? or similar issues? Also are you using the en-GB version?
Any help or ideas would be appreciated
I have successfully tested the AdverntureWorks sample using en-US.
Also I have developed another sample regarding Cortana Foreground.
Basically I have created the VCD and then installed it:
protected async override void OnLaunched(LaunchActivatedEventArgs e)
{
...
// Install the VCD
try
{
StorageFile vcdStorageFile = await Package.Current.InstalledLocation.GetFileAsync(#"HomeControlCommands.xml");
await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcdStorageFile);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("There was an error registering the Voice Command Definitions", ex);
}
}
And then handled the activation:
protected override void OnActivated(IActivatedEventArgs e)
{
// Handle when app is launched by Cortana
if (e.Kind == ActivationKind.VoiceCommand)
{
VoiceCommandActivatedEventArgs commandArgs = e as VoiceCommandActivatedEventArgs;
SpeechRecognitionResult speechRecognitionResult = commandArgs.Result;
string voiceCommandName = speechRecognitionResult.RulePath[0];
string textSpoken = speechRecognitionResult.Text;
IReadOnlyList<string> recognizedVoiceCommandPhrases;
System.Diagnostics.Debug.WriteLine("voiceCommandName: " + voiceCommandName);
System.Diagnostics.Debug.WriteLine("textSpoken: " + textSpoken);
switch (voiceCommandName)
{
...
}
}
}
The detailed process is described here
I had exactly same issue.
Make sure you have microphone capabilities turned on for your Package.appxmanifest otherwise it doesn't work.
Tu turn it on select your Package.appxmanifest in Solution Explorer go to Capabilities and check Microphone.
More info: http://jamescroft.co.uk/blog/universal-windows-8-dev/how-to-get-your-apps-cortana-ready/
Hope this helps,
damtur
I had the same problem as you, as noted by DevEnitly, if your region is set, for example, to UK and in your VCD file your CommandSet's language is en-US it won't work, simply changing the CommandSet's language to us-gb (or whatever language fits your region) should do the trick (it did for me), also note that, if you want to support different languages you should add more CommandSets. Hope this solve your problems.
I have an exception only in one PC, in others all work fine, anyone know wher it is comming from?
dditional information: Requested Windows Runtime type
'Windows.Media.Capture.MediaCapture' is not registered.
This exception is showing only in modern style apps (windows strore app) in windows 8.1. In WPF or Windows Form apps camera works fine. Code is fine, because in other pc work great:) i install system one more time, but the exception still showing up.
Looking at Microsoft's Windows Universal Samples (https://github.com/Microsoft/Windows-universal-samples/blob/e13cf5dca497ad661706d150a154830666913be4/Samples/SpeechRecognitionAndSynthesis/cs/AudioCapturePermissions.cs#L35) shows following piece of code
try
{
// Request access to the microphone only, to limit the number of capabilities we need
// to request in the package manifest.
MediaCaptureInitializationSettings settings = new MediaCaptureInitializationSettings();
settings.StreamingCaptureMode = StreamingCaptureMode.Audio;
settings.MediaCategory = MediaCategory.Speech;
MediaCapture capture = new MediaCapture();
await capture.InitializeAsync(settings);
}
catch (TypeLoadException)
{
// On SKUs without media player (eg, the N SKUs), we may not have access to the Windows.Media.Capture
// namespace unless the media player pack is installed. Handle this gracefully.
var messageDialog = new Windows.UI.Popups.MessageDialog("Media player components are unavailable.");
await messageDialog.ShowAsync();
return false;
}
So you have to install "Media player components".
I just had this issue with Windows 10. I had installed the N edition, but it looks like since it is missing Media Player, the classes related to MediaCapture are also missing.
As Hans Passant mentioned, the MediaCapture class was not registered in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsRuntime\ActivatableClassId.
I reinstalled Window 10 (not the N edition) and now the class is registered.