I'm developing a Windows Phone 8 Application that uses the map control. I have followed the tutorial, but I keep geeting the messagebox error: HRESULT: 0X80042706. Here is the code from the tutorial
protected override void OnNavigatedTo(NavigationEventArgs e)
{
map.ColorMode = MapColorMode.Light; map.CartographicMode = MapCartographicMode.Road; map.LandmarksEnabled = true; map.PedestrianFeaturesEnabled = true; map.ZoomLevel = 17;
routeQuery.TravelMode = TravelMode.Walking; routeQuery.QueryCompleted += rq_QueryCompleted;
base.OnNavigatedTo(e);
}
...
void rq_QueryCompleted(object sender, QueryCompletedEventArgs<Route> e) {
if (null == e.Error) {
//Recommended way to display route on map
Route MyRoute = e.Result;
MapRoute MyMapRoute = new MapRoute(MyRoute);
map.AddRoute(MyMapRoute);
}
else
MessageBox.Show("Error occured:\n" + e.Error.Message);
}
I tried to search what kind of error HRESULT: 0X80042706 was from here, but I have no idea what that meant.
I even tried to switch the if condition to e.Error == null, but still no good. Can anyone help me?
The error is because your device does not support CHAP authentication while connecting to Virtual Disk Service (i.e. Maps)
This is because you don't have an authentication id from Microsoft.
Follow the details here ( for wp8 maps another authentication is required)
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207033(v=vs.105).aspx
I received the same error from the same tutorial, and found it was due to no internet access to my PC (and hence no map data). Restored Internet access and the error resolved itself.
Please once check your Manifestfile and select Capability option click in ID_CAP_MAP.
Related
At start I'm sorry for my English is poor. And this is the only place where i solved the problem.
I have a problem with my application. I write and test it on emulator in VisualStudnio 2012 and It work fine. But when I add aplication in WindowsPhone store and I get to phone. It crashed. I think that problem is in geolocator or something with GPS, because when i use function where my it don't use gps it work. Everywhere where i use geolocator_geopositionchanged it break down and app is terminate. in one of application page i use map control but i gave token and application id but only in class where i use map.
private void maping_Loaded(object sender, RoutedEventArgs e)
{
Microsoft.Phone.Maps.MapsSettings.ApplicationContext.ApplicationId = "id";
Microsoft.Phone.Maps.MapsSettings.ApplicationContext.AuthenticationToken = "token";
}
Do you have any sugestion or advices?
if you want watching app there is a link
http://www.windowsphone.com/pl-PL/store/app/opencaching/06bce1e1-16ef-4ebf-ac53-23b4c725f78b
I have geolocator in a few class it's one of them
Geolocator code
if (!tracking)
{
gps = new Geolocator();
gps.DesiredAccuracy = PositionAccuracy.High;
gps.ReportInterval = 100;
gps.PositionChanged += geolocator_PositionChanged;
}
else
{
gps.PositionChanged -= geolocator_PositionChanged;
gps = null;
}
tracking = !tracking;
Geoposition changed code
void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
{
double distance = 0;
distance = point.GetDistanceTo(new GeoCoordinate(args.Position.Coordinate.Latitude, args.Position.Coordinate.Longitude));
string asa = Convert.ToInt64(distance).ToString();
if (asa != null)
{
Dispatcher.BeginInvoke(() =>
{
TBodleglosc.Text = asa +"m";
navi.Rotation = 180 + Kierunek(point.Latitude, point.Longitude, args.Position.Coordinate.Latitude, args.Position.Coordinate.Longitude);
});
}
}
Debug on your device. If that cannot repro, setup a Beta Test app and use that to distribute the app back to yourself for debugging. Sometimes signing breaks things.
I debug at lumia 920 and I have a problem with convert.toDouble
because there are was , i have . and vice versa
I think that it's connected with phone language
because in english emulator and Ertay Shashko phone who debug it yesterday it's working fine.
At now application work at phone but doesn't at emulator.
but if i change settings on location and language apps work but I can't debug because visual studio have error
It's weird .....
I have the following piece of code for using text to speech feature in Windows Phone 8. I am using ssml, with bookmarks. But when changing any UI element in the Bookmark event called function, raises Unauthorized Exception.
private void Initialise_synthesizer()
{
this.synthesizer = new SpeechSynthesizer();
synthesizer.BookmarkReached += new TypedEventHandler<SpeechSynthesizer, SpeechBookmarkReachedEventArgs>
(BookmarkReached);
}
void BookmarkReached(object sender, SpeechBookmarkReachedEventArgs e)
{
Debugger.Log(1, "Info", e.Bookmark + " mark reached\n");
switch (e.Bookmark)
{
case "START":
cur = start;
break;
case "LINE_BREAK":
cur++;
break;
}
**error here** t1.Text = cur.ToString();
}
But on running it gives the following error
A first chance exception of type 'System.UnauthorizedAccessException' occurred in System.Windows.ni.dll
An exception of type 'System.UnauthorizedAccessException' occurred in System.Windows.ni.dll and wasn't handled before a managed/native boundary
Invalid cross-thread access.
Any idea how to fix this error, or any work around.
Just got the answer.
Since the synthesizer.SpeakSsmlAsync() is an async function, to perform UI operations Dispatcher has to be used, something like this -
Dispatcher.BeginInvoke(() =>
t1.Text = cur.ToString());
It's pretty much unrelated to the speech recognition. It seems that it's related to accessing elements which are on the UI thread from a different thread.
Try this:
Dispatcher.BeginInvoke(() =>
{
t1.Text = cur.ToString();
}
);
From AppManifest.xml turn on capability ID_CAP_SPEECH_RECOGNITION.
Can someone show me or tell some example how to unregister from notification hub in windows phone 8. I tried on this way but it doesn't work.
public void registerForNotifications(string[] tags)
{
var channel = HttpNotificationChannel.Find("xxx");
if (channel == null)
{
channel = new HttpNotificationChannel("xxx");
channel.Open();
channel.BindToShellToast();
}
string[] tagsToSubscribeTo = tags;
channel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(async (o, args) =>
{
var hub = new NotificationHub("xxx", "xxx");
await hub.RegisterNativeAsync(args.ChannelUri.ToString(), tagsToSubscribeTo);
});
}
public async void unregisterFromNotifications()
{
var channel = HttpNotificationChannel.Find("xxx");
var hub = new NotificationHub("xxx", "xxx");
await hub.UnregisterAllAsync(channel.ChannelUri.ToString());
}
You didn't say what "it didn't work" means. Did you get an error message? Did it report success but actually fail? In your questions, it really helps more if you share those things. But I'll take a stab at this anyway.
I suspect that you might be using the DefaultListenSharedAccessSignature endpoint from your Windows Phone 8 app.
According to http://msdn.microsoft.com/en-us/library/dn495373.aspx, the Listen access level grants permission to:
Create/Update registration.
Read registration.
Read all registrations for a handle.
Delete registration.
Reading that last one, I wonder if the UnregisterAllAsync method might require a higher access level to delete all registrations, rather than just one.
But rather than use the DefaultFullSharedAccessSignature endpoint, I would rather just try the UnregisterAsync method instead of UnregisterAllAsync.
Disclaimer: I have not tried this out. It may not help at all.
Is that possible to make the buy & try options in windows phone 8
like in the windows store apps.
One of my game in the windows store is full access for one week from the day of download. After that windows store itself locks the game(If we give 1 week in the dashboard).
Like that, windows phone 8 having any of the features. .
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh286402(v=vs.105).aspx#BKMK_Runningtheapplication
Even i tried for Buy & try using the above link.
I changed the checklicense() like below.
private void CheckLicense()
{
if DEBUG
string message = "This sample demonstrates the implementation of a trial mode in an application." +
"Press 'OK' to simulate trial mode. Press 'Cancel' to run the application in normal mode.";
if (MessageBox.Show(message, "Debug Trial",
MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
_isTrial = true;
}
else
{
_isTrial = false;
}
else
_isTrial = _licenseInfo.IsTrial();
//Included lines
if(_isTrail)
freeversion = true; //Here Free version trigger when user presses Try
else
freeversion = false; //Here fullversion trigger when user presses Buy
//Included lines
endif
}
If i did like this. I run it in the Master Mode. It always goes for freeversion is false.(i.e: _isTrail is always returns false).
Its because of i have not yet uploaded to windows phone store or some other problem??
Help out to solve this??
There is no automated way to do that on Windows Phone, you'll have to implement the trial limitation yourself in the app.
Note that uninstalling an app on Windows Phone leaves no traces. Therefore, users will be able restart the trial period if they uninstall/reinstall the app.
Here is the code that i used:
private void CheckLicense()
{
LicenseInformation licenseInformation = CurrentApp.LicenseInformation;
try
{
var listing = await CurrentApp.LoadListingInformationAsync();
var _price = listing.FormattedPrice;
// start product purchase
await CurrentApp.RequestProductPurchaseAsync("FeatureName", false);
ProductLicense productLicense = null;
if (CurrentApp.LicenseInformation.ProductLicenses.TryGetValue("FeatureName", out productLicense))
{
if (productLicense.IsActive)
{
MessageBox.Show("Product purchased");
CurrentApp.ReportProductFulfillment("FeatureName");
ProductPurchased(); // It display product purchased & trigger full version
return;
}
else
{
str = "Purchase failed";
ShowErrorPopup(str); // It shows error msg. purchase failed.
return;
}
}
}
catch (Exception)
{
str = "Purchase failed. Check internet connection and try again";
ShowErrorPopup(str);
return;
}
}
I'm using the new Wi-Fi Direct API from google on Android 4.0
and in Sample code they send the User to Settings, to activate WiFi -Direct Mode.
Is there a way to Start it by code???
all they offer is to listen to WIFI_P2P_STATE_CHANGED_ACTION intent, and then use this code
String action = intent.getAction();
if (WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION.equals(action)) {
// UI update to indicate wifi p2p status.
int state = intent.getIntExtra(WifiP2pManager.EXTRA_WIFI_STATE, -1);
if (state == WifiP2pManager.WIFI_P2P_STATE_ENABLED) {
// Wifi Direct mode is enabled
} else {
// Wifi Direct mode is disabled
}
Yes there is a way using reflection. Works on my GSII (and fails gracefully on non Wifi Direct HTC Sensation) but as this is reflection it may not work on all phones.
p2pManager = (WifiP2pManager) getSystemService(WIFI_P2P_SERVICE);
channel = p2pManager.initialize(getApplicationContext(),
getMainLooper(), null);
try {
Class<?> wifiManager = Class
.forName("android.net.wifi.p2p.WifiP2pManager");
Method method = wifiManager
.getMethod(
"enableP2p",
new Class[] { android.net.wifi.p2p.WifiP2pManager.Channel.class });
method.invoke(p2pManager, channel);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Please note:
On Jelly Bean and above, when you try to use the WifiP2pManager API, WiFi-Direct is automatically enabled (as long as WiFi is on), so there is no need to use this hack.
No, all you could do is notify the user to turn on WiFi.
On some devices, even though Wi-Fi direct is supported, it's not enabled due to some system bugs. Here's a more reliable way to check whether it's enabled (unfortunately it requires root) using Kotlin.
val matcher = "^mNetworkInfo .* (isA|a)vailable: (true|false)"
.toPattern(Pattern.MULTILINE)
.matcher(su("dumpsys ${Context.WIFI_P2P_SERVICE}"))
if (!matcher.find()) return "Root unavailable"
if (matcher.group(2) != "true") return "Wi-Fi Direct unavailable"
return "Wi-Fi Direct available"
This should work for Android 4.3 - 8.1. Check source code below:
https://android.googlesource.com/platform/frameworks/base/+/f0afe4144d09aa9b980cffd444911ab118fa9cbe%5E%21/wifi/java/android/net/wifi/p2p/WifiP2pService.java
https://android.googlesource.com/platform/frameworks/opt/net/wifi/+/a8d5e40/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java#639
https://android.googlesource.com/platform/frameworks/base.git/+/f0afe4144d09aa9b980cffd444911ab118fa9cbe/core/java/android/net/NetworkInfo.java#433
https://android.googlesource.com/platform/frameworks/base.git/+/220871a/core/java/android/net/NetworkInfo.java#415