Sunday, April 29, 2012

TIP: Location of Windows 7 Start Menu Files

[Updated 11 Dec 2012]

As is often the case with a new Windows release, the file structure has changed again with Windows 7. If you need to tweak the Start Menu, it has again been relocated.

It's in such an odd place, it seems every time we need to make a change, we have to relearn where it is. Below, we give the Start Menu locations for individual accounts and for the master Start Menu, which includes menu items you wish to display for all users.



If you want to change the Start Menu for one user only:
     C:\Users\[username]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\

If you want to change the Start Menu for all users on your machine:
     C:\ProgramData\Microsoft\Windows\Start Menu\Programs\


Before you move on, please +1, bookmark, and/or link back to this article so you can keep it handy.

Wednesday, April 18, 2012

HOW TO: (Android) Rotate the Screen on your Emulator

Want to see what your layout looks like when rotated 90ยบ?

     Use     [Cntl] + [F11]






HOW TO: Create a New Thread in Java

Here's how to create a new Thread.

      new Thread() {
          public void run() {
              // insert code to be done by new thread here
          }
      }.start();

TERMINAL TIP: Handy ADB Commands (Android Debug Bridge)

Here are some very useful commands. To use them, you must have installed the Android SDK (Software Development Kit), which includes the command line tool ADB. When you have installed it, you can then open a Windows command window.

adb devices                   lists connected devices
adb [-d | -e] shell           connects terminal mini-bash shell to device (-d) or emulator (-e)





Once in the debug shell, try these commands

kill-server                cuts connection to emulator

start-server              [re-]connects eclipse to emulator

logcat                      displays running log in a terminal windows
logcat TAG:* *:S   filtered: TAG:* = only show all TAG entries; *:S = all others Silent
                                   [ TAG corresponds to Log.d(TAG, "msg"); in .java code ]


input keyevent 82        unlocks screen of connected device






HOW TO: Add a Menu for an Android App using Java in Eclipse

These are the steps needed in order to add a menu.

    1. File > New > class: BaseActivity
    2. Modify to read "BaseActivity extends Activity"
    3. CTL-SHFT-O    Organize Imports
    4. [HoverOver]    Click:    Add unimplemented methods
    5. Put common functionality such as menu items here
    7. As you add menu items, add functionality as part of a CASE: statement
    8. File > New > Android XML file > menu.xml
    9. Make sure you set the icon property in the menu.xml
  10. Update Android.manifest
  11. Update new child activity pages like this: NameOfActivity extends BaseActivity

Saturday, April 14, 2012

HOW TO: Add a Resource Library in Eclipse

To add a new resource library file into your project, follow these simple steps.
  • Drop the file into your project's root directory
  • Open Package Explorer
  • Right-Click on the project name
  • Select 'Refresh' (or press F5)
If it's a JAR file, you also need to add the new library to the class path:
  • Right-Click on project name
  • Select 'Properties'
  • Select 'Java Build Path'
  • Select 'Libraries'
  • Select 'Add JARs'
  • Select 'Refresh' (or press F5)

SOLVED: R.layout.main cannot be resolved to a variable

This is a misleading error message. A telltale symptom is your class file contains
import android.R; in your imports list. Remove this line, then look for the real cause of the error message.

More than likely, there is an error in a /res file preventing the project's 'R' file from being generated. If Eclipse can't find one, it will use Android's 'R' file. Check your /res folder for errors (red icons indicate errors). Finding the root cause might not be easy, but once you find and fix the error (and save it), a new 'R' file will be automatically generated.

When that happens, all should again be well with your code.

SOLVED: Eclipse Update - Connection refused (https://dl-ssl.google.com/android/repository/)

[Updated 28 January 2013]

Every time I try to update Eclipse, I get a variation of this error message.

Connection refused (https://dl-ssl.google.com/android/repository/)

There are several solutions to this issue. Google recommends using the non-secure variant of the repository address, http://dl-ssl.google.com/android/repository/, but I no longer travel this road. I've discovered that once I get the parameters correct for the non-secure site, the secure site will also work. To me, this just means an extra, unnecessary step. Since I prefer using the secure connection, I simply skip down to my short list, provided below, of things that might work. Sometimes, it requires a combination of solutions in order to update correctly. Persistence will pay off!

SOLUTION 1:
Make sure your firewall is set to allow Java, Eclipse, and Android SDK to get out and check for updates (preferred) ... OR turn it off (much more risky).

SOLUTION 2:
Check the URL you're using against the one published on the Android site. The address changes sometimes, so make sure it's the latest one. If it's different, you can try simply updating the address, but your best bet is to update the SDK.

SOLUTION 3:
Try a different network environment.

In certain recent versions of the Windows environment, the SDK Manager must be RUNAS the system administrator (not just any old administrator) as a standalone. This will, by virtue of the relationship between the SDK and Eclipse, update the appropriate add-ons in Eclipse. If you use this solution all the time, you should remove the address from Eclipse's add-ons repository list.

SOLUTION 4:
If you use a proxy server, try this. If not, skip to the next solution.
1. Open a command prompt or terminal window
2. Navigate to the directory in which android.bat resides (the SDK install location)
3. Backup android.bat (in case this fix doesn't work, you will need to revert to the original)
4. Locate the line (near the bottom, very long) that contains %REMOTE_DEBUG%
5. Add the following parameters, using actual values
* Replace [myProxyServer] with the name of your proxy server
* Replace [myProxyPort] with the port number your proxy server uses
-DproxyHost=[myproxyserver] -DproxyPort=[myProxyPort]
6. Save the new android.bat file
7. Restart SDK Manager
8. If problem persists, remove the new android.bat file and restore the original file

SOLUTION 5: For Mac users (may work for other platforms, too)
When the error occurs, click CANCEL, then Update SDK Manager, then Restart SDK Manager.

SOLUTION 6:
Take a look at this post for new ideas. A couple of the solutions in this list were gleaned from here. If you find one that works that's not in this list, please let us know by leaving a comment below.
http://code.google.com/p/android/issues/detail?id=21359

SOLUTION 7: (aka The Last Resort)
Uninstall/Reinstall latest Eclipse _AND_ Android SDK.



28 January 2013

For a recent Tools update, I kept getting a message from Android SDK that the ...\tools directory was in use. Of course, as dumb as it sounds, the program that had locked this directory was the very same Android SDK!!! Here's how I fixed that.
1. Close Eclipse and Android SDK, if running.
2. Manually rename the \tools directory to the destination folder name in the error message. In my case it was ToolPackage.old02.
3. Move the renamed folder via DragNDrop into the ...\temp folder.
4. I found the new version tools_rXX-windows.zip in my ...\temp directory & extracted the tools directory in the SDK root directory.

For example, the newly extracted folder on my Windows 7 machine is c:\Dev\android-sdk-windows\tools.