How to get Titanium to recognise Samsung Galaxy Tab 2 as an Android device

When I first plugged my new Galaxy Tab 2 into the USB port a notification message popped up on my Windows 7 PC (64 bit) to say that the drivers had been automatically installed. Brilliant. That meant I could just expect Titanium to recognise it as a device and install my app on it right? Wrong. The Android SDK just wasn’t recognising it at all.

Note: To discover the devices that the SDK does recognise (if any), go to the command prompt, change directory to C:\Program Files (x86)\Android\android-sdk\platform-tools and then type adb devices.

If you Google then you will get some of the way there: you will find that on your Android device you need to go to Settings->Developer Options and then check the USB Debugging and Allow Mock Locations boxes. I did it. I reconnected the USB. Rebooted both the device and PC. Still no joy. Then commenced lots of randomish pressing of buttons until I figured it out. With the USB connection plugged in to the PC you need to go to the USB icon in the Galaxy Tab’s notification bar (next to the clock). Press it and some options will pop up. Press on the ‘Connected as media device’ menu option. You will see that you can connect as a Camera (PTP) instead. Click this. Unconnect the USB cable. Reconnect. Some more drivers will be installed. The MTP driver will fail (well it did on mine anyway) but this doesn’t seem to matter. Check the devices again and you should see a new one listed!

Now if you ‘Install on Android Device’ in Titanium it should automatically pick it up. Note that Titanium only likes having one device connected at a time too.

AutoIt macro for automating Titanium splash screen generation using Paint.NET

A Titanium mobile application has many different splashscreens which are shown when the app starts up. Most of them are for Android apps, which can have a variety of different screen sizes.

I use Paint.NET to create/edit graphics which is great (and free!), but after I did my first screen I could see that it was going to be very tedious to have to go in half a dozen times, resizing and changing the directory each time. This is what macros are for but unfortunately Paint.NET does not have any built in ones. So I found AutoIt, which is a great little tool. Wish I’d found it earlier!

Here is my script for generating landscape splashscreens from a master copy. Note that the dimensions are taken from here, I have not tested with every type of device. Sorry, no code highlighting here, WordPress doesn’t do AutoIt! Portrait script is similar except that you need a couple more for the iPhone too.


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; AutoIt macro to create all the landscape splash screens for a Titanium 2.1 mobile app.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

$pictureDir = "C:\Users\Fred\Pictures\"  ; Picture root directory - where your original file should be
$outputRootDir = $pictureDir & "AppName\" ; The name of the directory to put your output files (relative to pictureDir) 
$fileName = "NWFBsplash.png"  ; File name of the big iPad image in pictureDir.

$iphoneDir = $outputRootDir & "iphone\" ; iPhone directory
$androidDir = $outputRootDir & "android\" ; android directory
$androidRLLHDir = $androidDir & "res-long-land-hdpi\"
$androidRLLLDir = $androidDir & "res-long-land-ldpi\"
$androidRNLHDir = $androidDir & "res-notlong-land-hdpi\"
$androidRNLMDir = $androidDir & "res-notlong-land-mdpi\"
$androidRNLLDir = $androidDir & "res-notlong-land-ldpi\"

$titleSuffix = " (100%) - Paint.NET v3.5.10" ; Might need to double check your window title here! 100% means fullscreen

$paintDotNetWindowTitle = $fileName & $titleSuffix

; Create output directory if necessary
If DirGetSize($outputRootDir) = -1 Then
   DirCreate($outputRootDir)
Endif 
   ; Create iPhone output directory
if DirGetSize($iphoneDir) = -1 then
   DirCreate($iphoneDir)
EndIf
   
; Create android output directories
if DirGetSize($androidDir) = -1 then
	  DirCreate($androidDir)
EndIf
	  
	  if DirGetSize($androidRLLHDir) = -1 then
		 DirCreate($androidRLLHDir)
	  EndIf
	  
	  if DirGetSize($androidRLLLDir) = -1 then
		 DirCreate($androidRLLLDir)
	  EndIf
	  
	  if DirGetSize($androidRNLHDir) = -1 then
		 DirCreate($androidRNLHDir)
	  EndIf
	  
	  if DirGetSize($androidRNLLDir) = -1 then
		 DirCreate($androidRNLLDir)
	  EndIf
	  
	   if DirGetSize($androidRNLMDir) = -1 then
		 DirCreate($androidRNLMDir)
	  EndIf
	  
  
   
   


; Set working directory to pictureDir
FileChangeDir ( $pictureDir )

; Load up the image into Paint.NET and wait for it to load.
Run("C:\Program Files\Paint.NET\PaintDotNet.exe " & $fileName, $pictureDir)
WinWaitActive($paintDotNetWindowTitle)

; Find the 'Maintain aspect ratio' flag on the resize screen.
$aspectRatioMaintain = RegRead("HKEY_CURRENT_USER\Software\Paint.NET", "LastMaintainAspectRatio")



;;;;;;;;;;;;;;;;;;  iPad - note that iPhone has no landscape splash screen

PopUpResize()

; If the maintain aspect ratio flag has been checked then uncheck it.
; Then send the new width and height and click OK (using ENTER).
if $aspectRatioMaintain == "True" Then
   Send("!m{TAB}1024{TAB}748{ENTER}")
   $aspectRatioMaintain = "False"
Else
   Send("1024{TAB}748{ENTER}")
EndIf

DoSaveAs($iphoneDir, "Default-Landscape.png")


;;;;;;;;;;;;;;;;;; Android high-def long

PopUpResize()
Send("800{TAB}480{ENTER}")
DoSaveAs($androidRLLHDir, "Default.png")


;;;;;;;;;;;;;;;;;; Android high-def notlong

PopUpResize()
Send("800{TAB}480{ENTER}")
DoSaveAs($androidRNLHDir, "Default.png")

;;;;;;;;;;;;;;;;;; Android med-def notlong

PopUpResize()
Send("480{TAB}320{ENTER}")
DoSaveAs($androidRNLMDir, "Default.png")

;;;;;;;;;;;;;;;;;; Android low-def long

PopUpResize()
Send("400{TAB}240{ENTER}")
DoSaveAs($androidRLLLDir, "Default.png")

;;;;;;;;;;;;;;;;;; Android low-def notlong

PopUpResize()
Send("320{TAB}240{ENTER}")
DoSaveAs($androidRNLLDir, "Default.png")

; Close Paint.Net
WinWaitActive($paintDotNetWindowTitle)
WinClose($paintDotNetWindowTitle)
; End of Script

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func PopUpResize()
   WinWaitActive($paintDotNetWindowTitle)
   ; Send the resize command and wait for the resize window to open.
   Send("^r")
   WinWaitActive("Resize")
EndFunc

;;;;;;;;;;;;;;;;;;
Func DoSaveAs($dir, $file)
   WinWaitActive($paintDotNetWindowTitle)
   ; Send the Save As command and wait for the Save window to open.
   Send("^+s")
   WinWaitActive("Save As")

   ; Send the name of the file
   Send($dir & $file & "{ENTER}")

   ; If prompted that the file already exists then choose Y to overwrite.
   WinWaitActive("Confirm Save As", "", 2);
   Send("!y")

   WinWaitActive("Save Configuration");
   Send("{ENTER}")
   $paintDotNetWindowTitle = $file & $titleSuffix
EndFunc