Android Studio is based on JetBrains IntelliJ software (http://www.jetbrains.com/idea) that is the official Integrated Development Environment (IDE) for creating Android apps for Windows, Mac OS X and Linux. There are two versions:
It includes the following features:
Below is a list of information regarding the use of older verisons of Andriod Studio and Andriod OSes.
Android versions are in alphabetical order and are based on some type of confectionery-themed code name starting with Cupcake. The earlier versions 1.0 and 1.1 were not released under specific code names — Wikipedia
See features associated with Android versions at https://en.wikipedia.org/wiki/Android_version_history.
End-user features:
Developer features:
While, permissions are still registered INDIVIDUALLY in the manifest (e.g., <uses-permission android:name="android.permission.SEND_SMS"/>, devices using Android 5.1 (API 22) or earlier still have to accept permissions during installation or upgrade. However, with Android 6 (APID 23) or later:
When a user request permission at runtime, he will see the entire group of permissions (e.g., CALL_PHONE and READ_PHONE_STATE are part of the SAME GROUP.)
You can authenticate users with their preferred screen lock methods. You can also use the fingerprint scanner.
Back up using a physical device or Google server
You can control which apps handle specific data type
Users can now define direct share targets that launch a specific activity in an app when a particular type of data is shared from another app.
The Assist API allows you to work with the new Google Now on Tap.
Allows a device to adopt EXTERNAL storage (e.g., micro SD) and use it as INTERNAL storage.
Support for Bluetooth stylus that are connected with a device.
There are many improvements for audio, video and camera.
This allows a user to open a web content using the device's built-in Chrome browser so that the device can share cookies, etc.
Additional enhancements include:
Go to http://developer.android.com/about/versions/marshmallow/android-6.0.html for details and sample apps.
CAUTION: You should NOT build production apps with PREVIEW software and you should only load it on a device that you are using for development testing or use virtual devices and NOT your regular device that you use daily.
To see a list of recent previews for Android Studio, go to http://tools.android.com/recent
You can upgrade an existing version of Android Studio you already have installed by watching the Canary channel (Help > Check for Update… on Windows/Linux and Android Studio > Check for Updates on the Mac) and following the upgrade notifications. CAUTION: This will download and install a patch rather than the full Android Studio IDE.
However, it is safer to install a new version in a separate directory from the old version so that they can have their own separate setting and cache directories. For more info on how to install multiple versions simultaneously, go to http://tools.android.com/tips/using-multiple-android-studio-versions
In order to create apps using Android 7, you will need to ensure that your SDK includes all required components and make some minor changes to the application Gradle script.
Target version:
Start A New Project:
Modify Gradle script:
NOTE: You can build this app now but you would be using the old compiler tool chain. It is best to change the build script to update the app using the new Jack and Jill compiler tool chain and Java 8 syntax:
Add Code to reference the new Jack And Jill Compiler and the Java 8 syntax:
There is no substitute for testing an app on a real supported physical device (e.g., phone or tablet). There are two ways to upgrade a device to the a newer version of Android (e.g., Android 7). Either use the Android Beta Program or manually flashing the device.
Unlock the bootloader:
Before you update, it is strongly recommend that you unlock the device's bootloader. This will make sure that if anything goes wrong that you'll be able to easily restore the device to an older version.
Enroll device:
Flash Device Manually:
If you have trouble using the beta program, you can download the factory images and flash them manually at developer.android.com/preview/download.html.
There are several types of shortcuts (keyboard, menu and code) that you can used to make writing code and working in Android Studio easier.
TIP: The sooner you learn these shortcuts that more proficient you will be and the more time you will save coding. So it is best to learn them upfront.
Below is a list of "vital few" shortcuts that will make you more productive when using Android Studio.
TIP: To learn all of Android Studio keyboard shortcuts go to Help > Default Keymap Reference. If you don't like the default keyboard options, you can change it by selecting Settings (PC) or Preferences (Mac) and select Keymap. To change them, you need to click on the Copy button, make changes and then click the OK button.
[NEED TO BE CLEAN UP AND CHECK]
The following keys represent the Windows OS. On the Mac, unless otherwise stated, replace these PC keys with their corresponding Mac keys
Live Templates are code snippets that can be created by writing a code shortcut that will be expanded to the complete code stub when you click the TAB or the ENTER key. They are defined in the Preference (Mac) or Settings (Windows) menu under Editor > Live Templates. They are used to speed up your coding and fall in five categories:
Toast.makeText(MainActivity.this, "", Toast.LENGTH_SHORT).show();NOTE: If you have automatic import turned on in the Preferences or Settings, an import statement will be added to the top of the code.
public class MainActivity extends AppCompatActivity {
private static final int MYCONSTANT = 331;
Log.i(TAG, "onCreate: onCreate was fired");NOTE: The TAG constant does not exist. You can click inside of it and press ALT+ENTER and then select Create constant field 'TAG" from the menu and then give the constant a string value (e.g., MainActivity).
You can review the default Live Templates to see how to create your own. Since setting the text property is a common task that you perform often, it may be helpful to create a Live Template to speed up writing code.
TextView tv = (TextView) findViewById(R.id.myTextview);
tv.setText("Set text property for TextView here...");
TextView tv = (TextView) findViewById(R.id.myTextView);
tv.setText("My text is set here...");
IMPORTANT CONCEPT TO REMEMBER: Whatever original value is CREATED in Design View with XML attributes can be OVERWRITTEN OR CHANGED to a new value in Text (Code) View with Java code. This is an important concept that you will see as you create more advanced code. For example, you can create STATIC or PLACEHOLDER content in Design view and then REPLACE them at RUNTIME with DYNAMIC content from a data source (e.g., an array, XML, JSON, Database, Java Code, etc.). Content that does not need to be changed can remain at their “design” values at runtime. To demonstrate this:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
TextView myNewText = (TextView) findViewById(R.id.textView);
myNewText.setText("How are you doing?");
IMPORTANT CONCEPT TO REMEMBER: While not real useful now, it is important to learn early how to evaluate expressions in your code to see if your code is working as expected. This is done by setting a breakpoint where you want the code to stop and then evaluating an expression in the code:
In CONJUNCTION with the shortcuts listed above, you can create common programming constructs (e.g., classes, methods, getters/setters, event handlers, etc.)
You can create all kind of components (e.g., Class, Interface) from one menu option:
To create a Java class:
To crease class stub:
You can create a set of getters and setters from a list of private instance variables.
public class CustomClass{
private String myString;
private int myInteger;
private String myString2;
}
You can define a method in one class and have it automatically created in another class. For example, let's say you have define a method name in the MainActivity.java class as highlighted below:
MyUtilityClass utility = new MyUtilityClass();
utility.addNumbers();
public void addNumbers() {
}
Instead of writing the stub for an event handler, you can let Android Studio do it for you.
<Button android:onClick="buttonClickHandler" />
public void buttonClickHandler (View view) {
}
public void buttonClickHandler (View view) { Log.d ("myClassName", "A message here..."); }
You can easily update multiple areas of your code at the SAME time using a technique called refactoring. This is a big time saver compared to the normal cut/copy and paste or search/replace operations.
There are a host of ways to use refactoring in Android Studio that allows you to rename, move and extract code. Most of the tasks can be access by selecting Refactor from the menu and then choosing an option:
For example, continuing with the code from the previous section:
MyUtilityClass utility = new MyUtilityClass();
utility.addNumbers();
MyUtilityClass myUtilityClass = new MyUtilityClass();
myUtilityClass.addTwoNumbers();
Beside dragging and dropping a class from one package to another to move it, you can also use the Refactor method to move a package as will be demonstrated in the next step. Continuing with the code from the previous section:
You can also EXTRACT CODE to other programming constructs as will be demonstrated in the next steps:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MyUtilityClass myUtilityClass = new MyUtilityClass();
myUtilityClass.addTwoNumbers();
}
}
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myMethod();
}
private void myMethod() {
MyUtilityClass myUtilityClass = new MyUtilityClass();
myUtilityClass.addTwoNumbers();
}
}