Learning Android toast the long way

By | June 11, 2017

It is relatively easy to show a toast (a short message that appears on screen for a few seconds and then disappears) with the following code: Toast.makeText(getApplicationContext(), “hi”, Toast.LENGTH_LONG ).show(); The trick is trying to understand how this short hand method was created. This is what it looks like written the long way: Context context;… Read More »

Best Android 101 Tutorials

By | June 7, 2017

This site has a very high quality android tutorial. Old school versions: Make Your First Android App: Part 1/3 Android Tutorial for Beginners: Part 2 Android Tutorial for Beginners: Part 3 Updated versions: Beginning Android Development Part One: Installing Android Studio Beginning Android Development Part Two: Using Android Studio It is well worth reading both.… Read More »

What is an Android Intent?

By | June 5, 2017

The official definition is: An Intent is an object that provides runtime binding between separate components, such as two activities. (taken from: https://developer.android.com/training/basics/firstapp/starting-activity.html) In plain English, if you want to pass variables or parameters between screens (activities), use Intents

Could not find com.android.support.constraint:constraint-layout:1.0.2.

By | June 4, 2017

If you are running into this problem, it will be because Android Studio has this quirk where the constraint folder is not in the android directory structure but outside it. Let’s start from the beginning. The libraries are all in the /User/<username>/Library/Android/sdk/extras/android/m2repository/com/android/support/ However, constraint sits in a slightly different place. It is at /User/<username>/Library/Android/sdk/extras/m2repository/com/android/support/ Note the… Read More »

Cannot get versionName from AndroidManifest.xml?

By | June 3, 2017

If you are running code like this: try { PackageInfo myInfo = getPackageManager().getPackageInfo(getPackageName(),0); versionName = myInfo.versionName; verCode = myInfo.versionCode; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } TextView myText = (TextView)findViewById(R.id.textView2); myText.setText(versionName + ” – ” + verCode); but the output is not what you are expecting, the chances are you are using gradle to build… Read More »

Need a skin for the Galaxy S range?

By | May 30, 2017

If you are using Android Studio and want to emulate on a Galaxy S6 or any other phone in the S range, you can download the skin from http://developer.samsung.com/galaxy/emulator-skin/s To install it, check out this video here: https://www.youtube.com/watch?v=sSc9D4rrOxw Go to 3:24 of the video to see how to install it in Android Studio.  

Removing Github Commits

By | May 3, 2017

To rewrite history (not usually a good thing to do) you can do the following: git reset –hard <commit hash> git rebase -i HEAD~2 (the 2 goes back 2 commits) git push origin +master refresh github and you should see your commits disappear.

Hello World HTML

By | May 3, 2017

In case you forget how to create the most basic html page ever, here is a reminder:   <html> <header> <title>This is title</title> </header> <body> Hello world </body> </html>