COURSERA: Android – Assignments

A collection of notes regarding course assignments.

My Android Homeblog   |   App 1   |     2      |     2 Quickie Ideas      |   ___Errors___


Assignment 2

Audio Recorded from my LG 3gp, converted to mp3 by: http://www.zamzar.com/

3gp: https://drive.google.com/file/d/0B2UXdsYg6uV5bnlKd3RJMWRMems/edit?usp=sharing

mp3: https://drive.google.com/file/d/0B2UXdsYg6uV5QjZ3d2h5cXlpVWc/edit?usp=sharing

Our assignment says:

  • Play your mp3 file only when the user is viewing Jabberwocky otherwise the app should be silent.
  • The Jabberwocky activity will also include two buttons beneath the web view:
  • The first button will use an Intent to open the Jabberwocky Wikipedia page in an external browser.
    The second button will use WebView’s ‘loadURL’ method to change the web view to display a picture of your choice.

The tough question: Could the 2nd button still be considered under Jabberwocky?

 

4 Activities:

Jabberwocky by Lewis Carroll
Roundball, a javascript game from limejs.com
U of I at NASA by Lawrence Angrave
War of the Worlds by H.G. Wells

 

I have the following in my manifest:

<application
        android:allowBackup=”true”
        android:icon=”@drawable/ic_launcher”
        android:label=”@string/app_name”
        android:theme=”@style/AppTheme” >
        <activity
            android:name=”coursera.app1.WarOfTheWorldsActivity”
            android:configChanges=”orientation|screenSize|keyboardHidden”
            android:label=”@string/app_name”
            android:screenOrientation=”sensorPortrait” >
            <intent-filter>
                <action android:name=”android.intent.action.MAIN” />

                <category android:name=”android.intent.category.LAUNCHER” />
            </intent-filter>
        </activity>
        <activity
            android:name=”coursera.app1.NasaActivity”
            android:configChanges=”orientation|screenSize|keyboardHidden”
            android:label=”@string/title_activity_nasa”
            android:screenOrientation=”sensorPortrait” >
            <intent-filter>
                <action android:name=”android.intent.action.MAIN” />

                <category android:name=”android.intent.category.LAUNCHER” />
            </intent-filter>
        </activity>
</application>

————————————-
<application
        android:allowBackup=”true”
        android:icon=”@drawable/ic_launcher”
        android:label=”@string/app_name”
        android:theme=”@style/AppTheme” >
        <activity
            android:name=”au.com.monster.assignment2_1.WarActivity”
            android:configChanges=”orientation|screenSize|keyboardHidden”
            android:label=”@string/app_name”
            android:screenOrientation=”portrait” >
            <intent-filter>
                <action android:name=”android.intent.action.MAIN” />

                <category android:name=”android.intent.category.LAUNCHER” />
            </intent-filter>
        </activity>
        <activity
            android:name=”au.com.monster.assignment2_1.ZeroGActivity”
            android:configChanges=”orientation|screenSize|keyboardHidden|uiMode”
            android:label=”@string/title_activity_zero_g”
            android:screenOrientation=”portrait” >
            <intent-filter>
                <action android:name=”android.intent.action.MAIN” />

                <category android:name=”android.intent.category.LAUNCHER” />
            </intent-filter>
        </activity>
    </application>
———————————
and this in my java:

package au.com.monster.assignment2_1;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.webkit.WebView;

public class ZeroGActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        WebView myWebView = (WebView) findViewById(R.id.webView1);
        myWebView.getSettings().setBuiltInZoomControls(true);
        myWebView.loadUrl(“file:///android_asset/nasa.html”);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.zero_g, menu);
        return true;
    }

}

———————————

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
       
if ((keyCode == KeyEvent.KEYCODE_BACK) && myWebView.canGoBack()) {   
myWebView.goBack();
return true;
}

return super.onKeyDown(keyCode, event);
}

———————————

@Override
public void onBackPressed() {
   if (webView.canGoBack()) {
        webView.goBack();
   } else {
       super.onBackPressed();
   }
}

———————————

if (Math.random() > 0.5){
     intent.setClass(this, MainActivity.class)
}

myWebView.getSettings().setBuiltInZoomControls(true);
myWebView.getSettings().setJavaScriptEnabled(true);



Assignment 1

APK Install Options:

  1. adb install
    Alternate way to install the APKs for Peer Review
    https://class.coursera.org/androidapps101-001/forum/thread?thread_id=8085
  2. DropBox
    Sharing APK using Dropbox
    https://class.coursera.org/androidapps101-001/forum/thread?thread_id=6112
  3. GMail draft download
    https://class.coursera.org/androidapps101-001/forum/thread?thread_id=8161#post-21903
  4. Peer Assessment Page APK Links
    https://s3.amazonaws.com/coursera-uploads/user-c0072e590c1a7eaf59554ce2/1/asst-6/2985e3a07b9911e38571afd318bd7368.apk
    Did not work as expected: download and install directly in AVD.
    My guess is this’ll work if you go on login to Coursera thru AVD.
    Would be very slow though.

 App 1   |   ^ top

Specifications:

  • App Name
    • To include last name of selected computer scientist
    • Should exclude your last name
    • Format abc.def (lowercase, no space, period separated)
    • Icon should represent app’s content
  • App Content: At least 2 computer scientists
  • Minimum SDK: 8
  • Layout
    • Portrait: Top to bottom: First Last (center), image (center), text (full)
    • Landscape: Top to bottom: First Last (center), image (left) then text (right, full)
  • Image Memory Size: < 2MB
  • Image Size: Must fit small phones, not more than half the screen-width
  • Image Accessibility: Must have content description to help users that needs it
  • Item Spacing: 8dp
  • Text Size: 22sp minimum (hardcode in XML)
  • Text Quantity: 2 lines minimum
  • Text Scroll: Should be active when text is too long to fit the screen


Requirements:

  • Screen captures:
    • 2560 x 1600 xhdpi, port-2560×1600-xhdpi.png
    • 320 x 480 mdpi, port-320×480-mdpi.png
    • 1024 x 600 mdpi, land-1024×600-mdpi.png
    • 480 x 800 hdpi, land-480×800-hdpi.png
  • Exported App’s APK
    • Signed
    • Valid at least 50 Years
  • Narrative:  The hardest part so far on my development experience – Connecting LG P705g to Laptop, steps as follow:
    • Activate “USB Debugging” from mobile’s Develop options
    • Connect mobile to computer by USB cable
    • On mobile’s “CONNECT AS”, select “PC Software” option on the mobile phone
    • Wait for the computer to finish installing
    • Check Eclipes [Devices] for the device
    • Click the project
    • Run As “Android Application”
    • Select the device name then click [OK]


Draft Text:

  • Picked Charles Babbage from the list
  • Downloaded his pic as shown by Google
  • Copied following text:
    The calculating engines of English mathematician Charles Babbage (1791-1871) are among the most celebrated icons in the prehistory of computing. Babbage’s Difference Engine No.1 was the first successful automatic calculator and remains one of the finest examples of precision engineering of the time. Babbage is sometimes referred to as “father of computing.” The International Charles Babbage Society (later the Charles Babbage Institute) took his name to honor his intellectual contributions and their relation to modern computers.
  • Googled Ada, downloaded pic
  • Text from Wikipedia:
    Augusta Ada King, Countess of Lovelace (10 December 1815 – 27 November 1852), born Augusta Ada Byron and now commonly known as Ada Lovelace, was an English mathematician and writer chiefly known for her work on Charles Babbage’s early mechanical general-purpose computer, the Analytical Engine. Her notes on the engine include what is recognized as the first algorithm intended to be carried out by a machine. Because of this, she is often described as the world’s first computer programmer.
  • Searched for Alan Turing, downloaded pic.
  • Text:
    Alan Mathison Turing, OBE, FRS (23 June 1912 – 7 June 1954), was a British mathematician, logician, cryptanalyst, and computer scientist. He was highly influential in the development of computer science, giving a formalisation of the concepts of “algorithm” and “computation” with the Turing machine, which can be considered a model of a general purpose computer.  Turing is widely considered to be the father of computer science and artificial intelligence.
  • Text:
    Grace Murray Hopper (December 9, 1906 – January 1, 1992) was an American computer scientist and United States Navy rear admiral. A pioneer in the field, she was one of the first programmers of the Harvard Mark I computer, and developed the first compiler for a computer programming language.  She conceptualized the idea of machine-independent programming languages, which led to the development of COBOL, one of the first modern programming languages. She is credited with popularizing the term “debugging” for fixing computer glitches (inspired by an actual moth removed from the computer).  Owing to the breadth of her accomplishments and her naval rank, she is sometimes referred to as “Amazing Grace”.  The U.S. Navy destroyer USS Hopper (DDG-70) is named for her, as was the Cray XE6 “Hopper” supercomputer at NERSC.
  • John von Neumann (December 28, 1903 – February 8, 1957) was a Hungarian-American pure and applied mathematician and polymath. He made major contributions to a number of fields, including mathematics (foundations of mathematics, functional analysis, ergodic theory, geometry, topology, and numerical analysis), physics (quantum mechanics, hydrodynamics, and fluid dynamics), economics (game theory), computer science (Von Neumann architecture, linear programming, self-replicating machines, stochastic computing), and statistics. He was a pioneer of the application of operator theory to quantum mechanics, in the development of functional analysis, a principal member of the Manhattan Project and the Institute for Advanced Study in Princeton (as one of the few originally appointed), and a key figure in the development of game theory and the concepts of cellular automata, the universal constructor, and the digital computer.
  • Donald Ervin Knuth (born January 10, 1938) is an American computer scientist, mathematician, and Professor Emeritus at Stanford University. He is the author of the multi-volume work The Art of Computer Programming. Knuth has been called the “father” of the analysis of algorithms. He contributed to the development of the rigorous analysis of the computational complexity of algorithms and systematized formal mathematical techniques for it. In the process he also popularized the asymptotic notation. In addition to fundamental contributions in several branches of theoretical computer science, Knuth is the creator of the TeX computer typesetting system, the related METAFONT font definition language and rendering system, and the Computer Modern family of typefaces.
  • Serge Joseph Abiteboul is a computer scientist working in the areas of data management, database theory, and finite model theory.  He received his PhD from the University of Southern California under the supervision of Seymour Ginsburg, in 1982. He is currently a senior researcher at the Institut national de recherche en informatique et en automatique (INRIA), the French national research institute focusing on computer science and related areas, and a professor at the Collège de France.
  • Kristen Nygaard (August 27, 1926 – August 10, 2002) was a Norwegian computer scientist, programming language pioneer and politician. Internationally he is acknowledged as the co-inventor of object-oriented programming and the programming language Simula with Ole-Johan Dahl in the 1960s. Object-oriented programming enables software developers to manage the complexity of computer systems. Nygaard got his master’s degree in mathematics at the University of Oslo in 1956. His thesis on abstract probability theory was entitled “Theoretical Aspects of Monte Carlo Methods”. Nygaard worked full-time at the Norwegian Defense Research Establishment from 1948 to 1960 – in computing and programming (1948–1954) and operational research (1952–1960). From 1957 to 1960 he was head of the first operations research groups in the Norwegian defense establishment. He was cofounder and first chairman of the Norwegian Operational Research Society (1959–1964). In 1960 he was hired by the Norwegian Computing Center (NCC), responsible for building up the NCC as a research institute in the 1960s, becoming its Director of Research in 1962.
  • Linus Benedict Torvalds (born December 28, 1969) is a Finnish American software engineer, who was the principal force behind the development of the Linux kernel. He later became the chief architect of the Linux kernel, and now acts as the project’s coordinator. He also created the revision control system Git as well as the diving log software Subsurface. He was honored, along with Shinya Yamanaka, with the 2012 Millennium Technology Prize by the Technology Academy Finland “in recognition of his creation of a new open source operating system for computers leading to the widely used Linux kernel”


Submission Checklist:

  1. Layouts
    • Portrait (layout/activity_main.xml)

      <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android”
          xmlns:tools=”http://schemas.android.com/tools”
          android:layout_width=”match_parent”
          android:layout_height=”match_parent”
          android:paddingBottom=”@dimen/activity_vertical_margin”
          android:paddingLeft=”@dimen/activity_horizontal_margin”
          android:paddingRight=”@dimen/activity_horizontal_margin”
          android:paddingTop=”@dimen/activity_vertical_margin”
          tools:context=”.MainActivity” >

          <TextView
              android:id=”@+id/textView1″
              android:layout_width=”wrap_content”
              android:layout_height=”wrap_content”
              android:layout_alignParentTop=”true”
              android:layout_centerHorizontal=”true”
              android:text=”@string/person01_name”
              android:textSize=”25sp” />
         
          <ImageView
              android:id=”@+id/imageView1″
              android:layout_width=”wrap_content”
              android:layout_height=”wrap_content”
              android:layout_below=”@id/textView1″
              android:layout_centerHorizontal=”true”
              android:layout_marginTop=”8dp”
              android:layout_marginBottom=”8dp”
              android:contentDescription=”@string/person01_image_description”
              android:src=”@drawable/charles_babbage_200x250″ />

          <TextView
              android:id=”@+id/textView2″
              android:layout_width=”wrap_content”
              android:layout_height=”wrap_content”
              android:layout_below=”@+id/imageView1″
              android:layout_centerHorizontal=”true”
              android:focusableInTouchMode=”true”
              android:paddingTop=”8dp”
              android:scrollbars=”vertical|none”
              android:text=”@string/person01_description” />

      </RelativeLayout>

    • Landscape (layout-port/activity_main.xml)

      <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android”
          xmlns:tools=”http://schemas.android.com/tools”
          android:layout_width=”match_parent”
          android:layout_height=”match_parent”
          android:paddingBottom=”@dimen/activity_vertical_margin”
          android:paddingLeft=”@dimen/activity_horizontal_margin”
          android:paddingRight=”@dimen/activity_horizontal_margin”
          android:paddingTop=”@dimen/activity_vertical_margin”
          tools:context=”.MainActivity” >

          <TextView
              android:id=”@+id/textView1″
              android:layout_width=”wrap_content”
              android:layout_height=”wrap_content”
              android:layout_alignParentTop=”true”
              android:layout_centerHorizontal=”true”
              android:paddingBottom=”8dp”
              android:text=”@string/person02_name”
              android:textSize=”25sp” />

          <ImageView
              android:id=”@+id/imageView1″
              android:layout_width=”wrap_content”
              android:layout_height=”wrap_content”
              android:layout_alignParentLeft=”true”
              android:layout_below=”@+id/textView1″
              android:contentDescription=”@string/person02_image_description”
              android:src=”@drawable/ada_king_200x250″ />

          <TextView
              android:id=”@+id/textView1a”
              android:layout_width=”wrap_content”
              android:layout_height=”wrap_content”
              android:layout_alignTop=”@+id/imageView1″
              android:layout_toRightOf=”@+id/imageView1″
              android:focusableInTouchMode=”true”
              android:paddingLeft=”8dp”
              android:scrollbars=”vertical|none”
              android:text=”@string/person02_description” />
         
      </RelativeLayout>

  2. Screenshots

    port-320×480-mdpi.png
    port-320x480-mdpi

    land-480×800-hdpi.png
    land-480x800-hdpi

    land-1024×600-hdpi.png
    land-1024x600-mdpi

    port-1600×2500-mdpi.png
    port-1600x2500-mdpi

  3. Signed APK
  4. At least 1 sentence why each person was chose
    • Charles Babbage
      I choose him because he’s one of the most popular name in computing, glad to have been reminded that its because of his ILLIAC.
    • Ada King
      I choose her because she’s likewise a programmer and she was with Sir Charles Babbage.
  5. Few notes about development experience
    Lots of challenges as expected for Android beginners:
    • USB Connection
      Bit of a challenge but was just glad to have figured this out.
      Lest I forget, I’ve documented most of the process in setting this up.
      Documentation available in my Coursera-Android blogpage, Setup portion.
    • Eclipse Crash
      Lots of inconvenience for this as one time for unknown reason, Eclipse crashed and error message kept coming.
      This stopped me from doing any development and spent lots of time solving the problem.
      With little help from classmate and plenty of research, was able to fix by re-installing and deleting previous Eclipse working folders.
      Planned to have more folks in this assignment but came up with just the minimum requirement as I lost plenty of time fixing corrupted installation and figuring out Eclipse programming. 
    • Following keeps haunting me:
      • CRITICAL STRUCTURE CORRUPTION
        Bothers me as it says it is gathering information of my computing environment
      • Java Exit Code 1
        Eclipse just crashes for unknown reason giving this message
      • Eclipse Version of Object-Orientation
        As pure 3GL coder (BASIC, dBase, C, etc…), spent lots of time figuring Eclipse ADT.
        Other integrated environment seemed to have more intuitive setup but I guess just need some getting used to.
        For more details, please see my Error blogpage: http://richardmhain.worpress.com/coursera-android-errors.

 



App 2   |   ^ top

 

Submission Checklist

  1. The signed APK
    Generated APK: greetingsapp.apk
    Keyword Used: abc12345
  2. App’s Screenshot
    port-480x800-hdpi-Assign2-Hide port-480x800-hdpi-Assign2
  3. Brief Answers:
    • What does you app do?
      Answer: Simply show/hide the message as respective button is pressed
    • Why did you decide to build the app?
      Answer: For simplicity and to learn more about buttons processing
    • What do you remember most about your development experience?  For example, what was the hardest part that required the most time?
      Answer: Learned of needing the usual much patience in learning technologies, from reconstructing crashed environment to finally being able to get bit comfy with it.  I find it difficult to even just connect my cellphone so I can run my apps on it but the hardest so far is figuring out simple data input/output.
    • What would you like to do next to your app?
      Answer: I would like to do some useful engineering calculations/conversions, nothing specific yet but will come up with few as needed.
  4. Optional: put feedback functionality to your app
    Comment: Will do this much later as for now, I hope this blogsite of mine is more than enough to accommodate any feedback.  Will first learn how to use permission before I go for this.


App 2   |   ^ top

Few thoughts on creating quick App 2:

  1. “Hello World” to “Greetings Assignment 1 App 2 Portrait/Landscape”
    Simply create usual hello_world app
    Update res/values/strings.xml hello_world string into “Greetings Assignment 1 App2 Portrait”
    Copy “hello_world” into another, say “hello_world_landscape”
    Update into “Greetings Assignment 2 Landscape”
    Copy “layout” folder, rename it “layout_land”
    Update res/layout/activity_main.xml, android:text string accordingly
    There goes quick App 2: display “Greetings Assignment 1 App2 Portrait/Landscape”
  2. “Hello World” to Portrait/Landscape Pics
    As in previous, create usual hello_world app
    Copy any portrait and landscape pics into “res\drawable-hdpi”
    Update res/layout/activity_main.xml, put portrait pic
    Copy folder into layout_land
    Update res/layout_land/activity_main.xml, put landscape pic
    Another quick App2: display portrait/landscape pics


Sample Codes:

 String[] formats = new String[] {
   "yyyy-MM-dd",
   "yyyy-MM-dd HH:mm",
   "yyyy-MM-dd HH:mmZ",
   "yyyy-MM-dd HH:mm:ss.SSSZ",
   "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
};
for (String format : formats) {
   SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US);
   System.out.format("%30s %s\n", format, sdf.format(new Date(0)));
   sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
   System.out.format("%30s %s\n", format, sdf.format(new Date(0)));
}

 

Date date = new Date(location.getTime());
DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(getApplicationContext());
mTimeText.setText("Time: " + dateFormat.format(date));

 

E    day of week    (Text)    E/EE/EEE:Tue, EEEE:Tuesday, EEEEE:T


PEER ASSESSMENT

  1. GosLov-Color
    • GoslingLovelace

      Works ok even without the scroll.

      Maybe I just don’t know how to make scrolling work on my devices.

      I’ve also used Ada but I used her real last name King.

    • ColorDetector

      Worked well on portrait mode, need rearrangement on landscape.

      As earlier mentioned, I can’t make scrolling work in my devices.

      Got confused with different icons, didn’t notice it I thought it wasn’t installed.

      I guess we’ve to set icon for each AVD, I wasn’t aware of this as well.

      Nice job!!!

  2. TorvStro-CamApp
    • Torvalds_Stroustrup

      Well done, would’ve helped if portrait/landscape is presented accordingly in online submission.

    • CamApp

      Took note of your code, might use it someday.

      Pretty too advanced to me for now.

      My guess is, pic/video taken would be on that moving green rectangle?

      App’s code:

      //Active the Camera

      private void dispatchTakePictureIntent (int actionCode){

      Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

      startActivityForResult(takePictureIntent, actionCode);

      }

      //Active the camera video

      private void dispatchTakeVideoIntent(int actionCode2){

      Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

      startActivityForResult(takeVideoIntent, Actioncode2);

      }

      // function of button photo

      public void takePicture(View v){

      Actioncode = 1;

      dispatchTakePictureIntent(Actioncode);

      }

      //function of button video

      public void takeVideo(View v){

      Actioncode2 = 2;

      dispatchTakeVideoIntent(Actioncode2);

      }

  3. LovNeu-Spanish
    • LovelaceNeumann

      Worked well.  You’re the second peer I’ve evaluated that used “Lovelace”, made me feel out of place for using her real lastname “King”.

      Yup, more dev, more probs solved :)

      Don’t get discouraged with layout, there’s plenty more tough stuff ahead.

      Hope we just keep going getting better in dev apps.

      Cheers!!!

    • Translate

      Ola, muy bien su espanol (Hello, very good your Spanish :)

      Pardon my Spanish, just got many words that’s similar in our native language.

      You’re the second peer I’ve evaluated that used “Lovelace”, made me feel out of place for using her real lastname “King”.

      Nice job!!!

  4. GrePag-Cats
    • GreenspunPage

      Well done!!!

    • SimpleCatMemorial

      You got cool cats!

      Would be nice if pic and thumbnail shows at the same time, instead of going back to thumbnail.

      Wished you’ve include some source code on this.

      I hope to be able to do similar app soon too.

      Good job!!!

  5. Peer
Advertisements

2 thoughts on “COURSERA: Android – Assignments

  1. Well it was an immensely wonderful post.Thanks for writing this type of info with us.I really hope you certainly will carry on enlightening individuals in future also,with the help of this type of valuable information.Continue the good task.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s