Monday, October 4, 2010

Class 2 - Terminal Commands and my first App!

Learned some useful terminal commands, got into the basic GUI layout, created my first app, and uploaded it onto my phone. I'm picking up on concepts much quicker than I thought I would thanks to a very talented professor.

Terminal Commands:
  • android - Opens Android Standard Development Kit (SDK) and Android Virtual Device (AVD) Manager
  • emulator - Run emulator for devices
  • adb - Android Debug Bridge allows debugging, view logs, and shell commands
Flashlight App:
(I improved on the code by calling the screenBrightness function to increase the phone's brightness to max in case it's not. I've been browsing around the reference materials on developer.android.com and through stackoverflow.com; there is so much information/code. I'm just starting to realize the vastness and potential of open source)

package com.demo.android.flashlight;

import android.app.Activity;

import android.graphics.Color;

import android.os.Bundle;

import android.view.View;

import android.view.Window;

import android.view.WindowManager;

public class FlashLightActivity extends Activity {

//Tag testing: private static final String TAG = "Flashlight";

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

View view = new View(this);

view.setBackgroundColor(Color.WHITE);

// Get rid of title bar

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

//New - Added to increase phone's brightness levels to max brightness

WindowManager.LayoutParams lp = getWindow().getAttributes();

lp.screenBrightness = 1;

getWindow().setAttributes(lp);

setContentView(view);

}

}


No comments:

Post a Comment