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();
}
Related
I am making an universal app and when i click a certain button, i need to open the webbrowser with a link. I got the link as a string in a variable but the windows 7 / 8 app ways such as "Proces" and Webbrowser objects give errors.
In windows apps, you can't simply open other apps/programms.
The only posibility is to use the Launcher:
Windows.System.Launcher.LaunchUriAsync(new Uri("http://www.google.de"));
The Launcher looks up the default program/app which is assosiated to the uri-scheme (in this case "http://" for webbrowsers) and forwards this call
others then above you can go Package.app manifest change the start page to the URL that you want or another method by using web control set the source to the URL you needed.
use scope async, it will open link to the mobile,PC default default browser for UWP
private async void Button_Click(object sender, RoutedEventArgs e)
{
await Windows.System.Launcher.LaunchUriAsync(new Uri("http://www.fmradiotune.blogspot.com"));
}
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);
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.
how can i refresh/reload my browserpage in my app?
i have a webbrowser created to dinamically retrieve a random page from my site, now i want to capture the actual url and use it for the refresh button and for the "open in browser button".
Basically i need to retrieve the current url and use it to refresh it: this is my question.
Thanks!
Assuming the webBrowser control is caleld EmbeddedBrowser.
Refresh:
EmbeddedBrowser.Navigate(EmbeddedBrowser.Source.AbsoluteUri);
Launch in IE:
var wbt = new WebBrowserTask
{
URL = EmbeddedBrowser.Source.AbsoluteUri
};
wbt.Show();
HI, is possible to add request headers in WP7 WebBrowser control?
There is no way to do this. If you need to change headers you'll need to use HttpWebRequest.
You could intercept the requests from the WebBrowser control and make them yourself via HWR but this could get complicated very quickly.
No - I don't think there's any API hook available for this.
It's a similar problem to the "change the user agent" request discussed in Bring back mobile version of website in WebBrowser control for wp7?
Sorry to necro but the answers here are wrong. Headers can be added to a WebBrowser through the Navigate method.
WebBrowser.Navigate(YourURI, null, YourCustomHeaderString)
See this page: http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff626636(v=vs.105).aspx
.
These headers will only apply to the first page navigated to through your code. If you want the headers to stay the same even when users click a link inside the web browser control, add this for the WebBrowser's navigating event:
private void browser_Navigating(object sender, NavigatingEventArgs e)
{
string url = e.Uri.ToString();
if(!url.Contains("YESHEADERS"))
{
e.Cancel = true;
string newUrl;
if(url.Contains("?"))
{
newUrl = url + "&YESHEADERS";
}
else
{
newUrl = url + "?YESHEADERS";
}
browser.Navigate(newUrl, null, "fore:" + Variables.GetForeground() + "")
}
}
Here's what that does:
We create an indicator, YESHEADERS, that tells us whether or not we have added custom headers.
When the WebBrowser tries to Navigate, we check whether or not the URL it is navigating to, e.Uri, contains YESHEADERS.
If it does, we've already added our headers. Take no action
If it does not, cancel the current navigation. Create a new URL equal to the old URL plus our indicator. We add YESHEADERS on to the new URL in it's query string. If you are not familiar with query strings that is fine, just know that they are extra strings on the URL that have no effect in our case. About Query Strings
Then, we navigate to the new URL, and add our custom headers.
In short, if we have our indicator YESHEADERS the web browser knows that we've added our custom headers, if we don't have YESHEADERS, than the web browser needs to add the headers.