Doubts about extends Application

2

Developing for android I can create a class that extends Application. How would I do this in java? Is there or is this marking?

    
asked by anonymous 11.06.2014 / 17:41

3 answers

5

There is no such thing in Java, it's Android thing. In Java you can even invent a Application class for your application, but it will not be like android.app.Application of Android, that is, there is no class java.lang.Application or java.app.Application for example that serves as a template or base for your subclass.

Some frameworks may provide a base class similar to the Application of Android for you to extend, but this would be a specific framework thing, for you to work with framework features, not a Java thing itself.     

11.06.2014 / 21:24
2

Yes, there is.

You can create a class like this:

public class ClasseApplication extends Application{


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

        //Código a ser executado quando o applicativo é inicializado
    }

}

And in your AndroidManifest.xml, you put as the tag's attribute the path to the class.

 <application
        android:name="com.pacote.ClasseApplication" >

In java it is a little abstract, as there are several types of appendices in java. In jsf for example there is the Applcation class, which works much like the android

link

It would help if you were more specific about what type of application you want to know.

    
11.06.2014 / 18:49
0

First you must create the parent class. for example Official.

public class funcionario{} //somente um exemplo

After extending it or creating a child class for this we will use a manager who is an employee.

public class gerente extends funcionario{} //exemplo

Remembering that in the child class you should only create new methods, the rest is inherited.

    
11.06.2014 / 19:03