To create an application, right-click on the “package explorer” box on the left and select New -> Android Application. We should have such a screen:
At this point, we need to give the application name, project and package where our classes will be located. The name of the project would be best as the name of the application (though not necessary). If you have a web domain, it is best to reverse the phrase and finally add the name of the newly created application. For example, if I have the jsystems.pl domain and create the “KebabFinder” application, then I create the package pl.jsystems.kebabfinder. This is common practice and ensures the uniqueness of the names. It will not happen that there will be two Class Classes in packages with the same name com.example, although they will come from different vendors and do different things.
Let’s move on until we get the application icon screen. By default, the Android logo will be the application icon. We can change it to a custom image (we choose it from the disk), some clip art, or a text logo. I pressed “Clipart”, then choose and chose the thumb sign. Next I changed the default blue color of the logo to red by clicking on “Foreground Color”.
We go on. On the next screen you can choose how to display the application. Will it be a normal application with a visible system menu (Default selection) or full screen display (eg when we write a game) or a master/detail form.
After going to the next screen, select the main activity class name and the xml file name in which the main activity view will be defined. Activity – this can be understood in a very simplified way as a screen – data window in the application. Activity can have many applications, the user can move between activities (between screens – run eg your application and look at the goal setting procedure and you understand what I mean). Each application needs to have what activity (screen) to appear first when the program starts. With such activity is associated with the class it supports, and the name of this class is defined in the “Activity Name” field. In this class, we will then specify how the screen should behave. Another field – layout Name specifies the name of the XML file in which the appearance of this screen will be saved.
When we are finished we should see the class of our activity:
So far without details – so informative: the onCreate method is started when the screen is displayed, the onCreateOptionsMenu method when the user presses the menu button.
When we click on the tab with our layout file (in the previous illustration, my activity_keeper_xml.xml) we will see the project on our main screen. On the left, we have a menu with elements that we can glue on the screen.
For this moment we leave the traditional “Hello World” and run the application on the emulator and the real phone.
To launch the application, right-click on the project directory in the “Package Explorer” box, then “Run As” -> “Android Application”. We should have such a window:
We can choose to run with a virtual or real device here. At this point I have created virtual devices, but none is running. We launch the application at the same time running the virtual device. I select “Launch a new Android Virtual Device”, select the selected device and press “Ok”.
The virtual unit can run for up to 2-3 minutes, all depends on the equipment we have. When running on a virtual machine:
This time we will run the program on the real device. Just like before we click PPM on the project, we choose Run -> Run as Android Application. The window will appear as before. In the “Choose a running Android device” section we see two devices. One is the previously launched virtual device, the other is a real device – Samsung ACE3. In order to be able to cast applications to this device, we have to prepare them for including programming options. To do so, go to “Settings”, then look at the bottom of the “Developer options” in which we enter and activate. Without this, we will not be able to debug the application, so we will not be able to implement it from Eclips on the phone. When you turn on the option, connect your phone to the computer with a cable. The next time you start your application, your phone should already be visible. I’ve noticed that some devices do not even want to talk to Eclips this way, even if everything was plugged in and connected as it should. I had such a phone with Prestigio. So before you start rummaging through options and getting annoyed, just check with another device.