Level Up – Android: How to get started with Android Wear and the Wearables Emulator

Recently, I started working on Android Wear for the first time. It’s been fun playing around with the new platform and form factor. And, of course, the official Android docs that I read could be condensed further for absolute newcomers. So, in the typical fashion, I’ve created myself a cheat sheet that I would use next time I would want to learn the easiest way for how to best create Wearable apps.

I’ve open sourced all my code so far on GitHub. It includes how to first set up the virtual Wear device, connect to the handheld device, and how to have the app send and open a notification on the wearable.

https://github.com/danialgoodwin/android-wear

~ Danial Goodwin ~

Level Up – Android Dev: KeyboardlessEditText

Today, I’ve released a new open source project that has help me build my latest app. I needed an EditText with fully capabilities, except for the keyboard showing up. All of the possible answers that I found on StackOverflow and GitHub all had their limitations, especially the lack of native editing (cut/copy/select/paste) options.

All of the problems have been abstracted out to a simple subclass of EditText that you can use easily in any project.

You can try it out on GitHub now: android-widget-keyboardless-edittext

If you have any questions or need clarifications on how to use the project, then please let me know.

~ Danial Goodwin ~
Apps

Prefix Words With AutoHotKey

Ever needed to prefix many variable names? Here’s the solution.

Watch part of this short video real quick to see what the following code is used for: http://www.youtube.com/watch?v=HQJHFKaLje4

So, what’s happening in the video? I recently had a long list of variables, and using a simple key command, I add a prefix to the variable names and capitalize the entire variable name as a best practice, because it is a constant. For all of the work shown on-screen, I only used a simple key command over and over. Here’s the entire AutoHotKey code that I used.

; Add prefix and capitalize work
#t::
    Sleep, 300
    ;; Double-click
	MouseGetPos X,Y
	Send {Click  %A_CaretX%,%A_CaretY% 2}
	MouseMove (X),(Y)
    Sleep, 20
    ; Go to left of word
    Send {Shift Down}{Ctrl Down}x{Ctrl Up}{Shift Up}{Left}
    ; Add prefix
    Send TAG_{Down}
return

Check out my other AutoHotKey cheat sheets:
- Stringify Variables with AutoHotKey

Danial Goodwin -
Computer Engineer | Co-Founder and Lead Developer for Simply Advanced, LLC

Stringify Variables with AutoHotKey

Ever needed to make many Strings based off of variable names? Here’s the solution.

Watch this 13 second video real quick to see what the following code is used for: http://www.youtube.com/watch?v=1JxEiZ9nIsg
Stringify Variables With AutoHotKey

So, what’s happening in the video? I recently had a long list of variables, and using a simple key command, I turn the variable name into a String and more. For all of the work shown on-screen, I only used a simple key command over and over. Though, I could have made my basic AutoHotKey a lot more sophisticated. Here’s the entire AutoHotKey code that I used. The only reason for the Sleep/wait functions is because AutoHotKey was sending the commands too fast to process.

; Press WindowsKey + t to select word cursor is on,
; then add String suffix with variable name in it.
#t::
    Sleep, 300
    ; Double-click
	MouseGetPos X,Y
	Send {Click  %A_CaretX%,%A_CaretY% 2}
	MouseMove (X),(Y)
    Sleep, 20
    ; Copy
    Send {Ctrl Down}c{Ctrl Up}
    Sleep, 40
    ; Paste
    Send {Ctrl Down}v{Ctrl Up}
    Sleep, 40
    ; Move to end of line, behind semi-colon
    Send {End}{Left}
    ; Prefix with ` = ""`
    Send {Space}={Space}""
    ; Move inside quotations
    Send {left}
    ; Paste
    Sleep, 20
    Send {Ctrl Down}v{Ctrl Up}
    Sleep, 40
    ; Prepare for next copy-paste
    Send {Down}{End}{Left}{Left}
return

Notes:
- After first copying word, instead of pressing {End}{Left}, I probably could have just send {Right} to move the cursor to the right.
- AutoHotKey might send commands faster than Windows can process them, so the system waits with the `Sleep, ` command. You may need more system pauses (or not).
- There probably is a way to slow down the entire AutoHotKey program, but I didn’t feel like looking that up yet. If you know how, please let me know. ;]

Check out my other AutoHotKey cheat sheets:
- Prefix Words with AutoHotKey

Danial Goodwin -
Computer Engineer | Co-Founder and Lead Developer for Simply Advanced, LLC

Simple way to add HTML5 PHP contact form for Bluehost

Yesterday, I spent some time figuring out how to add my own PHP code to make an email contact form work properly. Unfortunately, PHP’s mail() function didn’t work for Bluehost servers hosting the contact form on my site. There seems to be some special code required for Bluehost. Here’s what worked for me:

Continue…

Android: How To Decode ProGuard’s Obfuscated Code From Stack Trace

(This post is for Android developers who use ProGuard in their app and need to do some debugging with the encrypted stack trace. It’s really simple to return the file to a human-readable condition.)

BEFORE
Here’s the stack trace as obfuscated by ProGuard:

Caused by: java.lang.NullPointerException
at net.simplyadvanced.ltediscovery.be.u(Unknown Source)
at net.simplyadvanced.ltediscovery.at.v(Unknown Source)
at net.simplyadvanced.ltediscovery.at.d(Unknown Source)
at net.simplyadvanced.ltediscovery.av.onReceive(Unknown Source)

AFTER
All you need to do is write one line in the command prompt, and the obfuscation will be removed, as you can see here:

Caused by: java.lang.NullPointerException
at net.simplyadvanced.ltediscovery.UtilTelephony.boolean is800MhzNetwork()(Unknown Source)
at net.simplyadvanced.ltediscovery.ServiceDetectLte.void checkAndAlertUserIf800MhzConnected()(Unknown Source)
at net.simplyadvanced.ltediscovery.ServiceDetectLte.void startLocalBroadcastReceiver()(Unknown Source)
at net.simplyadvanced.ltediscovery.ServiceDetectLte$2.void onReceive(android.content.Context,android.content.Intent)(Unknown Source)

HOW TO DECODE STACK TRACE
You can choose either the command line method or GUI (Graphical User Interface) method.

Continue…

How To Edit App Studio Code

(If you don’t know what App Studio is, then you can read my description and review in my previous blog post.)

Background
This post assumes that you have already used App Studio to create your Windows Phone app and exported the code. The template I used was the “My City” template (typically the top-left and largest one). So, if you used a different template, then your file names will not be the same as mine, but hopefully, the directory names that I point you to will vastly help narrow your search for the proper code to edit. The purpose of this post is to just help you find the files to edit the data you put in App Studio and to help you edit the views/templates you chose also. There is also a small section on the errors you may encounter and the end of this post have some additional resources for further editing your app.

Continue…

Android: Recent Learnings

For the past two weeks, I have been in a serious coding mode. I barely read any of my daily or weekly new feeds and that created lots of time to write code for my Android app (which just had a huge update with a code rebase).

So, I was going to write some quick walkthroughs on how to use the many different APIs I’ve learned how to use for the first time. But, instead I’m going to provide a list here, and anybody that emails me regarding this post, then I will create a walkthrough/tutorial specifically for them.

Continue…