/
Mobile Programming Mobile Programming

Mobile Programming - PowerPoint Presentation

stefany-barnette
stefany-barnette . @stefany-barnette
Follow
393 views
Uploaded On 2017-10-01

Mobile Programming - PPT Presentation

Lecture 3 Debugging Lecture 2 Review What widget would you use to allow the user to enter a yesno value a range of values from 1 to 100 Whats the benefit of a Relative Layout over LinearLayout ID: 592228

lang val buclr ppr val lang ppr buclr solidfill debugging rpr med 91425 debug logcat srgbclr endpararpr 1800 fmla

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Mobile Programming" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Mobile ProgrammingLecture 3

DebuggingSlide2

Lecture 2 Review

What

widget would you use to allow the user to enter

a yes/no value

a range of values from 1 to 100

What's the benefit of a

Relative

Layout

over LinearLayout?

How many ways can you set an event listener?Slide3

Lecture 2 Review

How do you make the android:inputType attribute of an EditText both

textCapCharacters

and and textMultiLine?

Why should you use a @string resource for TextViews instead of hardcoding the string?

If you use the same android:onClick value for multiple views, how do you determine which one was clicked?Slide4

Agenda

Debugging using Toast ...

LogCat

Debug Perspective

Importing existing projects into Eclipse

Lab debugging assignmentSlide5

Debugging using Toast ...

A

Toast is an easy way to debug your app

... sometimesSlide6

Try not to debug using Toast!

it's slower

especially if you're using multiple Toasts

it doesn't persist

after the Toast is gone, you may not have seen all of the debug information, then you'll have to run it again

sometimes the code for a Toast will be correct, but the Toast just won't show!

depends on the state of the applicationSlide7

Debugging -

LogCat

LogCat shows the stack traces, diagnostic information from the operating system.

Slide8

Debugging -

LogCat

Slide9

Debugging -

LogCat

Slide10

Debugging -

LogCat

Slide11

Debugging -

LogCat

private static final String TAG = "HelloWorldActivity";

Log.i(

TAG

, "This line has been executed");

Log.i(

TAG

, "Value of x = " + x);Slide12

Debugging -

LogCat

Open

the LogCat view if it's not already open in Eclipse

Window > Show View >

LogCat

Under

Saved filters, click the + button to add a new

filter

Enter the following (modify to match your app)

Filter Name: HelloWorldActivity

by Log Tag: HelloWorldActivity

Click

OK

Your

debug messages should now show up

If they're not showing up, double check your filter (

or advance a few slides in this presentation

)Slide13

Debugging -

LogCat

Slide14

Debugging - Debug Perspective

Another way to debug is by using breakpoints, which you may already be familiar with from an IDE other than Eclipse

Add breakpoints to lines in your code where you want to pause your program

To start debugging, you can do one of the following

press F11

Run > Debug

If your application gets to your breakpoint, it will pause thereSlide15

Debugging - Debug Perspective

If it asks

whether

you want to switch to Debug Perspective, say

yes

I

n

the Expressions View of the Debug Perspective, you can add variables to see what their values are at the breakpoint

e.g., if you have int x somewhere in your code, try adding x to

You may have to open the view first

Window > Show View > Expressions

Buttons in the Debug View allow you to continue or step through the rest of the code

Resume, Step Into, Step Over, etcSlide16

Exporting projects from Eclipse

To

export a project from Eclipse

Right click your project > Export > General > Archive File

Next

Select your project if necessary

Options > Save in tar format preferably (zip will work as well)

Browse ...

Finish

Submit your homework assignments and projects in these formatsSlide17

Importing projects into Eclipse

Most code examples that I post will be .tar (or .zip) archive files

To import an existing project into Eclipse

Download the archive file

Navigate to File > Import ... > General > Existing Project into workspace

Choose "Select archive file"

Browse for the downloaded file and select it

Finish

I may include a README file in the root directory with instructions that you need to followSlide18

References

The Busy Coder's Guide to Android Development - Mark Murphy

Android Developers

The Mobile Lab at Florida State University