29 February 2012

How to: Move Photos from Flickr etc into Picasa

I used to love Flickr but the interface has been stale for some considerable years now and despite the fact its apparently getting a make over I’m tired of it. I logged in today and saw:

"Your pro account has expired". Great.. so all my photos have been binned or what? I can only get at them if I re-pay. Thanks for letting me know about that, some warning next time perhaps?! They probably did email me but seriously who subscribes or reads mail outs?

There are lots of my photos on there which I need to move somewhere. Personally I’m using Picasa web albums as my online photo sharing solution at the moment. Here are my notes on moving files across to Picasa. Even if you don’t want to use Picasa this might be useful as a stepping stone to moving them somewhere else.
Note these process do involve downloading your photos and uploading them so will use a lot of your internet bandwidth. Be warned if you have data limits you might go over them. I'll add other migration tools as I find a need for them!
  • Flickr: I used Migratr: download, install, run, authenticate with Flickr then follow the wizard like process.
  • Facebook: Automatically: I used a Google Chrome plugin called Move Your Photos Login, select the photos you want to move and click Upload.
    Alternatively you can go to https://www.facebook.com/settings and go to the link at the bottom:  “Download a copy of your Facebook data.” This will prepare a zip file with your data which will contain your photos.

25 February 2012

Fix for: Launching DOM2XmlPullBuilder Error

Sometimes in eclipse when you try to debug or run a project you get an error:

AndroidRunError

‘Launching DOM2XmlPullBuilder’ has encountered a problem.
Launch configuration DOM2XmlPullBuilder references non-existing project shared-sample-docs

The Fix

Right click the project and select Run As, and then the relevant application type e.g. Android Application.

14 February 2012

Windows Media Center Media Center Extensibility Host has stopped working

After returning from a weekend away I turned on my XBox to watch some recorded TV only to find a message like: “Windows Media Center had to be restarted, please check your recording schedule” and when I clicked OK a “Set Up Live TV” icon was where the guide should be. As you can imagine my heart sank. Why is it that of all the OS’s I had to choose one from the producer of the least stable one for my DTVR?! As often happens the message didn’t really convey they seriousness of the situation, the root cause or how to resolve it.

I tried a remote desktop onto the box and I found it was behaving strangely: being incredibly slow and locking up at the simplest of requests (e.g. task manager). The process responsible seemed to be ehvid.exe described as "Windows Media Center Video Analysis Process" which I believe makes the Media Center Recoded TV icons. When I went into a recorded program it would become even slower and eventually I’d get the message: “Windows Media Center Media Center Extensibility Host has stopped working”.

Searching for information about the ehvid.exe process running amok and the error message led me to believe if I cleared the guide data and tuner setup (including program meta data) the program data would be re-created and the problem resolved.

To Clear The Guide Data and Tuner Setup

I found a page on doing just that:
http://www.ehow.com/how_7158323_clear-windows-media-center.html
I found I needed to modify that process slightly so here are my steps:

  1. Move all your recorded TV out of the Recorded TV folder: it’s likely that one of the programs contains corrupt data which caused the problem in the first place.
  2. Stop all Windows Media Services: Control Panel; Services; Stop services: “Windows Media Center Receiver” and “Windows Media Center Scheduler”.
  3. Stop WM Processes: Task Manager; Processes tab; Click Description Tab to arrange alphabetically; Kill anything related to Windows Media Center.
  4. Delete the data: In Explorer; "C:\ProgramData\Microsoft\ehome." (you may need to show hidden folders: Press Alt; Select Tools, Options; View tab; Show hidden files, folders and drives).
  5. Restart the machine.

NB: Don’t put your recorded TV back yet!

Re-Setup TV

After moving out the files and deleting the data you need to re-setup your TV so you need to log in NOT using remote desktop: Media Center knows you’re logged in via remote desktop and doesn’t give you the option to setup. You could use TightVNC or LogMeIn to gain remote access. (don’t forget to add exceptions to the firewall if using VNC. Click on the “Setup Live TV” icon in Media Center (or go to Tasks; TV; Setup TV) and go through the process.

Once you’ve re-setup TV you can then add your recorded TV back in but I’d recommend you avoid doing it if possible: it is likely that one of the programs contains corrupt meta data. If you must then do it one at a time and only add stuff that pre-dates the failure and has an icon.

12 February 2012

Android App to Save Any File to disk: AToolBox

I have built a utility app for Android which enables the saving of any file to disk, then manually choosing which application to use to open it.

SC20120211-120243I love Google Docs and now they have added an offline ability to the Android I love it even more, but I use it to keep a lot of different file types, not only word and spread-sheet files. This is where the app falls down for me: If I select a file type that the Android system doesn’t recognise I can’t do anything with it. Sometimes I just want to add a file as an attachment to an email and so need to save it to disk first. I know this is possible via the Google Docs web interface (open it, select file and send as attachment) but I prefer to use the application, and anyway I find the Google Docs web interface doesn’t work well for me on either of my Android devices in the native (or other) browser.

AToolBox is available in “Complete Action Using” dialogue
Application List, from where you can choose an application to open the file.

SC20120211-120227
When you select ‘Open’ from the Google Docs application or any file handling application (e.g. Astro or a browser download) AToolBox will present itself as an option in the “Complete Action Using” dialogue and from there you can choose to save it to disk or try and open it directly. I find for most applications you need to save it to file first.


You can install AToolBox from here:
http://market.android.com/details?id=com.coultard.atoolbox
Give it a go and let me know any problems or suggestions.

07 February 2012

How To: Android ListView without ListActivity

All the ListView examples I could find inherited from a ListActivity but I had occasion not to and found this good example so wanted to record it here:
http://windrealm.org/tutorials/android/listview-with-checkboxes-without-listactivity.php
Thanks to Andrew Lim for this post.

How To: Create an Android App with AdMob Ads

NB: As of 1st May 2012 AdMob for mobile websites is discontinued. Use AdSense for mobile websites. AdMob is still valid for mobile applications however.

I found the documentation or a simple “How To” to get a simple Android App with AdMob ads lacking so here are my notes for reference (AdMob SDK 4.3.1). It’s a long post but it’s explicit so hopefully you should find it easy to follow.
Get the AdMob Publisher ID and SDK
  1. Choose an App Name and a package name e.g. com.coultard.Test (Java package names are domain names in reverse by convention to enforce uniqueness).
  2. Sign up for an Admob Account at http://www.admob.com
    1. Go to Sites and “Add Site/Apps”
    2. Choose Android App
    3. Enter App Name, Package Url (e.g. market://details?id=com.coultard.Test) and other details.
  3. Get the AdMob SDK and “Publisher Id”:
    1. Under Apps/Sites; Click on your application, click ‘Manage Settings’. Publisher Id is listed under the title and the SDK is available under “Get Publisher Code”. Personally I find this navigation obscure.
    2. Download and extract the SDK
Create an App
I have covered getting started with eclipse and Android Apps in another post here. Follow that and the Hello World example. Load up that app or create a new one and follow these directions (or the official ones):
  1. Import The AdMob SDK:
    1. In Eclipse Project Explorer Create a folder called ‘lib’ under the application.
    2. Right click the folder and select Import; General; File System; Choose the downloaded SDK (extracted) folder and select the GoogleAdMobAdsSdk[version].jar
  2. Add the SDK to the build path: Right click on the jar file in Project Explorer and select Build Path; Add to Build Path. You’ll see it’s filename added directly under the Project folder with a jar icon.
  3. Target Android >=3.2 (Android SDK 13): Right click the project in Project Explorer and select Properties; Android, then tick 3.2.
    Optionally you might need to change the uses-sdk element in the AndroidManifest.xml. As of writing the AdMob SDK 4.3.1 requires 3.2 or you’ll get an error in the manifest as below, note you can use a different ‘uses-sdk’ version but you are then responsible for checking you do not use any backwards incompatible code.
    If you target the wrong SDK you’ll get: ”Error: String types not allowed (at 'configChanges' with value 'keyboard|keyboardHidden|orientation|
    screenLayout|uiMode|screenSize|smallestScreenSize').
    If you get this error try a clean: Project (menu); Clean
  4. Add necessary elements to manifest:
    1. uses-permissions:
      <uses-permission android:name="android.permission.INTERNET" />
      <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    2. AdMob activity:
      <activity android:name="com.google.ads.AdActivity"
      android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />   
  5. Add your AdMob PublisherID as a value: Open [Project]\res\values\strings.xml and add a string named admob_pub_id or similar:
    <string name="admob_pub_id">[publisher id e.g. f12k78d8h62834s2]</string>
  6. Add the AdMob layout element to your res\layout\main.xml:
    1. Add the xmlns:ads property to LinearLayout:
      <LinearLayout  …   xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"…/>
    2. Add the actual AdMob element (You can add a AdMob element dynamically too):
      <com.google.ads.AdView
              android:id="@+id/adView"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              ads:adSize="BANNER"
              ads:adUnitId="@string/admob_pub_id" />
      You might like to have the ads at the bottom of the view so to do this add a new LinearLayout above it (as a sibling) and add the android:layout_height and android:layout_weight property so you end up with a file constructed like this:
      <LinearLayout with xmlns:ads…>
        <LinearLayout
          android:layout_height="0dp"
          android:layout_weight="1"…>
        [Your apps main content goes here]
        </LinearLayout>
        <com.google.ads.AdView… />
      </LinearLayout>
  7. Add code in the main Activity to load adverts after setContentView(R.layout.main);
    adView.loadAd(new AdRequest());
    Or for testing use:
    AdRequest adRequest = new AdRequest();
    adRequest.addTestDevice(AdRequest.TEST_EMULATOR); // Emulator
    AdView adView = (AdView) this.findViewById(R.id.adView);
    adView.loadAd(adRequest);

    NB you can get your device ID on running the code: see below.
Launch it
Using an emulator: Click Debug or Run and select the relevant emulator.
Using your phone:
  1. Ensure you have the phone connected and debugging enabled: Settings; Applications; Development; USB debugging.
  2. To get ads in test mode run it in  Debug mode and you’ll get a message like the following in LogCat at the bottom of the eclipse screen:
      ”To get test ads on this device, call adRequest.addTestDevice("[device id]");”
    Add a new constant for your device’s id:
      private static final string TEST_DEVICE = “[device id goes here]”;
    And insert the line:
      adRequest.addTestDevice(TEST_DEVICE); // Test Android Phone
    After the one adding the emulator mentioned above.

03 February 2012

IIS 7 Command Line Tools: Start and Stop Sites via Command Line

Install IIS 7 Management Scripts and Tools

To use IIS command line tools you will need to install IIS Management Scripts and Tools:

  1. Control Panel; Programs and Features; Turn Windows Features on or off (left hand side)
  2. In Windows Features box Expand Internet Information Services; Web Management Tools and select IIS Management Scripts and Tools:
    IISScriptsAndTools
  3. Select OK and wait while it installs.

To Start and Stop a Site from the Command Line

  1. Open a command prompt: Start, cmd, Enter
  2. Enter the code below:
    %systemroot%\system32\inetsrv\APPCMD START Site [Site.Name]
    Replacing [Site.Name] with the site’s name.

The command takes the following format:
APPCMD (command) (object-type) <identifier> < /parameter1:value1 ... >*

You could use this as part of a project build script to reset the site before debugging.

Ref: http://learn.iis.net/page.aspx/114/getting-started-with-appcmdexe/

02 February 2012

Fix for: Web Deployment Project “The configuration file has been changed by another program.”

I received the error below when using a Web Deployment Project to build and publish my Web Application locally:

“Microsoft.WebDeployment.targets(1024,9): error : The configuration file has been changed by another program.”

I was using Web configuration section replacements and so I figured it was to do with that:

WebDeploymentProjectConfigSectionReplacements

I double checked the deployment project xml (right click project in Solution Explorer, Open Project File). It had duplicated the entries like the second ‘appSettings’ below, but even removing those didn’t sort it:

<ItemGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
  <WebConfigReplacementFiles Include="config\appsettings-debug.config">
    <Section>appSettings</Section>
    <Section>appSettings</Section>  <<<< DUPLICATE
  </WebConfigReplacementFiles>
  <WebConfigReplacementFiles Include="config\customerrors-debug.config">
    <Section>system.web/customErrors</Section>
  </WebConfigReplacementFiles>
</ItemGroup>

The Fix

I realised whilst the deployment project was set to copy the output to a local IIS folder I’d also done some debugging in situ i.e. in the project’s own folder. So I also had an entry in the web.config to ‘import’ the relevant configuration file like this:

<appSettings configSource="config\appsettings-debug.config" />

When I removed the link to the external file all was well again, leaving the entry in web.config like:
<appSettings />
NB I also had to disable “Enforce matching section replacements” which checks that the replacement section has the same number of entries as the existing one otherwise you get an error like this:
”web.config(11): error WDP00001: section appSettings in "web.config" has 0 elements but "config\appsettings-debug.config" has 2 elements”