Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
262 views
in Technique[技术] by (71.8m points)

android - 'Intent cannot be resolved to a type' error in eclipse

I am programming the first android tutorial in eclipse, and when compiling this code:

Intent intent = getIntent();

it gives the error

Intent cannot be resolved to a type

How do I fix it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Probably, the import statement is missing. Try pressing Ctrl+Shift+O, Eclipse will automatically add the import statement if missing.

Then look at the top of the file and see what has been added. It should be something like this:

import android.content.Intent;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...