开发者

Android Application subclass constantly generates forceclose

开发者 https://www.devze.com 2023-01-25 16:31 出处:网络
Hi i\'ve found a example on this site on how to make a subclass of the application for android. I\'ve created this code

Hi i've found a example on this site on how to make a subclass of the application for android.

I've created this code

package mensand.test;
class TestApp extends android.app.Application {

}

Added this line to the manifest

android:name="mensand.t开发者_运维知识库est.TestApp"

And when i run the app it's starts with a force close message.

When i remove the line from the manifest all runs ok

Greetings Andre Mens


Is that you have in that class? If yes then the problem is that you don't override the onCreate() method.

import android.os.Bundle;

class TestApp extends Activity {

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

}

That's what you've missed.

EDIT: Reviewing that code snippet again I realized that coping the code snippet of the OP isn't a good idea. I've missed that you are extending the Application class. In that case onCreate() won't take any parameters. What is it you are trying to achieve with extending the Application class?

0

精彩评论

暂无评论...
验证码 换一张
取 消