CMPE277_Lec5_Android_Loopers_Handlers_Threads.pdf

CMPE277_Lec5_Android_Loopers_Handlers_Threads.pdf - CMPE...

Info icon This preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
CMPE 277 COMPUTER ENGINEERING 1 CMPE 277 Instructor: Charles Zhang Fall 2017 Loopers, Handlers, Threads, and Processes
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CMPE 277 COMPUTER ENGINEERING 2 q What’s an action bar used for? q What’s the difference between options menu and context menu? q What is a contextual action bar? q What is intent spoofing? q What is activity hijacking? Topics from Last Lecture
Image of page 2
CMPE 277 COMPUTER ENGINEERING 3 q Activities and Tasks q AsyncTasks q Android Threading q Loopers and Handlers q Android Processes Outline
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CMPE 277 COMPUTER ENGINEERING 4 Tasks and Back Stack A task is a collection of activities that users interact with when performing a certain job. The activities are arranged in a stack (the "back stack"), in the order in which each activity is opened. A task is a cohesive unit that can move to the "background" when users begin a new task or go to the Home screen, via the Home button. LIFO Root activity
Image of page 4
CMPE 277 COMPUTER ENGINEERING 5 Which task does a new activity belong to? q By default, new activities are started in the current task q Use FLAG_ACTIVITY_NEW_TASK to start activities in a new task
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CMPE 277 COMPUTER ENGINEERING 6 Activity Launch Mode Source:
Image of page 6
CMPE 277 COMPUTER ENGINEERING 7 Url Fetch
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CMPE 277 COMPUTER ENGINEERING 8 Permission to Use Internet Connections
Image of page 8
CMPE 277 COMPUTER ENGINEERING 9 AsyncTask to Fetch URLs
Image of page 9

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CMPE 277 COMPUTER ENGINEERING 10 Four steps of AsyncTask onPreExecute(): Invoked on the UI thread before the task is executed doInBackground(Params...): invoked on the background thread immediately after onPreExecute() finishes executing publishProgress(Progress...) to publish one or more units of progress onPostExecute(Result), invoked on the UI thread after the background computation finishes Source:
Image of page 10
CMPE 277 COMPUTER ENGINEERING 11 Regular Threads vs the Main Thread Android disallows all networking on the main thread in Honeycomb and later versions of Android. If you try to do it, Android will throw a NetworkOnMainThreadException Aka the UI thread
Image of page 11

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CMPE 277 COMPUTER ENGINEERING 12 Application Not Responding (ANR)!
Image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern