Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8652107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:13:54+00:00 2026-06-12T14:13:54+00:00

I am playing with Java reflection in an Android project. Source code: Log.d(LOG, begin);

  • 0

I am playing with Java reflection in an Android project.

Source code:

Log.d("LOG", "begin");
try {
    final android.view.View.OnSystemUiVisibilityChangeListener unusedVar = new android.view.View.OnSystemUiVisibilityChangeListener() {

        @Override
        public void onSystemUiVisibilityChange(int visibility) {
            // TODO Auto-generated method stub

        }
    };
    Log.d("LOG", "unusedVar is null = " + (unusedVar == null? "Yes": "No"));
    Class newClass = Class.forName("android.view.View.OnSystemUiVisibilityChangeListener");
    Log.d("LOG", "newClass created");
} catch (Exception ex) {
    Log.d("LOG", "Failed to create newClass", ex);
}
Log.d("LOG", "end");
  • The above code is in onCreate() of my activity.
  • The project’s build target is Android 4.0.
  • I am running it on a device with Android 4.0.4.

Result:
The variable unusedVar is NOT null, but Class.forName throws a ClassNotFoundException.

Log:

D/LOG(13205): begin
D/LOG(13205): unusedVar is null = No
D/LOG(13205): Failed to create newClass
D/LOG(13205): java.lang.ClassNotFoundException: android.view.View.OnSystemUiVisibilityChangeListener
D/LOG(13205):   at java.lang.Class.classForName(Native Method)
D/LOG(13205):   at java.lang.Class.forName(Class.java:217)
D/LOG(13205):   at java.lang.Class.forName(Class.java:172)
D/LOG(13205):   at com.MyActivity.onCreate(VideoPlayerActivity.java:100)
D/LOG(13205):   at android.app.Activity.performCreate(Activity.java:4465)
D/LOG(13205):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
D/LOG(13205):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
D/LOG(13205):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
D/LOG(13205):   at android.app.ActivityThread.access$600(ActivityThread.java:123)
D/LOG(13205):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
D/LOG(13205):   at android.os.Handler.dispatchMessage(Handler.java:99)
D/LOG(13205):   at android.os.Looper.loop(Looper.java:137)
D/LOG(13205):   at android.app.ActivityThread.main(ActivityThread.java:4424)
D/LOG(13205):   at java.lang.reflect.Method.invokeNative(Native Method)
D/LOG(13205):   at java.lang.reflect.Method.invoke(Method.java:511)
D/LOG(13205):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
D/LOG(13205):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
D/LOG(13205):   at dalvik.system.NativeStart.main(Native Method)
D/LOG(13205): Caused by: java.lang.NoClassDefFoundError: android/view/View/OnSystemUiVisibilityChangeListener
D/LOG(13205):   ... 18 more
D/LOG(13205): Caused by: java.lang.ClassNotFoundException: android.view.View.OnSystemUiVisibilityChangeListener
D/LOG(13205):   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
D/LOG(13205):   at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
D/LOG(13205):   at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
D/LOG(13205):   ... 18 more
D/LOG(13205): end

Why is that? Is it because android.view.View.OnSystemUiVisibilityChangeListener is an interface rather than a class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:13:56+00:00Added an answer on June 12, 2026 at 2:13 pm

    Interface OnSystemUiVisibilityChangeListener is nested in class View, so I believe you would have to do Class.forName("android.view.View$OnSystemUiVisibilityChangeListener"); (note the ‘$’).

    References:

    • http://developer.android.com/reference/android/view/View.html
    • http://developer.android.com/reference/android/view/View.OnSystemUiVisibilityChangeListener.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi all, Very new to Erlang, coming from C/C++/Java. Been playing with code and
Completely new to java and I have been playing around with regex in a
I was playing around with Java reflection, and I wanted to create a method
Just playing around with java trying to learn it etc. Here is my code
I am playing with Java's reflection API, and I'm writing methods that inspect a
I've been playing around with reflection in Java... and I'm a little bit baffled.
Extremely new to Java an just playing around with it. I'm trying to add
I've been playing around with developing Android apps in Java for a while and
I'm, playing with the Android framework and try to get my mind deeper into
I'm playing around with Java's reflection API and trying to handle some fields. Now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.