Wednesday, January 11, 2012

Adding new Activity to Android App Package

From: http://stackoverflow.com/questions/2337874/best-way-to-add-activity-to-an-android-project-in-eclipse

you can create the activity via the manifest editor like this:

  1. Double click on AndroidManifest.xml in the package explorer.
  2. Click on the "Application" tab of the manifest editor
  3. Click on "Add.." under the "Application Nodes" heading (bottom left of the screen)
  4. Choose Activity from the list in the dialog that pops up (if you have the option, you want to create a new top-level element)
  5. Click on the "Name*" link under the "Attributes for" header (bottom right of the window) to create a class for the new activity.

When you click Finish from the new class dialog, it'll take you to your new activity class so you can start coding.

Five steps might seem a lot, but I'm just trying to be extra detailed here so that it's clear. It's pretty quick when you actually do it.

Saturday, January 7, 2012

AppleScript to Toggle usage of bluetooth speakers

Here is a script I wrote that works around a Mac OS bug on the Mac Book Pro. The issue I was seeing, was that after opening the lid to my laptop, a previously connected bluetooth speaker could no longer be connected to.

Workaround:
I found that if I simply ran "Bluetooth Setup Assistant" before selecting "Use as Audio Device" then I could reliably connect to the bluetooth speakers. I am using the Creative Labs D200 speakers, which work well.

Script:

-- Start "Bluetooth Setup Assistant to trigger bluetooth mode

-- For some reason this reliably leads to connecting to the bluetooth speaker

tell application "Bluetooth Setup Assistant"

activate

delay 3

quit

end tell

-- Toggle usage of Bluetooth speakers

tell application "System Events" to tell the front menu bar of process "SystemUIServer"

activate

delay 1

tell menu bar item 1

click

-- Un comment next line for diagnostic mode

-- set menustuff to entire contents of front menu

-- Specify your bluetooth speaker name here in place of "Creative D200"

tell menu item "Creative D200" of menu 1

click

tell menu item 1 of menu "Creative D200"

click

end tell

end tell

end tell

-- Workaround below: Only when running this script as an application

-- For some reason running this script as an application doesn't perform the final click above, so I added an additional menu click below which cause the previous click to take effect.

-- repeat to add another action

tell menu bar item 1

click

tell menu item 1 of menu 1

click

end tell

end tell

end tell

-- Un comment next line for diagnostic mode

--return menustuff