I am attempting to troubleshoot some issues with a webbrowser we use in our Windows Phone application. The problem is that our Windows Phone that is running 8.0 receives all of its javascript callbacks fine and loads the webpage happily. When the 8.1 phone runs the application, the web page doesn't load and the javascript callbacks aren't hit.
Relevant code:
this.ShowBlocker(true);
browser = new WebBrowser()
{
Name = "browser",
IsScriptEnabled = true,
HorizontalAlignment = HorizontalAlignment.Stretch,
VerticalAlignment = VerticalAlignment.Stretch
};
browser.ScriptNotify -= this.ScriptNotify;
browser.ScriptNotify += this.ScriptNotify;
browser.Navigated -= this.Browser_Navigated;
browser.Navigated += this.Browser_Navigated;
browser.NavigationFailed -= this.Browser_NavigationFailed;
browser.NavigationFailed += this.Browser_NavigationFailed;
if (browser.Source != this.mapSource.MapUrl)
{
browser.Navigate(this.mapSource.MapUrl);
}
else
{
this.isWebPageLoaded = true;
this.isJsLoaded = true;
this.Clear();
this.JSMap_Loaded();
}
this.BrowserContainer.Child = browser;
Has something changed in 8.1?
This was solved by reformatting the phone. Weird.
Related
I am creating a Windows universal app and I would like to implement some behavior for the (hardware)back button. I am able to do so for windows Phone using
'using Windows.Phone.UI.Input;'
and
'HardwareButtons.BackPressed += HardwareButtons_BackPressed;'
But can't seem to do it with the universal app, This behavior will happen on a page that is shared. How can I do this?
You can use SystemNavigationManager
SystemNavigationManager currentView = SystemNavigationManager.GetForCurrentView();
And have an event handler like this one:
currentView.BackRequested += CurrentView_BackRequested;
private void CurrentView_BackRequested(object sender,BackRequestedEventArgs e) {
e.Handled = true;
if(Frame.CanGoBack)
try { Frame.GoBack(); }
catch(Exception) { }
}
And to Visible Back Button at corner of ur app (Desktop mode) :
currentView.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
I have been in a headache to display SystemMediaTransportControls in my wp8.1 app, unfortunately it doesn't work.
Here is the scenario, I have added Windows Phone App Project and then Windows Runtime Component (Windows Phone). I referenced the Runtime Component in My probject and then in the manifest added Audio as a Background Task.
Everything seems to work fine, the media is played in the background, but the SystemMediaTransportControls are not displayed. Below is my code for Run method in my BackgroundTask
public void Run(IBackgroundTaskInstance taskInstance)
{
Debug.WriteLine("Background Audio Task " + taskInstance.Task.Name + " starting...");
taskInstance.Canceled += TaskInstance_Canceled;
//taskInstance.Task.Completed += Taskcompleted;
systemmediatransportcontrol = SystemMediaTransportControls.GetForCurrentView();
systemmediatransportcontrol.ButtonPressed += systemmediatransportcontrol_ButtonPressed;
systemmediatransportcontrol.PropertyChanged += systemmediatransportcontrol_PropertyChanged;
systemmediatransportcontrol.IsEnabled = true;
systemmediatransportcontrol.IsPauseEnabled = true;
systemmediatransportcontrol.IsPlayEnabled = true;
systemmediatransportcontrol.IsNextEnabled = true;
systemmediatransportcontrol.IsPreviousEnabled = true;
BackgroundMediaPlayer.Current.CurrentStateChanged += Current_CurrentStateChanged;
BackgroundMediaPlayer.MessageReceivedFromForeground += BackgroundMediaPlayer_MessageReceivedFromForeground;
Debug.WriteLine(systemmediatransportcontrol.IsEnabled.ToString());
ValueSet message = new ValueSet();
message.Add("backgroundStarted", "1");
BackgroundMediaPlayer.SendMessageToForeground(message);
BackgroundTaskStarted.Set();
deferral = taskInstance.GetDeferral();
}
It has been two days working in this problem and it has given me a lot of headache. The question is, why SystemMediaTransportControls is not displayed?
Use SystemMediaTransportControls.DisplayUpdater to set the MusicProperties. MusicProperties is of type MusicDisplayProperties and include properties such as the song title and the song artist.
Update this on track change:
systemmediatransportcontrol.PlaybackStatus = MediaPlaybackStatus.Playing;
systemmediatransportcontrol.DisplayUpdater.Type = MediaPlaybackType.Music;
systemmediatransportcontrol.DisplayUpdater.MusicProperties.Title = "<Track_Name>";
systemmediatransportcontrol.DisplayUpdater.MusicProperties.Artist = "<Artist_Name>";
systemmediatransportcontrol.DisplayUpdater.Update();
In my application I want to notify the user with the ShellToast.
Just by running...
var toast = new ShellToast
{
Title = "Nom nom nom!",
Content = "More! More! Keep feeding me!",
};
toast.Show();
...makes nothing happen, and as I understand it needs to be run from a ScheduledTaskAgent. But how do I run this on command, and make sure it only run once?
You can't use a ShellToast while the app is the foreground app. It's meant to be invoked from a background service while the app isn't the foreground app.
If you want to have a UX similar to that of ShellToast use the Coding4fun toolkit ToastPrompt control. Here's a code snippet showing how to use it:
private void ToastWrapWithImgAndTitleClick(object sender, RoutedEventArgs e)
{
var toast = GetToastWithImgAndTitle();
toast.TextWrapping = TextWrapping.Wrap;
toast.Show();
}
private static ToastPrompt GetToastWithImgAndTitle()
{
return new ToastPrompt
{
Title = "With Image",
TextOrientation = System.Windows.Controls.Orientation.Vertical,
Message = LongText,
ImageSource = new BitmapImage(new Uri("../../ApplicationIcon.png", UriKind.RelativeOrAbsolute))
};
}
Running this code snippet shows the following:
Just a small update: using ShellToast when the app is in foreground, is now possible, when using Windows Phone 8 Update 3. Though, they are obscured by other activity such as a phone call or the lock screen. Source
In my application I want to notify the user with the ShellToast.
Just by running...
var toast = new ShellToast
{
Title = "Nom nom nom!",
Content = "More! More! Keep feeding me!",
};
toast.Show();
...makes nothing happen, and as I understand it needs to be run from a ScheduledTaskAgent. But how do I run this on command, and make sure it only run once?
You can't use a ShellToast while the app is the foreground app. It's meant to be invoked from a background service while the app isn't the foreground app.
If you want to have a UX similar to that of ShellToast use the Coding4fun toolkit ToastPrompt control. Here's a code snippet showing how to use it:
private void ToastWrapWithImgAndTitleClick(object sender, RoutedEventArgs e)
{
var toast = GetToastWithImgAndTitle();
toast.TextWrapping = TextWrapping.Wrap;
toast.Show();
}
private static ToastPrompt GetToastWithImgAndTitle()
{
return new ToastPrompt
{
Title = "With Image",
TextOrientation = System.Windows.Controls.Orientation.Vertical,
Message = LongText,
ImageSource = new BitmapImage(new Uri("../../ApplicationIcon.png", UriKind.RelativeOrAbsolute))
};
}
Running this code snippet shows the following:
Just a small update: using ShellToast when the app is in foreground, is now possible, when using Windows Phone 8 Update 3. Though, they are obscured by other activity such as a phone call or the lock screen. Source
After registering BHO on machine with Win7 i realized that something is wrong. When IE is not opened as administrator then OnBeforeNavigate2 and OnDocumentComplete events of WebBrowser are not fired. When I run IE as administrator these methods are fired correctly. I subscribing to these metods the following way:
public int SetSite(object site)
{
if (site != null)
{
webBrowser = (WebBrowser)site;
webBrowser.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
webBrowser.BeforeNavigate2 += new DWebBrowserEvents2_BeforeNavigate2EventHandler(this.OnBeforeNavigate2);
}
else
{
webBrowser.DocumentComplete -= new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
webBrowser.BeforeNavigate2 -= new DWebBrowserEvents2_BeforeNavigate2EventHandler(this.OnBeforeNavigate2);
}
return 0;
}
UAC function is turned on with default value.
On machine with Windows XP everything was OK(even on limited account).
Are you sure that the BHO is registered properly on the limited account?