I'm trying to open a specific page in my app (not the home page) and use the following piece of code
private void toastNotification(string Content,string uri)
{
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);
XmlNodeList textElements = toastXml.GetElementsByTagName("text");
textElements[0].AppendChild(toastXml.CreateTextNode("FootBallTards"));
textElements[1].AppendChild(toastXml.CreateTextNode(Content));
var toastNavigationUriString = "/Views/Browser.xaml?uri="+uri;
var toastElement = ((XmlElement)toastXml.SelectSingleNode("/toast"));
toastElement.SetAttribute("launch", toastNavigationUriString);
ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(toastXml));
}
The toast notification is being fired correctly but on tapping them, the home located in Views/Home.xaml (absolute address) page of my app is being opened, but I want to redirect to page located in Views/Browser.xaml (absolute address), and also pass the parameter uri to that page.
Apart from this how can I get the value of parameter on that page. I've looked up help from stackoverflow question , stackoverflow question and msdn page but couldn't get it to work.
Related
Please help me to find the way how to navigate back on webviewclient using back button on android.
I am using Xamarin hybrid app using Razor views,
I am using loadDataWithBaseURL method to find each method and move on that page, like following:
if (method == "SignIn")///sign-in.html
{
var template = new SignIn();
var page = template.GenerateString();
webView.LoadDataWithBaseURL("file:///android_asset/", page, "text/html", "UTF-8", null);
}
The above code I am using in ShouldOverrideUrlLoading(WebView webView, string Url)
the URL is passed as "hybrid:SignIn?"
Now back navigation is not working either on using OnBackPressed() method, or using OnKeyDown()
I also tried, WebBackForwardList, I can see in debug mode te current items in it , but no any url to go back on.
The url is always "about:blank"
and page is showing blank on GoBack() method.
I have a button in my game where I make a finish level screen capture , I then attach that picture to a Facebook SharePhotoContent dialog from the newest SDK.
It all works as it's supposed but how do I also insert a custom message body so that I replace the standard "Say something about this photo" text in the body?
Here is the code :
File tmpFile = new File(path_to_saved_facebook);
media_scanner = new SingleMediaScanner(this, tmpFile);
Bitmap bitmap = BitmapFactory.decodeFile(path_to_saved_facebook, options);
SharePhoto photo = new SharePhoto.Builder()
.setUserGenerated(true)
.setBitmap(bitmap)
.setCaption("Latest score")
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
shareDialog.show(content);
You can't. Facebook does not allow you to prefill the status message.
pre-fill text-with-image is no longer work in latest SDK 4.0 or high
Don't prefill captions, comments, messages, or the user message parameter of posts with content a person didn’t create, even if the person can edit or remove the content before sharing.
https://developers.facebook.com/docs/apps/review/prefill
I'm trying to create an MVVM Caliburn-based WinRT 8.1 app (I know that CM won't be perfectly compatible with 8.1 until version 2.0 is out, but the error does not seem to be related, as it is raised also when the handler is placed in the view code behind). One of its views contains a WebView control, whose content is set via NavigateToString (HTML contents come from app's installed assets). The HTML loaded into this control includes several hyperlinks, most of them representing cross-references to other asset-based HTML content. So when users click the link I want to override the standard navigation action, get my viewmodel notified, and let it load another HTML content from the app assets.
Here is what I did, following the post Open links in external browser in WebView (WinRT):
in the XAML code, I added to the WebView control an attribute for attaching the ScriptNotify event to my VM: cal:Message.Attach="[Event ScriptNotify] = [Action GetFromLink($eventArgs)]" (see https://caliburnmicro.codeplex.com/wikipage?title=All%20About%20Actions).
in my VM, the method signature is public void GetFromLink(NotifyEventArgs e).
whenever my VM loads some HTML into the WebView, it first injects a script in the HTML head which replaces the click handler of each anchor representing a cross-reference (all these anchors are marked by a class="xref" attribute). This script is hold in a constant in my VM:
private const string SCRIPT = "for (var i = 0; i < document.links.length; i++) {" +
"var className = document.links[i].getAttribute(\"class\");" +
"if (className && className === \"xfer\") {" +
"document.links[i].onclick = function() {" +
"window.external.notify('url:' + this.href);" +
"return false;" +
"}}}";
Now, when I launch the app, load an item containing one of these xref's and click on it, I get an unhandled exception telling me that "navCancelInit is undefined". I suppose this error is surfacing from JS code, but I cannot see where and how this function should be defined.
According to http://msdn.microsoft.com/library/windows/apps/br227713, I do not need any additional step for ScriptNotify when HTML has been loaded via NavigateToString. Could anyone suggest a solution?
I got an answer from a MS guy about this, so credit is not mine for this answer: it is a timing issue. I must ensure that the page has fully loaded before running the script which changes the DOM; pretty simple, if you think. Just moving the script at the end of the page, or wrapping it in an onload handler, should make the trick. Hope this can save some hair-pulling to others!
If you listen to this event: http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.webview.domcontentloaded.aspx WebView.DOMContentLoaded event, All of the script should be loaded in the WebView and you should be able to access and execute, if you are trying to do this before the scripts won't be loaded.
I try to instance new page and get the object on that page (for example LongListSelector) by the name.
But when I do
var currentPage = (PhoneApplicationPage)((PhoneApplicationFrame)App.Current.RootVisual).Content;
currentPage.NavigationService.Navigate(new Uri(pageUri, UriKind.Relative));
I can't get the instance of new page. The second calling of var currentPage = (PhoneApplicationPage)((PhoneApplicationFrame)App.Current.RootVisual).Content gets me the same currentPage.
How can I access the instance of new page and items on it?
I need it to implement custom item selector. When tapping on the list item_header from page1 the page2 is showing, where I can chose the right item_kind and navigate back to list1.
What you are actually looking for is passing data between pages or having a ViewModel that can be accessed from different pages and share data between them. Please have a look at the answer for that question here
It describes the different ways of sharing data between pages.
Done it with saving page instance in OnNavigateTo event into a global array.
I am trying to create a simple adult filter to get my feet wet in Chrome extension building.
Basically, I have a block list and a redirect list, everything works great and the correct parts fire when the user enters one of block list's domains, and now i want to redirect to google when that happens, so I used this code (that I got after searching Google) :
if (blocked) {
up = new Object();
up.url = chrome.extension.getURL("http://www.google.com");
chrome.tabs.update(tab.id, up);
but that seems to be code only to open files locally.
How do I open the URL instead?
Thanks!
Since "http://www.google.com" is not an extension resource, just use:
up.url = "http://www.google.com";