I'm working on a native Google Glass app in Xamarin. I've got QR code scanning working properly - but after a scan I want to open a URL in the Glass browser. Is this something that's possible? The code below just shows that the text was properly scanned. But I really want to open the URL: result.Text.
Any help would be greatly appreciated. Thanks!
Console.WriteLine ("Scanned Barcode: " + result.Text);
var card2 = new Card (this);
card2.SetText ("Card Scanned.");
card2.SetFootnote ("Just scanned!");
SetContentView (card2.ToView());
You can define a new menu item with the following intent.
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(result.Text));
startActivity(i);
Yes, you can open a URL in the Glass browser.
If result.Text is a URL (like "http://www.stackoverflow.com"), this will work:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setClassName("com.google.glass.browser", "com.google.glass.browser.WebBrowserActivity");
i.setData(Uri.parse(result.Text));
startActivity(i);
Related
I have integrated SerialIO RFID SDK and using Bluetooth LE Plugin to check Bluetooth Status in my Xamarin.iOS app.
Each time when I launch the app, it keeps showing me the alert as soon as any of the code from above SDK or plugin is invoked. I don't want to show this alert. Instead, I want to notify user about this, in some other way.
I found this way to disable this alert, but Where and How to
write this in Xamarin, is my Question.
I searched a lot for Xamarin Specific solution and didn't find any.
I tried following in AppDelegate.cs but none of them worked. May be I am not sure how to write this.
// Way : 1
var cbCentralInitOptions = new CBCentralInitOptions();
cbCentralInitOptions.ShowPowerAlert = false;
var cbCentralManager = new CBCentralManager(this, null, cbCentralInitOptions);
// Way : 2
//NSDictionary options = new NSDictionary();
//options.SetValueForKey(NSNumber.FromNUInt(0), CBCentralManager.OptionShowPowerAlertKey);
//var cbCentralManager = new CBCentralManager(this, null, options);
Please help me to get this default alert suppressed. Thanks.
I have a very standard code picked up from the GitHub examples like this:
HeroCard postAnalysisCard = new HeroCard()
{
Buttons = new List<CardAction>
{
new CardAction(ActionTypes.PostBack, "Show me previous polls", value: "showprevious"),
new CardAction(ActionTypes.PostBack, "Show me more statistics regarding this question", value: "ShowStats"),
new CardAction(ActionTypes.OpenUrl, "Show me more about this topic", value: "http://bing.com/search?q=" + question.Substring(0, queryIndex)),
new CardAction(ActionTypes.PostBack, "Help", value: "Help")
}
};
But the OpenUrl action doesn't seem to work on all Skype clients. It works on Windows desktop but not on Android.
Is this a known issue?
If yes, what is the workaround to have a consistent behavior?
The actual issue was unescaped special characters in the url. Escaping the string solves the issue.
The URL you provide in OpenUrl must use https://. Skype requires all external links to be secure.
I know this sounds weird. Is there any way we can open a URI from background tasks in Windows 10 Apps?
I have 2 requirements,
Talk to cortana and it will show you results based on the speech recognition, when user clicks on it, we cannot open the links in browser directly. Instead I am passing the Launch Context to the Foreground app and then using LauchUri I am opening the url in default browser.
Send toast notifications from the App, when user clicks on it, I have requirement to open a url instead opening an app. So, did the same, by passing the launch context to foreground app and then opening the url.
Both scenarios, it just opening url in browser. Here user experience is very poor that user seeing the app open for each action and then opening browser. Please throw some ideas if any possibilities.
thanks in advance.
For your second requirement, you can make Toast Notifications launch a URL!
If you're using the Notifications library (the NuGet package that we suggest you use), just set the Launch property to be a URL, and change the ActivationType to Protocol. You can also do this with raw XML, but that's error-prone.
You can also make buttons on the toast launch a URL too, since they also support ActivationType of Protocol.
Show(new ToastContent()
{
Visual = new ToastVisual()
{
BindingGeneric = new ToastBindingGeneric()
{
Children =
{
new AdaptiveText() { Text = "See the news" },
new AdaptiveText() { Text = "Lots of great stories" }
}
}
},
Launch = "http://msn.com",
ActivationType = ToastActivationType.Protocol
});
I'd like to know, how can I use facebook c# sdk to post to user's wall from my wp7 app as application.
So I want to display message from FB application on users wall.
I have so far:
var app = new FacebookApp();
var parameters = new Dictionary<string, object>
{
{"access_token", accessToken},
{"appId", appId,
{"message", "TEST"}
};
var fbCB = new FacebookAsyncCallback(postResult);
app.PostAsync("me/feed", parameters, fbCB);
But this displays text on my wall as I wrote it, not like the application specified by appId.
app.PostAsync("friendId/feed", parameters, fbCB);
I would also suggest you to use the latest facebook c# sdk.
I have the following question:
I have my Windows Phone 7 appplication and I have a HyperlinkButton with the NavigateUri binded to an Uri created like this:
Uri uri = new Uri("http://google/ro",UriKind.Ablosute)
but when I press the button I get the following error :
Navigation is only supported to relative URIs that are fragments, or begin with '/', or which contain ';component/'.\r\nParameter name: uri
What did I do wrong? Or is the WP7 that does not allow to surf the internet from an application with a HyperlinkButton? Since when I create the uri like Uri uri = new Uri("/Page.xaml",UriKind.Relative) it redirects me to Page.xaml in the project.
I found a rather strange workaround that fixes this. Just add a TargetName="_blank" property to your HyperlinkButton control, and it magically starts working.
<HyperlinkButton Content="Google" NavigateUri="http://google.com" TargetName="_blank" />
Chris
You can't use the phone navigation system to navigate to the web (where would you expect it to display?). But you can use the web browser control to display web pages in your app. See this example
You could also use a Web Browser Task something along the lines of
WebBrowserTask wtb = new WebBrowserTask();
wtb.Uri = new Uri("http://www.google.com", UriKind.Absolute);
wtb.Show();
The URL is obsolete. Use Uri, as below.
private void Button_Click(object sender, RoutedEventArgs e)
{
WebBrowserTask wtb = new WebBrowserTask();
wtb.Uri = new Uri("http://www.google.com", UriKind.Absolute);
wtb.Show();
}