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

  • Home
  • SEARCH
  • 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 7018627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:04:35+00:00 2026-05-27T23:04:35+00:00

Im making a multi activity application and the first two activities i made have

  • 0

Im making a multi activity application and the first two activities i made have worked fine with no force closes, but as soon as i added a third activity, one to register touches on the display, when its list item is clicked i get a force close.

I have done exactly the same as with my other activities but cant figure out at all what is wrong, all activities have also been included in the AndroidManifest file.

Main activity with listview:

public class MyCustomAdapter extends ArrayAdapter<String> {

    public MyCustomAdapter(Context context, int textViewResourceId, String[] objects) {
        super(context, textViewResourceId, objects);
        // TODO Auto-generated constructor stub
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        //return super.getView(position, convertView, parent);
        LayoutInflater inflater = getLayoutInflater();
        View row = inflater.inflate(R.layout.row, parent, false);
        TextView label = (TextView)row.findViewById(R.id.tool);
        label.setText(Tool[position]);
        ImageView icon = (ImageView)row.findViewById(R.id.icon);

        if (Tool[position]=="Random # Generator") {
            icon.setImageResource(R.drawable.generator);
        }
        else if (Tool[position]=="Converter"){
            icon.setImageResource(R.drawable.converter);
        }
        else if (Tool[position]=="Ruler"){
            icon.setImageResource(R.drawable.ruler);
        }
        else if (Tool[position]=="Stopwatch"){
            icon.setImageResource(R.drawable.stopwatch);
        }
        else if (Tool[position]=="Countdown"){
            icon.setImageResource(R.drawable.countdown);
        }
        else if (Tool[position]=="Multitouch"){
            icon.setImageResource(R.drawable.touch);
        }

        return row;
        }
    }

    String[] Tool = {"Stopwatch", "Countdown", "Multitouch", "Ruler", "Converter", "Random # Generator"};

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);
        /*setListAdapter(new ArrayAdapter<String>(this, R.layout.row, R.id.weekofday, DayOfWeek));*/
        setListAdapter(new MyCustomAdapter(this, R.layout.row, Tool));
    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        // TODO Auto-generated method stub
        // super.onListItemClick(l, v, position, id);
        switch(position) {

        case 0:
            Intent stopwatch = new Intent(UsefulToolsActivity.this, Stopwatch.class);
            startActivity(stopwatch);
            return;

        case 1:
            Intent countdown = new Intent(UsefulToolsActivity.this, CountdownActivity.class);
            startActivity(countdown);
            return;

        case 2:
            Intent multitouch = new Intent(UsefulToolsActivity.this, Multitouch.class);
            startActivity(multitouch);
            return;

        default:                    
    }
}

The activity that causes the forceclose:

public class Multitouch extends View {

private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);

final int MAX_NUMBER_OF_POINT = 10;
float[] x = new float[MAX_NUMBER_OF_POINT];
float[] y = new float[MAX_NUMBER_OF_POINT];
boolean[] touching = new boolean[MAX_NUMBER_OF_POINT];

public Multitouch(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    init();
}

public Multitouch(Context context, AttributeSet attrs) {
    super(context, attrs);
    init();
}

public Multitouch(Context context) {
    super(context);
    init();
}

void init() {
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(1);
    paint.setColor(Color.BLUE);
}

@Override
protected void onDraw(Canvas canvas) {

    for(int i = 0; i < MAX_NUMBER_OF_POINT; i++) {
        if(touching[i]){
            canvas.drawCircle(x[i], y[i], 50f, paint);
        }
    }
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    // TODO Auto-generated method stub
    setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), 
            MeasureSpec.getSize(heightMeasureSpec));
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    int action = (event.getAction() & MotionEvent.ACTION_MASK);
    int pointCount = event.getPointerCount();

    for (int i = 0; i < pointCount; i++) {
        int id = event.getPointerId(i);

        //Ignore pointer higher than our max.
        if(id < MAX_NUMBER_OF_POINT) {
            x[id] = (int)event.getX(i);
            y[id] = (int)event.getY(i);

            if((action == MotionEvent.ACTION_DOWN)
                    ||(action == MotionEvent.ACTION_POINTER_DOWN)
                    ||(action == MotionEvent.ACTION_MOVE)) {
                touching[id] = true;
            }
            else {
                touching[id] = false;
            }
        } 
    }
    invalidate(); 
    return true;
}

Information from LOGCAT:

01-02 16:08:05.292: W/dalvikvm(20683): threadid=1: thread exiting with uncaught exception (group=0x40a321f8)
01-02 16:08:05.302: E/AndroidRuntime(20683): FATAL EXCEPTION: main
01-02 16:08:05.302: E/AndroidRuntime(20683): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.reddicliffe.usefultools/com.reddicliffe.usefultools.Multitouch}: java.lang.InstantiationException: can’t instantiate class com.reddicliffe.usefultools.Multitouch; no empty constructor
01-02 16:08:05.302: E/AndroidRuntime(20683): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
01-02 16:08:05.302: E/AndroidRuntime(20683): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
01-02 16:08:05.302: E/AndroidRuntime(20683): at android.app.ActivityThread.access$600(ActivityThread.java:123)
01-02 16:08:05.302: E/AndroidRuntime(20683): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
01-02 16:08:05.302: E/AndroidRuntime(20683): at android.os.Handler.dispatchMessage(Handler.java:99)
01-02 16:08:05.302: E/AndroidRuntime(20683): at android.os.Looper.loop(Looper.java:137)
01-02 16:08:05.302: E/AndroidRuntime(20683): at android.app.ActivityThread.main(ActivityThread.java:4424)
01-02 16:08:05.302: E/AndroidRuntime(20683): at java.lang.reflect.Method.invokeNative(Native Method)
01-02 16:08:05.302: E/AndroidRuntime(20683): at java.lang.reflect.Method.invoke(Method.java:511)
01-02 16:08:05.302: E/AndroidRuntime(20683): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-02 16:08:05.302: E/AndroidRuntime(20683): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-02 16:08:05.302: E/AndroidRuntime(20683): at dalvik.system.NativeStart.main(Native Method)
01-02 16:08:05.302: E/AndroidRuntime(20683): Caused by: java.lang.InstantiationException: can’t instantiate class com.reddicliffe.usefultools.Multitouch; no empty constructor
01-02 16:08:05.302: E/AndroidRuntime(20683): at java.lang.Class.newInstanceImpl(Native Method)
01-02 16:08:05.302: E/AndroidRuntime(20683): at java.lang.Class.newInstance(Class.java:1319)
01-02 16:08:05.302: E/AndroidRuntime(20683): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
01-02 16:08:05.302: E/AndroidRuntime(20683): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
01-02 16:08:05.302: E/AndroidRuntime(20683): … 11 more

Revised Multitouch code

public class Multitouch extends Activity {

public class MultitouchView extends View {

    private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
  • 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-05-27T23:04:36+00:00Added an answer on May 27, 2026 at 11:04 pm

    In short: in your case Multitouch is extending a View not an Activity class.

    if you want to show Multitouch as an Activity’s content.

    use it as View and add it inside Activity‘s contentView using layout from xml or simply call setContentView(anyMultitouchInstance);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't have much experience in making app multi lingual, but it seems to
I really have a strange situation. I'm making a Linux multi-threaded C application using
Making my first steps with NHibernate, I'm trying to have it creating my Tables
I am making a multi-lingual (computer languages) notepad in WinForms. I have a menu
I am making a multi-table fulltext query.But I met some question. I need make
I'm making an application that supports multi language. And I am using gettext and
I am making progress but still struggling with Unit of Work in a multi
Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created
Is memcached capable of making full use of multi-core? Or is there any way
I've got some multi threaded code that typically runs great, but every so often

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.