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?
I had to add
import android.os.*; before I could get the android.os.Handler object working in my class.
Just import android.os.Handler, no need to import everything in android.os
open : Settings -> Editor -> General -> Auto Import。
Exclude from Import
solved the problem.
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
See the IntellJ documentation for more information.
It works because Android Studio and InteliJ usually import
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.