Missing the android.os.handler object from Android Studio
Asked Answered
B

6

10

I'm attempting to create a Handler thread in my application however Android Studio marks my text as red and will only attempt to import the java.util version of a handler and not the Android SDK version. When attempting to import manually I'm able to find the HandlerThread just fine but the normal handler import seems to be missing.

Any ideas why?

Burtburta answered 15/6, 2013 at 7:27 Comment(2)
those are part of the same jar. Probably you have misspelled the importNiven
Android Studio will auto complete the import for you. So if I was to type android.os. it would then complete the import for me. In the list it does not show "Handler" as an available object.Burtburta
B
32

I had to add import android.os.*; before I could get the android.os.Handler object working in my class.

Burtburta answered 17/6, 2013 at 0:29 Comment(0)
A
6

Just import android.os.Handler, no need to import everything in android.os

Ascites answered 27/5, 2017 at 3:15 Comment(0)
W
2

open : Settings -> Editor -> General -> Auto Import。

Exclude from Import

Wisdom answered 8/6, 2018 at 5:42 Comment(0)
C
1
import android.os.*;

solved the problem.

Clubman answered 1/7, 2017 at 15:16 Comment(1)
Welcome to SO. Though we thank you for your answer, it would be better if it provided additional value on top of the other answers. In this case, your answer does not provide additional value, since another user already posted that solution. If a previous answer was helpful to you, you should vote it up once you have enough reputationEba
D
0

Make sure that your Android SDK is added properly to Android studio. To do this go to File -> Project Structure and check the SDKs item under Platform Settings. Also make sure that you have selected a Project SDK under the Project item.

See the IntellJ documentation for more information.

Delphinus answered 15/6, 2013 at 10:18 Comment(0)
M
-1

It works because Android Studio and InteliJ usually import import android.os.Handler; instead of import android.os.Handler;

When you import the android version of Handler make sure you remove the Java version because the Java version is always compiled first over the Android version.

Maudiemaudlin answered 20/1, 2018 at 5:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.