Android Studio
Kyle Waters
Venturedata LLC
Installing
- wget https://dl.google.com/dl/android/studio/ide-zips/2.1.2.0/android-studio-ide-143.2915827-linux.zip
- unzip android-studio-ide-143.2821654-linux.zip
- android-studio/bin/studio.sh
- install as user
- Java
- 32 bit Libraries
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6
sudo yum install zlib.i686 ncurses-libs.i686 bzip2-libs.i686
Install Android Platform
- wget https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
- android-sdk-linux/tools/android update sdk
- Tools->Android->SDK Manager
- Install Packages
- Defaults
- API Versions
Android SDK Tools
Android SDK Platform-Tools
Android SDK Build-Tools
Android [Version] SDK Platform
Debug on Your Device
- Tap Buildnumber 7 times
- Developer Options->USB Debugging
- /etc/udev/rules.d/51-android.rules
- SUBSYSTEM=="usb",SYSFS{idVendor}=="04e8",SYMLINK+="android_adb",MODE="0666"
- chmod a+r /etc/udev/rules.d/51-android.rules
- Allow RSA Key
Android Virtual Device
- Android Emulator
- Tools->Android->AVD Manager
- Create Virtual Device...
Start New Project
- File->New->New Project
- Application Name
- Company Domain
- Package Name
- Project Location
Start New Project
- Form Factors
- SDK
- Activity Type
Android Components
- Activity
- Service
- ContentProvider
- Broadcast
Activity - Each screen the user sees is defined by an activity
Services - Background process with out user interface
Content Provider - Manages app data
Broadcast Receiver - React to system messages
Files
- Android Manifest
- app->src->main...
- java->[package name]
- res->layout
- res->menu
- res->values
Android Manifest
- Main Config File
- Program Label
- Program Icon
- Actvitiy - Launcher
Android Life Cycle
- OnCreate
- OnStart
- OnResume
- OnPause
- OnStop
- OnDestroy
Auto Add Import
- File->Settings
- Editor->General->Auto Import
- Optimize imports on the fly
- Add unambiguous imports on the fly
OnPause Example
@Override
protected void onPause() {
super.onPause();
TextView t=new TextView(this);
t=(TextView)findViewById(R.id.my_text);
t.setText("Paused");
}
Listener Example
private View.OnClickListener buttonhandler = new View.OnClickListener() {
public void onClick(View v) {
Toast toast = Toast.makeText(getApplicationContext(), "Button Pushed!", Toast.LENGTH_LONG);
toast.show();
Log.d("Sent Toast");
};
};
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(buttonhandler);