Android Studio – Setting Member and Static Field Prefixes

While there is huge debate over the advantages and disadvantages of Hungarian notation and I generally disagree with much of it, I do still find it useful to differentiate member and static variables with the prefix m and s.

However, by default in Android Studio if you do that you and use code generation, such a generating getters and setters, it will include the prefix as part of the name for the generated code.  Thus a variable named mName which generate the getter  getmName() which gets annoying pretty quickly.

Fortunately there is an easy fix.  You can configure the prefixes for field and static fields in settings (File->Settings->Editor->Code Style->Java->Code Generation).  In this case the name prefixes can be set to “m” for member fields and “s” for static fields as shown below.

SettingsEditorCodeStyleJavaFields_mAnds

Now when you auto-generate the code you will get what you wanted.

public class User {
 
    String mName;
 
    public String getName() {
        return mName;
    }
 
    public void setName(String name) {
        mName = name;
    }
 
    public User(String name) {
        mName = name;
    }
}

Android Studio – Create Desktop Entry

After installing Android Studio on my Linux laptop, I realized that there wasn’t an icon on the Gnome desktop for me to launch the application.  After a little digging, I found this StackOverflow answer which showed just how easy it is.

In Android Studio, just select Tools -> Create Desktop Entry, provide the admin password.

CreateDesktopEntry

And the next thing you know there’s a beautiful icon all ready for launching Android Studio.

AndroidStudioInDesktop

 

Interesting Stuff for July 2016

Maps:

Android

Coding

Java

  • Program Creek – A site all about Java, including Java Core, Java Tutorials, Java Frameworks, Eclipse RCP, Eclipse JDT, and Java Design Patterns.
    • Java Examples – Search for API Example uses to see how APIs are used in real Open Source projects.  Very useful to see how APIs are actually used.
    • Interview Questions – A list of Java related Interview questions

Android Full Screen Activity

In the application, I wanted all of the activities to display the Action Bar except the WebView.  To accomplish this, I created a new AppThem.NoActionBar which keeps the same style as the rest of the application, except disables the Action Bar and the Title.

<style name="AppTheme.NoActionBar" parent="AppTheme">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

Then we can assign the AppTheme.NoActionBar theme to just those activities that should not have the Action Bar. All of the remaining activities will keep AppTheme.

<activity android:name=".WebViewActivity"
    android:theme="@style/AppTheme.NoActionBar">
    <intent-filter>
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

Reference:

Android Studio – Configure Java SE 7

To configure an Android Studio Project to use Java SE 7:

  • Open the Project Structures window.  Select “Open Module Settings” from the right-select menu from the project’s app folder (F4).

    App_Select_OpenModuleSettings

    App Select Open Module Settings

  • On the properties tab of the app module, select 1.7 for the Source and Target Compatibility settings.ProjectStructure_Select_JavaSE7

Interesting Stuff for June 2016

Windows:

To find which version of Windows you are running, enter the following commands in the Command Prompt or Powershell:

wmic os get caption
wmic os get osarchitecture
  • Web Development:
  • svg-sprite –  a low-level Node.js module that takes a bunch of SVG files, optimizes them and bakes them into SVG sprites
  • Grumpicon – The tool processes a set of SVG files, generates PNG fallback images for legacy browsers, and exports a demo page showing how to use the final icons.
  • svgo – SVG Optimizer is a Nodejs-based tool for optimizing SVG vector graphics files.
  • Android Development
  • jsonschema2pojo – Generate Plain Old Java Objects from JSON or JSON-Schema.
  • http://tools.android.com/tips/layout-designtime-attributes: Android Design Time Layout, display values in the designer, but not included in the build.
  • http://tools.android.com/: Android Studio Project Site

Location

Retrofit

Picasso

 

Motorola Joins the Android Revolution

In a recent development, Motorola is making a major investment in supporting Android on mid-range Motorola phones.  In the high end handhelds they are still supporting Windows Mobile/CE, but in the mid-range they are adopting Android.

This will finally bring a real application environment to the average phone and people will no longer have to make the decision to invest hundreds of dollars in a Blackberry or Windows Mobile Phone.  Now they will have a mobile platform with a complete set of mobile capabilities.

The other advantage that Motorola has in this market is that their legacy in barcode scanning through their Symbol acquisition.  We can now realistically have barcode scanning in a mid-range handheld which will open a whole new world of applications such as ShopSavvy.  In the past Symbol has made attempts to bring scanning to the mobile phone, but with very limited success.

Of course the next question will be with the higher end terminals.  With all of the capabilities that are coming with the Android platform, what will happen to the high-end terminals.