Xamarin.Forms Map Pins - google-maps

How can i implement click event for Map Pins in Xamarin.Forms ?
I tried Something like this :
var pin = new Pin
{
Position = _testPosition,
Label = string.Format("Latitude: {0},Longitude: {1}", _curentPosition.Latitude, _curentPosition.Longitude)
} ;
pin.Clicked += (sender, args) =>
{
DisplayAlert("Tapped!", "Pin was tapped.", "OK");
};
But it doesn't worked !
Anyone have idea with this !
Thanks in Advance.

Does the code compile but doesn't fire the event or is it not seeing the clicked property at all?
Please check which version of Xamarin.Forms you are using.
The "Clicked" event was added to the xamarin.forms map control in version 1.3.0, but has only actually been working since version 1.4.2-pre2
The usage is exactly the same as you listed in your example.
Check that your packages and environment are up to date.
Some users are reporting issues with the clicked event not firing.
If this happens to you, use appropriate Xamarin support channels to report/vote on the issue to get fixed.
If you can't get it to work and can't wait for Xamarin to fix the issue, you can write custom renderers for the map control and access the native API to handle the tap event.
For more information on this, search for "Xamarin.Forms Custom Renderer"

Related

Distriqt GameServices ANE - Apple Game Center Problem

I'me developing a game in AS3 AIR and I'me using Distriqt GameServices native extension.
The problem is that I can not sign in to Apple Game Center.
In the documentation, it's stated that: If Google Play Services aren’t available then you won’t be able to use the functionality in this extension.
And there's a code snippet:
var result:int = GoogleApiAvailability.instance.isGooglePlayServicesAvailable();
if (result != ConnectionResult.SUCCESS) {
if (GoogleApiAvailability.instance.isUserRecoverableError( result )) {
GoogleApiAvailability.instance.showErrorDialog( result );
} else {
trace( "Google Play Services aren't available on this device" );
}
} else {
trace( "Google Play Services are Available" );
//init here
}
That sounds odd to me because Google Play Services are not available on iOS, naturally.
I've tried to skip this step and initialize the service without checking GoogleApiAvailability. But I'm getting this message after a successful initialization and then calling signIn() method:
The requested operation could not be completed because local player has not been authenticated.
That sounds odd too, because this is the authentication method itself!!
I'm almost sure that my setup is correct. And the extension is working fine on Android.
GameServices ANE Version: 5.0.011
Any help is appreciated,
Thanks
Ah, actually that had nothing to do with the Distriqt GameServices, so sorry.
The message "The requested operation could not be completed because local player has not been authenticated." was coming from iOS meaning the Game Center is not activated on the device.
Switching on Game Center in the device (settings-> gamecenter) solved the issue.

XCode 7 UI Testing: Dismissal of system-generated UIAlertController does not work

I have a UI test which involves the dismissal of a system-generated UIAlertController. This alert asks the user for the permission to access the device's calendar. The objective of the test is the behaviour after a tap on the OK button:
1 let app = XCUIApplication()
...
// this code was basically generated by the recording feature of XCode 7
2 app.alerts.elementBoundByIndex(0).collectionViews.buttons["OK"].tap()
Now, instead of clicking the OK button, line 2 makes the simulator tap onto the first button which happens to be the Cancel button...
Additionally, I found out that the testing framework does not accurately recognize the appearing alert. So if I check the current count of alerts I always get 0:
// ...tap...
let count = app.alerts.count // == 0
This also happens if I use an NSPredicate for the condition and wait for several seconds.
Is it possible that UI tests do not work reliably with system-generated alerts? I am using XCode 7.0.1.
Xcode 7.1 has finally fixed the issue with system alerts. There are, however, two small gotchas.
First, you need to set up a "UI Interuption Handler" before presenting the alert. This is our way of telling the framework how to handle an alert when it appears.
Second, after presenting the alert you must interact with the interface. Simply tapping the app works just fine, but is required.
addUIInterruptionMonitorWithDescription("Location Dialog") { (alert) -> Bool in
alert.buttons["Allow"].tap()
return true
}
app.buttons["Request Location"].tap()
app.tap() // need to interact with the app for the handler to fire
The "Location Dialog" is just a string to help the developer identify which handler was accessed, it is not specific to the type of alert. I believe that returning true from the handler marks it as "complete", which means it won't be called again.
I managed to dismiss access prompt for contacts like this:
let alert = app.alerts["\u{201c}******\u{201d} Would Like to Access Your Contacts"].collectionViews.buttons["OK"]
if alert.exists
{
alert.tap()
}
Replace asterisks with your app's name. It might work the same for calendar.
This is what I ended up using to get the prompt to appear and then allow access to Contacts:
func allowAccessToContacts(textFieldsName: String)
{
let app = XCUIApplication()
let textField = app.textFields[textFieldsName]
textField.tap()
textField.typeText("aaa")
let alert = app.alerts["\u{201c}******\u{201d} Would Like to Access Your Contacts"].collectionViews.buttons["OK"]
if alert.exists
{
alert.tap()
}
textField.typeText("\u{8}\u{8}\u{8}")
}

Detect if user Idle on windows universal app

I'm developing a class library for windows 10 universal apps (mobile and desktop device families only). I need to invoke an event if the user has been idle(no touch, mouse move, key press etc) for x number of seconds. This method can be used to solves this problem on android. But I couldn't find a solution on windows UWP.
Is there an API available in UWP to achieve this?
You can detect global input with various events on the app's CoreWindow:
Touch and mouse input with CoreWindow.PointerPressed, PointerMoved, and PointerReleased.
Keyboard input: KeyUp and KeyDown (the soft keys) and CharacterReceived (for characters generated via chords & text suggestions)
Use these to detect the user is active and idle out if it goes too long without any of these events.
I know this is really old question, but I think you can now get to same result with RegisterBackgroundTask
Just set:
new TimeTrigger(15, false) //For time trigger
Link
new SystemCondition(SystemConditionType.UserNotPresent)) //And so you want to know so user is not present
Link
Example usage in App.xaml.cs:
var builder = new BackgroundTaskBuilder();
builder.Name = "Is user Idle";
builder.SetTrigger(new TimeTrigger(2, false)); //two mins
builder.AddCondition(new SystemCondition(SystemConditionType.UserNotPresent));
// Do not set builder.TaskEntryPoint for in-process background tasks
// Here we register the task and work will start based on the time trigger.
BackgroundTaskRegistration task = builder.Register();
task.Completed += (sender, args) =>
{
//Handle user not present (Idle) here.
};

Show select file dialog in flash 15 error

I'm using this library https://code.google.com/p/swfupload/ to provide uploading files functionality.
But it turned out it stopped working with the latest version of flash player (15).
For now I found out that code responsible for displaying select file dialog is not working,
it is just:
this.fileBrowser = new FileReference();
this.fileBrowser.browse();
and line this.fileBrowser.browse(); doesn't work.
I'm not providing full code snippet.
Are there some more restricted ways of invoking such thing in new flash version?
Edit:
I'm providing more code maybe somebody know what is wrong here?
try {
ExternalInterface.call("console.log", "invoking browse()");
this.fileBrowserOne.browse();
} catch (ex:Error) {
ExternalInterface.call("console.log", ex.toString());
this.Debug("Exception: " + ex.toString());
}
The function is invoked as a result of mouse click event, this.fileBrowserOne.browse() return true that should indicate that select file dialog opened correctly.
I can see all logs lines before and after method invocation. But the dialog is not showing up.
It happens only with Flash 15.0.0.152 and FF 32.0.2.
I haven't found any report on Internet about this issue but I cannot believe I'm the only one.

How to get appWindow from Chrome.app.window.create

I am trying to write a chrome.app that is able to open and close chrome.app windows on both displays of a system that is configured with two monitors. When launched, the chrome application establishes a socket connection with a native application running on the same computer, I also open a hidden window via chrome.app.window.create to keep the chrome application up and running. The native application then reads a configuration file and then sends a series of ‘openBrowser’ commands to the chrome application via the socket.
When the chrome application receives an ‘openBrowser’ command, the chrome application makes a call to the chrome API method chrome.app.window.create, passing the create parameters AND a callback function. A code snippet is below:
NPMBrowserManager.prototype.openBrowser = function (browserId,htmlFile,browserBounds,hidden,grabFocus)
{
var browserManager = this;
var createParameters = {};
createParameters.bounds = browserBounds;
createParameters.hidden = hidden;
chrome.app.window.create(htmlFile,createParameters,function(appWindow)
{
// Check to see if I got a non-undefined appWindow.
if(appWindow !== null)
{
browserManager.browsers.push({"browserId":browserId,"window":appWindow});
console.info("NPMBrowserManager.openBrowser: Added browser, id =" + browserId + ", count =" + browserManager.browsers.length);
}
});
}
Unfortunately, the ‘appWindow’, parameter passed in the create callback is always undefined. I suspect it has something to do with the fact that the method openBrowser is itself being called by another method that processes commands received from the native application. However, the window opens exactly here and when I want to to, I just can’t seem to cache away any information about the new window that can be used later to close or move the window.
I want to be able to cache away the appWindow so that I can close or modify the created window later on in the workflow.
As a side note, I’ve noticed that appWindow is NOT undefined if I call the openBrowser method from within the callback that is associated with the chrome.app.runtime.onLaunched event. I suspect it has something to do with the current script context. I was not able to find any chrome.app documentation that goes into any detail about the chrome app architecture.
I would GREATLY appreciate it if anyone out there can explain to me how I can get the appWindow of the window that is created in the chrome.app.window.create method. By the way, I have also tried calling chrome.app.window.current to no avail… Very frustrating!!!
I’d also be interested in any documentation that might exist. I am aware of developer.chrome.com, but could not find much documentation other than reference documentation.
Thanks for the help!
Jim