Home » Android » import – Missing the android.os.handler object from Android Studio

import – Missing the android.os.handler object from Android Studio

Posted by: admin May 14, 2020 Leave a comment

Questions:

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?

How to&Answers:

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

Answer:

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

Answer:

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

Exclude from Import

Answer:

import android.os.*;

solved the problem.

Answer:

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.

Answer:

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.