0

the error that i m getting :-

 04-08 00:37:48.540: E/AndroidRuntime(528): java.lang.RuntimeException: 
 Unable to instantiate activity ComponentInfo{com.android.collision/
com.android.collision.GameViewActivity}: java.lang.InstantiationException: 
can't instantiate class com.android.collision.GameViewActivity; no empty constructor

other deatils of the coding portion and i have to extend my main activity class by SurfaceView

my manifest xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.collision"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="14" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:label="@string/app_name"
        android:name=".GameViewActivity" >
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
   </application>

</manifest>

And my mail activity is :-

public class GameViewActivity extends SurfaceView {
/** Called when the activity is first created. */


 public GameViewActivity(Context context) {
       super(context);


 }

2 Answers 2

3

Your activity must extend an Activity class.

http://developer.android.com/reference/android/app/Activity.html

Sign up to request clarification or add additional context in comments.

3 Comments

i need to extend my activity class by SurfaceView
if you need to use SurfaceView, you need to add it to your Activity's layout, do not subclass it.
thanks for your attention on my question but i dont know how to add it in my activity class
0

java.lang.RuntimeException: Unable to instantiate activity

so do it like this

public class GameViewActivity extends  Activity  

or you can extend any activity from your project eg.

public class GameViewActivity extends  GameActivity   

3 Comments

i need to extend my activity class by SurfaceView
so that file has no Activity ? it should have extend that activity not class .
ok then how to add the SurfaceView in my activityclass after extend it by Activity

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.