How do I get the class from a static method of a subclass?
<pre><code>/**
 * this is my class, yadayada. Needs to be subclassed to be useful.
 */
public abstract class MyClass {
  ...
  public static void myMethod() {
    // What is the name of the subclass that's using this?
    System.out.println("Called from class " + this.getClass().class.getName());
    // Doesn't work because there's no "this" in a static method.
  }
}
</code></pre>

<p>Edit: this is what I want to happen:</p>

<pre><code>public class FooClass extends MyClass {
  ...
}

FooClass.myMethod();   // I would like this to print "Called from class FooClass"
</code></pre>

<p>I'm all out of ideas.</p>

<p>Edit: And for those who wonder why I'm doing it this way, it's actually an Android question of sorts.</p>

<p>Android defines a class called BroadcastReceiver.  You subclass this and register your subclass with the system. When an appropriate broadcast is sent, the system creates an instance of your subclass and calls one of its methods.</p>

<p>I want to create my own BroadcastReceiver subclass that contains a static method for registering itself.  But I also want it to be subclassable.  It sort of looks like this:</p>

<pre><code>/**
 * My special-purpose BroadcastReceiver.  Subclass this to use it.
 */
public class MyClass extends BroadcastReceiver {
  public static scheduleAnAlarm(long when) {
    // do some class-specific stuff
    AlarmManager.scheduleBroadcast(MyClass.class, when);
  }

  public void onBroadcast() {
    System.out.println("You should subclass MyClass for it to be useful");
  }
}
</code></pre>

<p>My problem is that I want to register the subclass to be instantiated, not MyClass.</p>
