Introduction To Java For Android Platform
Introduction To Java For Android Platform
Versions of Java
Smart
Short Description of Java
Java was designed for the Internet. It has two
Planet
attributes that make it very suitable: safety and
portability.
The safety features of the Java language make it
possible to run Java programs in a browser without fear
that they might attack our computer.
The other benefit of Java is portability. The same
Java program will run, without change, on Windows,
Smart
https://en.wikipedia.org/wiki/Android_version_history
Android 8.0 Oreo (API 26)
Android Oreo is the 8th major release of the Android
Planet
operating system. It was first released as a developer
preview on March 21, 2017, with factory images for
current Nexus and Pixel devices. The final developer
preview was released on July 24, 2017, with the stable
version released in August 2017. Features:
• Project Treble, the biggest change to the foundations of Android: a modular architecture that makes it easier and faster for
hardware makers to deliver Android updates
• Picture-in-picture support
• Support for Unicode 10.0 emoji (5.0) and replacement of all blob-shaped emojis by round ones with gradient and outline
• Redesigned Quick Settings and Settings with white background and respectively black and Accent font color
• Restructured Settings by regrouping in sections similar entries
• Adaptive icons
Smart
• Notification improvements
• Notification channels
• Notification dots (badges)
• Notification snoozing
• System-wide Autofill framework
• Sony LDAC codec support
• App-specific unknown sources
• Multi-display support
• 2 times faster boot time
• Apps background execution and location limits
• Google Play Protect
• Downloadable fonts
• Integrated printing support
• Deep color (Wider color gamut for apps)
• Wi-Fi Assistant
https://en.wikipedia.org/wiki/Android_version_history#Android_8.0_Oreo_.28API_26.29
Global Android version distribution since
Planet
December 2009
Smart
https://en.wikipedia.org/wiki/Android_version_history
Global Android version distribution as of
September 2017
Planet
Smart
https://en.wikipedia.org/wiki/Android_version_history
How can we start Java code on Android
smartphone?
Planet
A Java program (such as an Android app) undergoes
several translation steps between the time we write the
program and the time a processor runs the program:
1. Compiler creates Java bytecode from our Java
source files. The source filenames have the .java extension;
the Java bytecode filenames have the .class extension.
2. Another compilation creates Dalvik bytecode from
Smart
our Java bytecode files. Dalvik bytecode file names have the
.dex extension. Android Runtime (ART) replaces Dalvik nowadays.
3. Android app has XML files, image files, and possibly
other elements. Before we install an app on a device,
Android Studio combines all these elements into a single file
– one with the .apk extension.
How can we start Java code on Android
smartphone?
Planet
JDK (Java SE
Development Kit)
includes a complete JRE
plus tools for
developing, debugging,
and monitoring Java
applications.
Planet Get the Free Software We Need
2. Visit http://developer.android.com/studio and
download the Android Studio IDE along with the Android
Software Development Kit (SDK).
Smart
Planet
Smart Install Android Studio
https://developer.android.com/studio/install.html
Planet Android Studio: Welcome window
We see the welcome window when we start
Android Studio:
Smart
Planet Android Studio: Existing project
For instance, we choose to open existing Android
Studio project:
The areas
that you
see on
the
computer
Smart
screen
may be
different
from
these
areas…
Planet Android Studio: The main window
• The top of the main window – the topmost area
contains the toolbar and the navigation bar:
- the toolbar contains action buttons such as Open, Save
All, Cut, Copy, and Paste;
- the navigation bar displays the path to one of the files in
the Android project.
• The Project tool window.
Below the main menu and the
Smart
• app/res/drawable branch
Smart
• app/res/layout branch
• app/res/mipmap branch
• app/res/values branch
The app/res branches: app/res/drawable
The app/res/drawable branch contains any regular-size
Planet
images that our app uses.
The app/res branches: app/res/layout
The app/res/layout branch contains files that describe the
look of our app’s activities (activity_fullscreen.xml in our case).
The app/res branches: app/res/mipmap
This branch contains some additional images – the images
of our app’s icons.
Smart
some kind.
The heart of that script is in the build.gradle
(Module: app) branch of the Project tool window. That
branch describes our app’s version number, minimum
SDK, and other things.
Planet
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
Smart
android:layout_marginTop="90dp"
android:ems="10"
android:inputType="textPersonName"
android:text="@string/text2" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="170dp"
android:text="@string/textView1" />
Planet Simple Addition Android App (cont.)
6. On the preview screen or in the component
tree, select the dummy_button.
7. In the Properties pane, type onButtonClick in
the onClick field.
Smart
Simple Addition Android App (cont.)
8. Inside the app/java branch of the Project tool
Planet
window, double-click FullscreenActivity.java
9. Modify the activity’s code as follows:
package com.example.zubov.myapp1;
…
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
…
public class FullscreenActivity extends AppCompatActivity {
EditText editText;
EditText editText2;
TextView textView;
…
@Override
Smart
import android.widget.EditText;
import android.widget.TextView;
// We tell Java that, in this program, we’ll be using,
// i.e. importing, some code that’s already defined
// in the Android library
@Override
protected void onCreate(Bundle savedInstanceState) {
// Inside the FullscreenActivity class, we make a list of
// instructions (i.e. method) named onCreate