Webbrowsercontroll - Windows Phone 7 Software Development

Hello anybody
Actually I write a app to show a social website with the windows phone 7, and to control your status and more.
Now I have a problem. The mobilepage are not very good programmed (not from me ^^).
Also I need a function to set a default zoom level, and a way to disable the zoom for the users.
can you help me please ?
grezz from germany
bibox

One way to do it (and I've a feeling the only way) is to use the following sort of meta tag within the <head>... </head> section of the HTML that you are displaying in the webbrowsercontrol:
<meta name="Viewport" content="width=320; user-scaleable=no; initial-scale=1.0" />
This means of course you need to have control of the HTML that you are trying to display (it won't work unfortunately for displaying someone else's website).
More info here: http://blogs.msdn.com/b/iemobile/archive/2010/11/22/the-ie-mobile-viewport-on-windows-phone-7.aspx
Hope that helps,
Ian

He can download external HTML, save it locally, make needful changes and display from the local file Tricky but should work.

Related

Detailed weather URL not working

(by McNevin and mloamiller from T-Mobile forums)
On the weather tab, when I click on "More Detail Online" I get a 404 error page. It does the same thing on my PC, if type the address manually. I can look up detailed weather pages, I know that Athens, Greece works.
The correct address is:
http://www.accuweather.com/m/en-us/NAM/US/WA/Seattle/details.aspx
What I get when I click is:
http://www.accuweather.com/m/NAM/US/WA/Seattle/details.aspx
I searched for a registry settng that would define this URL, but the only setting I found pointed to "manila:IDS_WEATHER" or something like that (don't remember the exact syntax). I remember seeing a large number of files named "manila" in the Windows folder, and also remember someone saying this was the app name for the TF3D interface. I took a look at one of those files - they seem to be XML files, and the one I looked at had several tags such as
<trans-unit id="IDS_MENU">
<source>Menu</source>
</trans-unit>
I would be willing to bet that one of these _manila files includes an "IDS_WEATHER" tag with the actual URL that gets used by the weather app; changing that URL may fix the problem. Unfortunately, there are hundreds of these _manila files and I don't have a way to search all of them for "WEATHER".
Any ideas on how to fix this?
Don't have an answer to the specific question, but if you were to copy all of the manilla xml files on to your desktop you could then use the Windows search to search for snippets of the url within them.
However, it's entirely possible that this data is compiled into the applications binary files. If you have no luck, email accuweather and tell them there are embedded devices that have the wrong URL. They surely want the inbound traffic so it's in their interests and relatively trivial for them to set up a redirect from the broken one on their site. To be honest, this would be the best solution as it would work for everyone!
I thought of that, but the files don't have any extension (e.g. 00a49dc2_manila); doesn't Windows Search require an extension, so a specific viewer can be associated with them? I couldn't figure out how to rename all of them to have an XML (or even TXT) extension so they could be searched.
However, I just answered my own question - I remember I had Notepad++ on my machine which allows me to search through files regardless of their extension. I'll give that a shot.
I was able to search through all of the "manila" files for "WEATHER" and found 463 hits among 63 different files. Of those, "accuweather" only showed up 4 times in one file (17ae3d30_manila), but none of them are the URL I was looking for. Back to the drawing board, I guess.
That file looks to be the html page it sends you to when you hit "About" in the weather tab.
How about this:
http://forum.xda-developers.com/showpost.php?p=2488224&postcount=73

Working with an XML database

Nevermind, I found the help I needed here. I may need help later on, but for now I can continue myself.
--------------
Hey there, thanks for reading.
I'm working on my first Windows Phone application, but I'm having some trouble right now. It's an application to keep track of donations to a small children's daycare. The idea is to keep track of what has anything that has recently been donated, and what people said that they might have (for example over the phone) so they can keep track of what to expect, what to look for and what to replace in the near future.
As I'm pretty new to Silverlight and C# (I do have plenty xHTML / CSS / PHP experience) I find it hard to parse and write to the XML file correctly. I've searched on MSDN and browsed trough a few pages of Google search results, but to no avail. I did find some examples, for example using XDocument, but then MSDN said it wasn't available for SL on Windows Phone.
Basically, I need a method that, depending on the input ...
# reads all items from the XML (to show a list on the app's main page)
# reads 1 specific item (for a detail view)
or
# reads either all received, or all expected donations
Also, I'm not quite sure what would be the best way to save the DateTime value to the XML. I assumed the best way would be splitting it up in day/month/year etc, but if there's a better solution I'll gladly take your advice.
If any of you could show me an example, or give me a push in the right direction, I would really appreciate it!
My current XML layout is below:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<donations>
<received>
<!-- begin sample data-->
<donation id="0">
<dateTime>
<day>18</day>
<month>2</month>
<year>2011</year>
<hours>5</hours>
<minutes>13</minutes>
</dateTime>
<contact>Henk</contact>
<items>Football, 2 tennis rackets</items>
<money>150.00</money>
<description>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac justo dui, id aliquam erat. Aliquam quis lorem et nulla.</description>
</donation>
<!-- end sample data-->
</received>
<expected>
</expected>
</donations>

problem how to display many data in itemsControl - ListBox?

problem how to display a lot of data to a itemsControl - ListBox?
Hello everyone! I am student developers as on windows phone and I recontre a problem when I want to display in my listbox ItemsControl.
Let me explain the problem:
I said three itemsControl in my listbox;
<ListBox name="MyListBox" >
<ItemsControl name="item_BeforeHead" />
<ItemsControl name="item_Head" />
<ItemsControl name="item_Body" />
</ListBox >
After I get a "Http request" full source code of a web page and I cutting (parse) the contents into three parts: <Before head> <head> <body> to place them in the good items!
The problem is the big website containing more than 50,000 - 1000'000 characters. So more than 30,000 characters in each itemControls. And the problem is the display that's slowing my listbox! The movement is made by jerks ..
Y is there a better way to charge a lot of content and display it after?
Thank you very much in advance for your help, this was a moment I'm looking for this solution ...
And again sorry for my bad english;-)
Change your app design. The whole idea to display items 30,000 characters long is completely wrong (doesn't really matter how fast you are displaying that junk), your list/whatever become simple unreadable.
So, try to formulate your task requirements in correct way first, and look for correct solution after (4 example, if you are trying to display ebooks, there are a few possible solution etc.)
mhhh thank you ! But i found this :
http://stackoverflow.com/questions/6170640/lazy-loading-of-listbox-images-from-isolated-storage
And also this class : "LongListSelector" for windows phone 7
kingmiddle said:
mhhh thank you ! But i found this :
http://stackoverflow.com/questions/6170640/lazy-loading-of-listbox-images-from-isolated-storage
And also this class : "LongListSelector" for windows phone 7
Click to expand...
Click to collapse
I highly doubt this will be beneficial to you as I believe this is also build on the standard listbox. If you really need to store that many items, think about implementing a database, and than let the listbox directly read the data out from the database and filter the amount of results down if needed.
But like sensboston said, don't know what u are trying to do, but who is gonna read 30.000 characters? Think about parsing the content first before you add it to the listbox, so get rid of all the unwanted stuff. By building a regex which will match all the stuff you need than add each match to the listbox/database.

Include local JavaScript within PhoneGap on Windows Phone 7

I have a PhoneGap application designed to work on multiple mobile platforms. I'm loading a dynamic HTML content from an external page on the Internet using jQuery Mobile. The problematic system is Windows Phone 7.
This is what I get from the external page, with the URL of the script tag already replaced to load from the phone instead of from the net to save bandwidth:
HTML:
<script type="text/javascript" charset="utf-8" src="x-wmapp1:/app/www/test.js"></script>
This works fine on Android, iPhone and even BlackBerry when I replaced the x-wmapp1: part by a respective counterpart (e.g. file:///android_asset/www/ on Android). However, on Windows Phone 7 it doesn't seem to work at all.
When I try to load the same URL via $.getScript function, it always returns a 404 eror, even if I try and load it with a relative path only.
Any suggestions?
First of all, this type of question may be better suited to the Software Development or Apps and Games sub-forums, as a lot of the people who hang out here are more familiar with homebrew hacks. I'll give it a shot, though.
First of all, what kind of path are you trying to use? I haven't tried loading scripts or images in HTML or JS, but to dynamically load content within the app itself typically requires some care with regard to the path. For example, is the JS file being built into the assembly (as a resource) or included alongside it (as content)? How about the HTML page?
This is a kind of lame approach, but one option that's sure to work is just inlining the scripts in the page, directly. That won't increase the total app size or load time at all, although it might make maintaining the app take a little bit more effort.
Thanks for the reply, I will try to post this into the more appropriate forum.
With regards to paths - you can see the path in the HTML snippet I provided in the original question. It's all a bit specific and we cannot afford to load JS directly from page, since that does increase the size of the resulting HTML, sent from an external PHP page, thus increasing bandwidth. This is the first reason why we chose to have all JS and CSS files directly bundled with the application and load them internally rather than from Internet.
Also, all of JS files are included alongside the application as content. I'm using the same approach for all images, since if they were included as a resource, they would not show in the application.
GoodDayToDie said:
First of all, this type of question may be better suited to the Software Development or Apps and Games sub-forums, as a lot of the people who hang out here are more familiar with homebrew hacks. I'll give it a shot, though.
First of all, what kind of path are you trying to use? I haven't tried loading scripts or images in HTML or JS, but to dynamically load content within the app itself typically requires some care with regard to the path. For example, is the JS file being built into the assembly (as a resource) or included alongside it (as content)? How about the HTML page?
This is a kind of lame approach, but one option that's sure to work is just inlining the scripts in the page, directly. That won't increase the total app size or load time at all, although it might make maintaining the app take a little bit more effort.
Click to expand...
Click to collapse
First question: have you set the IsScriptEnabled proerty on the control to True? It defaults to False, preventing scripting within the control. Also, changing it only takes effect
on navigation, so if you already loaded the page and then set this property, it still won't work.
Anyhow, I missed that your HTML was coming externally, and only the scripts and stylesheets were local. That's... interesting, and seems reasonable enough, and I can't find any info online that exactly matches your use case. The way you're structuring the script src URI looks weird to me, but I haven't messed with the WebBrowserControl very much at all.
One solution, though a bit hacky:
Use the WebBrowserControl's InvokeScript function to dynamically load scripts into your pages. To do this, you would first need to load the script file content into a .NET String object. The GetResourceStream function is probably your best friend here, combined with ReadToEnd(). Then, just invoke the eval() JS function, which should be built-in, and pass it the JS file content. That will load the JS into the web page, creating objects (including functions) and executing instructions as the files are eval()ed.
Of course, you'd need to do this on every page navigation, but you can actually automate it such that the page itself requests that the app load those scripts. In your app, bind the script-loading function to the ScriptNotify event handler, probably with some parameter such as the name of the script to load. Then, on each page served from your server to the app, instead of including standard <script src=...> tags, use <script>window.external.notify('load localscript1.js')</script> and so on; this will trigger the app's ScriptNotify function for you.
I hope that helps. I can see your use case, but somewhat surprisingly, I couldn't find anybody else online who had either run into your problem or written a tutorial on doing it your way.
Thank you for your reply, it was very informative. One question though - why do you think the way I'm structuring the SCRIPT URI is wierd? I tried to mess around with relative URIs and the such, however those would load the JavaScript file from Internet rather than from the application itself.
The problem I'm running into with your proposed solutions, however is that:
1. the project is a PhoneGap/Cordova application, using its own components, so I have no idea where I would look for IsScriptEnabled here (although this all worked on an older PhoneGap release, so I'm guessing they have it set up correctly)
2. injecting a script programmatically on each navigation would require me to rewrite much of the code we already use for other platforms, not to mention those custom Cordova components, which I don't even know if they can handle such thing
As for my user case - I was surprised to be the only guy on the internet with this methodology in place as well. So it either works for everyone else or nobody really thought of doing it my way, since it's basically an Internet application (maybe the don't want to disclose their sources, who knows).
CyberGhost636 said:
1. the project is a PhoneGap/Cordova application, using its own components, so I have no idea where I would look for IsScriptEnabled here (although this all worked on an older PhoneGap release, so I'm guessing they have it set up correctly)
Click to expand...
Click to collapse
In the WebBrowser properties.
CyberGhost636 said:
As for my user case - I was surprised to be the only guy on the internet with this methodology in place as well.
Click to expand...
Click to collapse
Of course you not "the only guy". I've tried to port/run a few HTML java-script based games on WP7 (Digger and couple more) more then year ago; they runs well with one HUGE exception - touch screen events are freezing scripts execution and make games not playable.
The "x-wmapp1:" URI scheme was what I was referring to. Not sure where that comes from, but I haven't done anything really with the WebBrowser control.
I have no knowledge of PhoneGap or Cordova; I assume they're "we write your app for you" frameworks? One would assume that such tools would know to set IsScriptEnabled, but you may have to do so manually. A bit of web searching on that direction may be fruitful - maybe earlier versions enabled scripting by default, and now it's disabled by default so you have to specify an option somewhere?
Injecting the script on navigation really doesn't require any major change to the server-side code. I mean, is sending
<script>window.external.notify('load localscript1.js')</script>
really much different from sending
<script type="text/javascript" charset="utf-8" src="x-wmapp1:/app/www/test.js"></script>
? If that's too different, you could instead send
<script src="http://yourserver.com/LoadLocalScripts.js"></script>
and put "LoadLocalScripts.js" on your server with the following code:
window.external.notify('load localscript1.js');
This has only a trivial increase in server traffic and load time, but lets you continue using external scripts instead of inline ones. Very little server-side change needed at all.
Now, the additional client-side code to support the window.external.notify and call InvokeScript... normally I'd say that's dead easy, because it is if you have any experience with the .NET framework, but in your case I get the feeling that this isn't so? I code to the framework, or to the underlying native code, and I tend to code "raw" (very little auto-generated code), so I'm not going to be able to help you solve the problems with a "make me an app" wizard unless I can see the code it generates for you.
For what it's worth, here's the approximate raw code that I'd use (it's over-simplified, but close enough):
void HandleNotify (String param) {
String[] parts = param.split(" ");
if (parts[0] == "load") LoadScript(parts[1]);
}
void LoadScript (String script) {
String content = Application.GetResourceStream(new Uri(script, UriType.Absolute)).ReadToEnd();
theBrowserControl.InvokeScript("eval", content);
}
void theBrowserControl_Loaded (...event handler args here...) {
theBrowserControl.IsScriptEnabled = true;
theBrowserControl.ScriptNotify += HandleNotify;
theBrowserControl.Navigate("http://yoursite.com");
}
the URI comes from Windows Phone itself, with this code, you can see for yourself:
var a = document.createElement('a');
a.setAttribute('href', '.');
alert(a.href);
also, I've been informed that this works in Cordova 2.0, so it might be a 1.8.1 bug... will try and see how it goes
thanks for your help so far!
Looks like it was a problem with PhoneGap 1.8.1 - after upgading to Cordova 2.0 (PhoneGap got renamed) it all works now... thanks for all the help!

[GUIDE] NFC-AAAC (NFC Assisted App Access and Control)

NFC-AAAC or NFC Assisted App Access and Control
Pretext:
I have 2 children under the age of 3, all of their content (audio/video) is digital accessed. This created a disconnection for them, as they are not able to play /change the content unless my wife or I change it for them. I know there is an interest for them to be able to change the content themselves as when we have Netflix or Pandora open on the touch enables screens they are all was trying to pick the show/music they like. The few places where they do have a physical medium to play content,
The DVD player/CD player (note we have it backed up digitally), there is much interest with the “desk”. The kids would love nothing more to remove and replace it over and over. Watching this behavior over some time has lead me to believe that a simpler solution would/could be doable.
This brings me to NFC tags, with a few add-on programs the NFC tag can be scripted to perform most complicated input tasks.
Goal:
To provide access to complicated tasks via NFC.
To allow a person of limited physical input abalaty to use smart phone tech.
This can include, the disabled, the young, the old.​ To allow access to tasks/apps while driving or when attention is needed other places.​
Current Scope:
Create tags for a radio station that can be quickly taped to change station/play album.
( Keeping the driver form looking at their phone while driving).​ Create tags that auto play Netflix/Amazon Prime/YouTube/Google +/etc videos.
This may include second screen casting​ Create tags to autolaunch/call via Skype/cell phones
Want to call grandma? Or have grandma get on Skype, etc.​ Create tags to attach to things around the house foods/shapes/flashcards etc.
When was this put in the fridge?
Send text to let people know the item is all gone etc.
What was this called.
Call support.​
Where I'm at:
I'm currently gathering URIs / intents for the tasks described.
I will be using a combination of the “NFC task launcher” and “Tasker” to complete the tasks.
I will be following up with more detailed guide on how to set up functions/tasks.​What I am looking for:
Help locating the URI / intents to call to complete tasks.
More tasks, Do have someone you know / you yourself finding something more complicated than it should be let me know and we can discuss how to fix.​
Current URI list
Note Most if not all the URIs are undocumented aka may stop working, I will try to keep the list up-to-date. Please let me know if any stop working.
Pandora:
Add/Play station: pandorav2:/createStation?stationId=<stationId>​
Netflix:
Play Tv Show: nflx://www.netflix.com/Browse?q=action%3Dplay%26movieid=http://api.netflix.com/catalog/titles/series/<ShowID>​Play Movie: nflx://www.netflix.com/Browse?q=action%3Dplay%26movieid=http://api.netflix.com/catalog/titles/movies/<MovieID>​
Skype:
Audio Call User: skype:<SkypeUser>?call​Audio Call Phone / Moble: skype:<Phone#>?call​Video Call: skype:<SkypeUser>?call&video=true​
YouTube:
Play Video: vnd.youtube:<VideoID>​
Mmm, interesting.
Bye!
! !
interesting ... how did you discover the uri to launch apps with arguments?
I also used a custom URI and NFC Task Launcher to launch my app "Badge NFC" and store custom data inside the app database (look at my signature to get a playstore link) ...
furius said:
how did you discover the uri to launch apps with arguments?
Click to expand...
Click to collapse
All of the custom URIs prefixes are in the apps manifest.
If I'm lucky I can simply type it into google and find someone else that's done the work, (to get the data argument)
If not I used JD-GUI to look over the source code to trace the Android Intent path and see what the app is looking for.
Another way is to see is if the app has a web app interface. Aka if I go to the web site or get a share link, does the app autolunch the content.
I was a little confused with your question, hope this answers it.
Thanks for the interest.
odwdinc said:
I was a little confused with your question, hope this answers it.
Thanks for the interest.
Click to expand...
Click to collapse
Yes sure, that's what I was asking ... Cool!
I'll search in some of my favourite apps manifests to see if I can find something interesting ...
Inviato dal mio HTC One X con Tapatalk 4

Categories

Resources