Tuesday, December 7, 2010

Capabilities - Removing Networking and Location Capabilities

Well, well, well.... I've learnt my lesson again.  Don't use something you do not know well.  I was using the copyright object/thingamagig and did not understand what it did and what it's purpose was, but I felt I should insert my copyright in my app, so I used it.

Well it looks like it was the culprit causing my app to have a Location and Networking Capability, when my app did not have a need for either.

I found this by taking a two headed approach.

  1. I built a Hello world application, checking on the capabilities at each step.
    1. Using the new Capabilities detection tool
      1. On my Vista 64 machine it was found here after installing it: C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.0\Tools\CapDetect
      2. In a Command window (Dos Window)
      3. goto the above directory
      4. And run the following
        1. CapabilityDetection.exe Rules.xml  "C:\Users\David\Documents\Visual Studio 2010\Projects\HelloWorldWindowsPhoneApplication\HelloWorldWindowsPhoneApplication\Bin\Debug"
  2. I removed unnecessary items from the working app one by one to find running the above tool to see what the culprit was.

Microsoft's instructions can be found here: http://msdn.microsoft.com/en-us/library/gg180730(VS.92).aspx


I think Capabilities is a mis-nomer.  In my case and I think most cases we would want our apps to have the minimum amount of capabilities our apps require.  Why would a user want to buy/download an app that has a location requirement, that does not have a perceived need for it, a user would have privacy concerns.

Now I need to resubmit my apps.

Wednesday, November 24, 2010

Setting the background image for an app

For a simple Windows Phone app in the MainPage.xaml file add this line right after the opening to the Grid definition:

        <Grid.Background>
            <ImageBrush ImageSource="your Background file here.png"/>
        </Grid.Background>

Note: The background.png file is not for the app it is for the Tile when your app gets pinned to the Start Screen, and it should be 173X173. 

Is Sprint releasing Windows Phone 7 phones?

According to the Sprint Customer rep I talked to this morning, Sprint already has a Windows Phone 7 on the market.  when I had a chance to look it up online, I found they had a Windows Phone, just not a Windows 7 Phone, it was Windows Mobile 6.1, it was the HTC Touch Pro 2.

http://shop.sprint.com/NASApp/onlinestore/en/Action/DisplayPhones?phoneSKU=PPCT7380SP

A chat with a sprint.com person, said check back next week.  I just did a Google search and found this: HTC 7 Pro, Sprint's Windows Phone 7: Hands On | News & Opinion | PCMag.com

Looks like it's coming soon, don't know about everything working in landscape mode though.  The phone in question is set up to work well in landscape mode when in the open position, see the article for more details.

Last I heard it was in their lab and we should expect it second quarter 2011!

Windows Phone 7 app build and deploys but does not run

  • I could not get the app to run on the phone or in the emulator
    • It built and deployed with no errors
    • Cause: I changed the project name, and the startup App was now blank
    • Solution: Make sure to change the Startup Object on the Properties page of the Application

Thursday, November 18, 2010

Always retest in Trial mode

I released my first paid application to the Marketplace!

I decided to download it in trial version to see it running, the first thing I noticed was the trial version did not run well, as the trial version does not work with the default settings, oh well back to the drawing board, and back through the whole process to get it back into the Marketplace...

Monday, November 8, 2010

Debugging without the Debugger

I had a problem, my app worked well in the debugger, when I submitted it to the Marketplace it failed as it would not run on the phone.  I then tried to deploy it to the phone emulator, and it did not run there either.

I then figured I should rebuild the App piece by piece and check each step to see if it deployed and ran on the emulator.  I then found the method (function) that caused the trouble.

I put a trial mode in my app, and tested by faking a trial mode with a settings object saved in IsolatedStorageSettings.  My problem was I was storing the setting in Isolated Storage with a guard clause checking for the debugger (not deployed), when I did the test in the code I did not include the debugger guard clause.  So when running in the Debugger everything worked, when deployed it crashed on trying to get the isTrial setting.



IsTrial blog entry by a Microsoft Phone "evangelist", Jeff's 31 days of Windows phone is an excellent introduction to writing apps for the Windows Phone.

http://www.jeffblankenburg.com/post/31-Days-of-Windows-Phone-7c-Day-23-Providing-Trial-Versions-of-Your-App.aspx

Thursday, November 4, 2010

Regenerating a .XAP file

XAP files are used to submit applications to the Windows Phone Marketplace.

Story
I was trying to submit an app to the marketplace and kept on getting the same error, no matter how many times I rebuilt the solution and deployed the solution.

The XAP file is located in the <project>\bin\debug directory.

The timestamp on the file was not changing....

I do not know why, the documentation may have been pushing me towards it.  I opened Expression Builder and rebuilt the project (under the tools menu), and this rebuilt the XAP file.

I haven't spent much time using Expression Builder yet, I need to visit it when I make my app perform well under both orientations.

Friday, October 29, 2010

What does this mean?  Is the class supported on Windows Phone?  Am I just not reading it right?

http://msdn.microsoft.com/en-us/library/system.globalization.hebrewcalendar(VS.95).aspx


Platform Notes

Silverlight for Windows Phone:
This type is present but is not supported on Windows Phone.
Version Information

Silverlight

Supported in: 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.0

HebrewCalendar on Windows Phone 7 - Gotcha in leap years

Try converting a hebrew calendar date in Elul in a leap year using this code:


            DateTime myDateTime = new DateTime(1995, 9, 1);
            DateTime returnDateTime;
            HebrewCalendar hebrewCalendar = new HebrewCalendar();
            int jyear;
            int jmonth;
            int jday;
            jyear = hebrewCalendar.GetYear(myDateTime);
            jmonth = hebrewCalendar.GetMonth(myDateTime);
            jday = hebrewCalendar.GetDayOfMonth(myDateTime);
            returnDateTime = hebrewCalendar.ToDateTime(5767, jmonth, jday, 0, 0, 0, 0);

This will cause an error as 5767 is not a leap year and there are only 12 months in a non leap year, and jmonth is 13 in the code above.

(Elul is month 12 in non leap years and month 13 in leap years).

Solution
If the beginning year is a leap year and the end year is not a leap year
and the month index is greater than 7 //Adar II
then move the month back one


If the beginning year is not a leap year and the end year is a leap year

and the month index is greater than 7 //Adar II
then move the month forward one


            bool isLeap1 = hebCal.IsLeapYear(hYear);
            bool isLeap2 = hebCal.IsLeapYear(year);
           if ((isLeap1 & !isLeap2) & hMonth > 7)
            { hMonth--; }

           if ((!isLeap1 & isLeap2) & hMonth > 7)
           { hMonth++; }




Links:
http://www.hebcal.com/converter/?hd=11&hm=Elul&hy=5771&h2g=Convert+Hebrew+to+Gregorian+date
http://msdn.microsoft.com/en-us/library/system.globalization.hebrewcalendar(VS.95).aspx

This is a good right up with some examples on the HebrewDate class in C#.
http://www.ziporah-greve.net/prog/jewish-csharp.html


Side note:
This became much clearer to me when I had to create example code from my code.

Wednesday, October 27, 2010

DateTime picker?

The DateTime picker is not in the original developer toolkit, but it is in a new download.

Silverlight for Windows Phone Toolkit - Sept 2010
http://silverlight.codeplex.com/releases/view/52297

Phone Emulator orientation and keyboard input

When using the phone emulator with the PC keyboard the Orientation of the app does not change.



Radio Button groups

  • There is no Tab Group box in the toolbox
    • Solution: use GroupName in the .xaml file
    • eg.
            <RadioButton Content="Male" Height="72" HorizontalAlignment="Left" Margin="293,102,0,0" Name="maleRadioButton" VerticalAlignment="Top" Checked="maleRadioButton_Checked"
                         GroupName="MyRadioBtnGroup"/>
            <RadioButton Content="Female" Height="72" HorizontalAlignment="Left" Margin="292,177,0,0" Name="femaleRadioButton" VerticalAlignment="Top" Checked="femaleRadioButton_Checked" 
                         GroupName="MyRadioBtnGroup"/>

The traditional way of dealing with multiple radio buttons, with "one checked" behaviour, is to put the Radio Buttons in a group box.  The Toolbox in the Windows Phone 7 Toolkit does not have a group box.


I was trying to do it programatically, and could not find a simple way to programatically set the state of the Radio Button, trying to use SetValue required a DependencyProperty...