newInstance failed: no <init> error in android program development
<p>I am writing a sample code to use android orientation sensor to view 3D scenes.</p>

<p><strong>The error i got is :</strong></p>

<pre><code>03-22 16:12:48.939: D/dalvikvm(9532): newInstance failed: no &lt;init&gt;()
03-22 16:12:48.939: D/AndroidRuntime(9532): Shutting down VM
03-22 16:12:48.939: W/dalvikvm(9532): threadid=1: thread exiting with uncaught exception (group=0x40018560)
03-22 16:12:48.949: E/AndroidRuntime(9532): FATAL EXCEPTION: main
03-22 16:12:48.949: E/AndroidRuntime(9532): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.droidnova.android.games.vortex/com.droidnova.android.games.vortex.Vortex}: java.lang.InstantiationException: com.droidnova.android.games.vortex.Vortex
03-22 16:12:48.949: E/AndroidRuntime(9532):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1680)
03-22 16:12:48.949: E/AndroidRuntime(9532):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
03-22 16:12:48.949: E/AndroidRuntime(9532):     at android.app.ActivityThread.access$1500(ActivityThread.java:123)
03-22 16:12:48.949: E/AndroidRuntime(9532):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
03-22 16:12:48.949: E/AndroidRuntime(9532):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-22 16:12:48.949: E/AndroidRuntime(9532):     at android.os.Looper.loop(Looper.java:130)
03-22 16:12:48.949: E/AndroidRuntime(9532):     at android.app.ActivityThread.main(ActivityThread.java:3835)
03-22 16:12:48.949: E/AndroidRuntime(9532):     at java.lang.reflect.Method.invokeNative(Native Method)
03-22 16:12:48.949: E/AndroidRuntime(9532):     at java.lang.reflect.Method.invoke(Method.java:507)
03-22 16:12:48.949: E/AndroidRuntime(9532):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
03-22 16:12:48.949: E/AndroidRuntime(9532):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
03-22 16:12:48.949: E/AndroidRuntime(9532):     at dalvik.system.NativeStart.main(Native Method)
03-22 16:12:48.949: E/AndroidRuntime(9532): Caused by: java.lang.InstantiationException: com.droidnova.android.games.vortex.Vortex
03-22 16:12:48.949: E/AndroidRuntime(9532):     at java.lang.Class.newInstanceImpl(Native Method)
03-22 16:12:48.949: E/AndroidRuntime(9532):     at java.lang.Class.newInstance(Class.java:1409)
03-22 16:12:48.949: E/AndroidRuntime(9532):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
03-22 16:12:48.949: E/AndroidRuntime(9532):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1672)
03-22 16:12:48.949: E/AndroidRuntime(9532):     ... 11 more
</code></pre>

<p><strong>Vortex.java :</strong></p>

<pre><code>public class Vortex extends Activity {
    private static final String LOG_TAG = Vortex.class.getSimpleName();
    private VortexView _vortexView;
    SensorManager sm;
    private float headingAngle,pitchAngle,rollAngle;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        _vortexView = new VortexView(this);

        setContentView(_vortexView);        
        //setContentView(R.layout.main);
        SensorManager sm = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
    }

    //////////////////

    private final Context context;
    public Vortex(Context context) {
        this.context = context;
    }


    int sensorType = Sensor.TYPE_ORIENTATION;

    private final SensorEventListener myOrientationListener = new SensorEventListener(){
        public void onSensorChanged(SensorEvent sensorEvent) {
            if(sensorEvent.sensor.getType() == Sensor.TYPE_ORIENTATION) {
                headingAngle = sensorEvent.values[0];
                pitchAngle = sensorEvent.values[1];
                rollAngle = sensorEvent.values[2];

                //TODO: 对应用程序应用方向变化
                _vortexView.updateAngles(headingAngle, pitchAngle, rollAngle);

            }
        }
        public void onAccuracyChanged(Sensor sensor, int Accuracy){}
    };

    //////////////////


    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();

        Sensor orentation = sm.getDefaultSensor(Sensor.TYPE_ORIENTATION);
        sm.registerListener(myOrientationListener, orentation, SensorManager.SENSOR_DELAY_FASTEST);
    }

    @Override
    protected void onStop() {
        // TODO Auto-generated method stub
        super.onStop();
        sm.unregisterListener(myOrientationListener);
    }
    }
</code></pre>

<p>I am absolutely confused, what could possibly be wrong?</p>

<p>Thank you</p>

<p>bitxue</p>

<p>I have solved this problem by
adding</p>

<pre><code>public Vortex() {
        super();
    }
</code></pre>

<p>method in "Vortex.java" file.</p>
