How can I test my WP7 app under no Internet connection conditions in emulator? - windows-phone-7

I am developing a Windows Phone 7 App which is capable to work without internet connection but optionally loads some content from web if network is available.
How can I test this application in Phone Emulator under the condition of having no internet connection?
There is a Settions option available in the main menu, but unlike on real device there is no option to disable data connection. The only solution I came up with is to disable the WiFi adaptor of my development laptop, but this seems to be an ultimate option.
Is there any way to force emulator to run in disconnected environment?

Another option is to use NetLimiter
Not only can you shut off connection to your app, you can change the speeds to simulate a poor connection and see how your app behaves. NetLimiter and Fiddler are sweet tools.

Like you said, I just disconnect my development computer from the internet whenever I want to test a wp7 app under no internet connection. You can't force it from the emulator, but you could probably turn it off using code, but that seems like too much work to me.
Another StackOverflow post.
From WP7 App Hub.

Check out this question. It has some info on the same problem. Also check out this post.
You can use this method in your code for detecting internet connection. If you put it in a static class as a static method, it works nice.
private bool InternetIsAvailable()
{
var available = !NetworkInterface.GetIsNetworkAvailable();
#if DEBUG
available = false;
#endif
if (!available)
{
MessageBox.Show("No internet connection is available. Try again later.");
return false;
}
return true;
}

There is an easy way...
If your app do not require a online login... Desktop, open the "Internet Explorer" > "Settings" > "Connection" and setup a proxy which is of course not valid. Save the changes. Now, you should not be able to browse a website anymore. After these steps, start the simulator...

Related

PWA development in localhost

Currently, I am trying to make my website support PWA. After implementing it, it works on the browser from the desktop where the button to install it is available on the address bar, but when I tested it on my mobile locally, somehow it won't prompt the "Add to home screen" popup.
Could the reason be that I run it locally, as it only uses the HTTP protocol? Or I missed something in order to set up for that popup specifically? My website is on Laravel 7.
Hope anyone could help enlighten me with this issue.
Thank you.
UPDATE: Solved it. Apparently by running the website locally with exposed public port using ngrok with HTTPS protocol, I am able to simulate how the app will behave on the mobile and the "Add to home screen" popup finally appeared.
PWAs by definition need HTTPS connections to be installed and run properly (as you said). On your development machine you are making use of the exception for "localhost". On your mobile device, you are not accessing the site locally as it is not hosted on the device itself.

Not able to debug phonegap app running on windows 8 mobile

I have a phonegap application that has some layout problems. I can run the app in browser for the most part, and this usually get me over the line. But with a new design I need to debug the application layout on windows phone 8.
I'm currently looking at weinre but its not showing anything on the desktop when browsing the local server, I have added the link to my application I have cleaned up everything I can think of. Still blank. Any good tuts around the ones I have read just copy and paste the original docs or are not on my same error.
There's a public weinre server available here:
https://the-weinre.herokuapp.com/
You may have better luck with that than with your local server. There's a demo available on that page, give that a try and see if it works on your windows 8 mobile device.

Debugging network requests with iOS Simulator, network request data is not showing

I am trying to debug the network requests for a hybrid/webview cordova based application in the ios simulator, actually see the network requests in the Safari Web Inspector. I am trying to use the Web Inspector within Safari to monitor the network requests to the server but all I see is the "timeline" graph, I don't see the actual URI requests. Is there a way to enable this?
I build my application through xcode. Launch the iOS simulator with iPad2 selected/iOS 8.1. I then launch Safari and select the "ios simulator/index.html" to launch the web inspector. And then click on network requests. The resources tab pane is empty when I make web request calls. Is there a way to fix this so I can see the url requests?
Xcode: 6.1.1
Safari: 7.1.3
OSX: 10.9.5
I'm not quite sure if it's even possible to do that via web inspector or not but put option 1 just in case. I highly recommend you to go with Option 2 tho.
Option 1
First make sure you don't have anything filtered, then make sure recording is on as shown in picture.
Option 2. RECOMMNDED
Use an http monitoring tool. They are design to do that specific task plus you get many more options such as breakpoints, etc.
Charles Proxy. (MAC) The best IMHO. You can set breakpoints and alter request/response if needed. And many other features.
HttpScoop (MAC) Easier to use, but less functionality.
fiddler (WINDOWS) Just in case.
PS. Some one might say Wireshark, I know but it's too complicated for such work.
[UPDATE 1]
To make it clear you don't need to set any proxy on iOS simulator to get these tools working. In case of SSL connections you want to use charles and follow their SSL guideline.
I use Proxyman to monitor network traffic from the iOS simulator for the following reasons -
It has a clear set of instructions on how to set it up with both iOS
simulators and Android emulators.
It has a simple, intuitive UI, which makes it easy to work with.
Also, you might find it worthwhile going through this stackoverflow post.

Windows Phone - Call default web browser

I am trying to develop Windows Phone App, I would like to know that how can I call the default web browser with a specific URL(e.g. http://www.google.com) when I launch the program?
Thanks
When you're launching "the program" as you say (Internet Explorer) you use the following code:
WebBrowserTask browser = new WebBrowserTask();
browser.URL = new Uri("http://www.google.com", UriKind.Absolute);
browser.Show();
The WebBrowser task is inside the Microsoft.Phone.Tasks namespace, the documentaion of which is here: Microsoft.Phone.Tasks.WebBrowserTask
You should also know that the "default" browser is always Internet Explorer, because right now there is no way for users to define an alternative browser as their "default".
Edit:
After reading your question more closely, I can tell there is a little bit of ambiguity. If you want to launch the browser immediately when your app launches, you should know the following:
This kind of application will fail Microsoft's marketplace validation (check the Application Certification Requirements for Windows Phone
Even if it didn't fail the certification, it would be a kind of strange application... not one that is of very much use to your users.
If, however you intend to launch the phone's browser when the user clicks a button, then the above code I posted will work just like you want it to, just make sure to include this line at the top of the code file that it's in:
using Microsoft.Phone.Tasks;
Hope that helps!

Is there any way to notify IE about changes done in registry via code?

I have done changes in registry (proxy settings) via Windows programming code.
I have to restart (reopen) Internet Explorer each time I run the code to make those changes take effect.
Is there any API in Windows programming through which I can notify Internet Explorer or Windows that changes are made to the registry and there will not be any need to reopen Internet Explorer to make those changes take effect?
Thanks.
Try this:
Change Internet Explorer 7 Proxy Setting without Restarting Internet Explorer
http://www.codeproject.com/KB/IP/Change_IE7_Proxy_Setting.aspx
Yes, with Shell apis (FAQ).
See on Win32 api group
news://nntp.aioe.org/comp.os.ms-windows.programmer.win32
I managed to do it successfully with API InternetSetOption.

Resources