How to create an application for android without skills. Programming for Android: how to start creating your own applications and games? What to do with app ideas if you're not a developer

The Android operating system has become widespread - as of the end of 2015, more than 80% of mobile devices run on it, and the graphs show steady growth. Interest in mobile applications continues, judging by the number of new products in the Playmarket. How to create an Android application yourself? Do you need to be a real programmer for this? We will talk about this in our article.

A professional approach to Android programming

In order to create your first Android application, you need to work hard. We will need:

  • Books on programming;
  • Development environment (includes many programs and plugins);
  • Additional manuals on programming for Android OS;
  • Knowledge in building algorithms.

Having completed the installation of the development environment, you need to start studying books and manuals. They will help you gain knowledge about operators, classes, arrays, and ways to interact with mobile device equipment. Also you need to learn to read other people's code and find in it the necessary knowledge and programming techniques. Looking at the listing of the smallest program, your head begins to spin - it seems that it is impossible to learn it all.

In fact, many manuals and tutorials have been written for Android programming. Therefore, there will be no problems with learning the basics of programming - the main thing is to have the ability to do so.

Android app builders

If operators, classes and the development of algorithms scare you, and program listings plunge you into primitive horror, then we are ready to offer you another solution - creating applications in special constructors. Their number is growing by leaps and bounds, so there will be no problems finding them. Designers allow you to write applications of varying levels of complexity using pre-developed modules and capabilities. Based on them you can create:

  • News applications;
  • Catalogs of culinary recipes;
  • Mobile blogs;
  • Online stores;
  • Applications for ordering services;
  • Photo and video galleries;
  • Text apps and more.

Also, many designers offer tools for basic promotion of created applications.

App2b constructor

This designer is designed for a business audience, so it can create business projects of a high level of complexity. On its basis, online stores, clothing catalogs, applications for discount programs, applications with notifications, news applications, promotional catalogs, video galleries and much more are implemented. Users have access to download statistics of created applications, hosting and promotion tools.

Like many other business tools, the App2b builder is paid. There is only one payment option for users and developers to choose from - 9,900 rubles for one one-time application. The payment includes access to all specified features, technical support, promotion tools, as well as placement of applications in the Playmarket.

To be fair, it is worth noting that this designer can create applications not only for Android, but also for iPhone smartphones (with subsequent publication in the AppStore).

Elena Shramenko

CEO
"Akintsev and Partners" company

“I would like to say a few words about the mobile application designer from AppGlobal.

We recently developed our application based on the AppGlobal constructor. And every day we are revealing more and more capabilities of this tool, with which you can implement a variety of tasks.

Firstly, I realized that this tool is of great benefit to both parties: for us, as the owners of the application, and for our clients who use this application.

By solving our marketing problems, we give our clients additional benefits:

They have at their fingertips all the information on a topic that interests them, and get the opportunity to study materials that are not freely available. They can take advantage of discounts and gifts that are only active through the app. They also have the opportunity to pay for your service or delivery from the application and make a free call.

Thanks to this, we get regular customers and attract new ones.”

Ilya Basnin

AppGlobal partner

“The big disadvantage of all other services is the lack of technical support.

I have analyzed many constructors.

Most often, simple inexpensive platforms are used, the owners of which simply copy AppGlobal materials, but the designer itself remains “raw” and unfinished.

Their big disadvantage is the lack of support. And, despite the low prices, they still cannot withstand the competition.”

Arthur Budovsky

“Sales increased by 14% in the first month of using the mobile application!

I write selling texts and teach people this art. The level of trust my readers have in me has increased only because there is a mobile application. Like, if my School is in Apstore and Google Play, it means that I have a solid business, and not some kind of “scam”. People buy trainings without even downloading the app to their phone.

The AppGlobal constructor itself is a mega-tool! You can create a full-fledged application yourself, without special programming knowledge, in just a couple of hours! The only thing is that I would like to be able to make different interfaces, because all applications are similar to each other due to the buttons.

Now I post audio and video materials and information tabs in my mobile application. There is a subscription to news and integration with social networks. I use push notifications for my readers. There is feedback such as receiving messages, photos from clients.

Despite the fact that the launch of my product was delayed due to moderation, I am very pleased with the cooperation with the AppGlobal service. Problems are resolved quite quickly, consultants help to sort out all the issues.

My site now lives a mobile life. I really hope that my clients and readers will appreciate my mobile application and come back to me more than once!

Thank you AppGlobal for simple solutions to complex but important issues!”

Google's Android operating system is ideal for developers who want to create applications for mobile phones without having to go through Apple's complex approval processes each time.

This guide aims to guide you through the necessary software and tools that will help you get started developing your own app with ease.

It doesn't matter how good you are at programming, because if you can master the Android software development kit (SDK), your apps will turn out great. So, check out the resources below to get yourself into the swing of things.

Java Development Kit

The first thing you will need to start developing java applications (the basis of Android applications) is the Java Development Kit (JDK) from Oracle, which can be downloaded from the following link.

You've probably already downloaded and installed the Java Runtime Environment (JRE) in some form, which is needed to run applets on your computer. You need to uninstall the JRE version that is currently installed on your computer in case it conflicts with the JDK version that you are downloading. Luckily, the version above includes the latest and greatest version of the JRE, which is sure to be compatible with the JDK, eliminating the need to reinstall it.

Download and run the installer, make sure that 'Development Tools', 'Source Code' and 'Public JRE' are included in the installation in the manual installation window (can be seen below). Click 'Next', read the terms of the license agreement if you have enough free time, and proceed with the installation.

Although most integrated development environment (IDE) applications—we'll talk more about this in the next step—come with their own compiler, I recommend that you embed the newly installed Java compiler into the command line so that you can use it on demand.

If you are using Windows, go to System Settings from Control Panel and select Advanced System Settings. Here select ‘Environment Variables’ and find the ‘Path’ variable. Add a let to file as a 'bin' directory before your Java installation, as shown in the example below.

To check if everything was successful, use the commands 'java -version' and 'javac -version'. You should see something like the following:



Installing the IDE

Integrated development environments are often used by seasonal developers and newbies who want to develop applications. For those who don't know, an IDE is an application that helps programmers write code by providing a condensed set of tools like debuggers, compilers, and more.

Although there are many IDEs available on the internet, here we will use the free Eclipse software as Google provides a plugin to integrate it with the Android SDK. You can download the required version of Eclipse.

This may vary from case to case, but when I downloaded the resource, the software was provided as a zip archive that contained an 'eclipse.exe' file that you could get started with without any installation. If your version requires installation, then do it yourself, since there are no special requirements or settings. When you first launch it, the software will ask you to specify the ‘Workbench’ where your codes and related files are located. Please indicate a location that is convenient for you.

Once completed, you will be presented with the following:

If you want to get a little familiar with Eclipse before starting, open the Help window and look through the Workbench User Guide. You can also see the Development User Guide here, which will help you learn basic Java skills if you are not yet familiar with the language.

Download Android SDK

Follow this link and click ‘Get the SDK’. On the next page you will be given a link to install the Android SDK on your computer.

Once the download of the executable file is complete, start the installation. When you reach the window below, specify the path to the directory where you want to install, or remember the one that is already specified.

When the installation is complete, open Android SDK Manager, and then you will see the following window:

Click the button to install any required packages and resources that were not included in the original installation.

Install the Android Development Tools plugin

As noted above, Google offers a special Android SDK plugin for Eclipse that can be added directly from the IDE.

In Eclipse, go to 'Help' and select 'Install New Software'. Click the ‘Add’ button and you will then be taken to a window that will allow you to add an online software repository containing the ADT plugin. Give a descriptive name, and enter the following URL in the ‘Location’ block:

  • http://dl-ssl.google.com/android/eclipse

Click 'OK'. Select the newly added repository and check the ‘Developer Tools’ checkbox.

Click ‘Next’ and go through the steps to install the plugin files. Once completed, the following 2 icons should appear in your Eclipse Control Panel:

Now go to 'Window' and 'Preferences', select the 'Android' section and make sure that the SDK Location matches the SDK directory you specified earlier. As a result, you should get the following:

You are now the owner of the Android Development Tools plugin.

Setting up an Android emulator

While this helps, you don't actually need to have every model of Android device on hand to create apps for them, as Google provides us with a great emulator of its own mobile OS along with an SDK. Before starting development, it is advisable for us to configure the Android Virtual Device (AVD) so that the testing platform is ready in advance.

Now we need to create a new virtual device. This example assumes the creation of a general device, but there are also resources for specific settings for Android devices. Select ‘New’ and you will be presented with an empty window like the one below:

  • Name: If you want to test the application on multiple device settings, then you will need to enter something descriptive. On the other hand, a more general name can also be used.
  • Target: This is the version of Android that the emulator will target. In most cases, your option will be the latest version of Android, which comes with the SDK you install. However, if you want to test on earlier versions (which would be quite wise, given there are so many different versions and models), then use the SDK manager to install additional versions.
  • SD card: Indicator of additional storage space to be used in the device. By default, the virtual device has 194 megabytes of “internal” memory and an SD card, so you will need to manually specify the required amount of disk space.
  • Skin: You can use this option to set the appearance and configurations of a specific device (HTC One X, for example). But in our case we use the standard value.
  • Hardware: Since there are significant differences in hardware among physical Android devices, you can use this option to add any hardware that will be used by your application.

When finished, the AVD Manager window should include your newly created device. You can click ‘Start’ to start this device, just be aware that the first startup may take some time.



Your first Android project

Now that you have equipped your computer with all the necessary applications and plugins, you can start developing code. But first we need to prepare the project files.

To get started, go to 'File', 'New', 'Project' and open the Android tab. Select ‘Android Application Project’ there, and the following window will open in front of you:

You can use the drop-down menus next to each field to select the appropriate value. The main thing to consider is the ‘Application Name’, which is responsible for the name of our application during installation, as well as the ‘Minimum Required SDK’, with which you indicate the earliest version of Android that supports your application.

Click 'Next' to continue and set an executable icon to be the face of your application. The next menu will ask you to create an ‘Activity’ for your application.

This is the action or view that the user will interact with, so the most logical thing to do is to divide your application into activities in terms of which windows the user will see and what functionality will be available in each of them. So, if you are, for example, creating a simple "Hello World" program, then you only need one active window that represents the text, and all the interface settings are pulled from the resource files that the SDK creates.

When you have decided on these windows, click ‘Finish’. Eclipse will gather all the files needed for the application together into which you will write code and/or change settings to specify the parameters of your program.

And that is all! Everything is ready to assemble the finished application. You can find comprehensive tutorials on Google on how to develop Android apps (for those with programming experience). Anyone looking to get into Java programming should also first read tutorials like the one provided by Oracle.

Dmitry Dementiy

Do you doubt whether it is worth investing in mobile application development? You can do it yourself and absolutely free. You may end up with a test version that can be used to conveniently evaluate the effectiveness of your mobile strategy. And if you try, you will make a decent mobile application that will become the main tool for online interaction with owners of smartphones and tablets.

Is it worth making your own mobile app?

Costs. If you don't take my word for it, here are some facts:

  • According to Flurry Analytics and comScore, owners of smartphones and tablets use the browser only 14% of the total time they work with the device. And they spend 86% of their time on different applications.
  • The installed application is your direct channel of communication with the consumer. Just think: you don’t need to spend money on advertising or wait for a person to find you using Yandex. All that remains is to support the functionality the user needs and provide him with relevant content.
  • The number of purchases made using tablets and smartphones is growing both on the Internet in general and in RuNet. According to marketing agency Criteo, already in 2016, more than half of online transactions in RuNet will be made using mobile devices.

If you want, the application is a mobile browser in which only your website opens. In what case would a user install such an Internet browser? Only if he is interested in your product or information. Therefore, remember: the client who installed the application is a loyal and ready-to-buy representative of the target audience.

In this case, is it worth taking the risk and offering DIY applications to loyal customers rather than custom programs made by professionals for Android and iOS? Let's figure it out.

When can you create an application yourself?

Do you remember what website visitors need? They come because of the content or functionality of the resource. People want to get information, buy something, look at and comment on friends' photos, and so on. Mobile app users need the same. They are looking for information or making some kind of transaction.

Do you remember when a business could make a website on its own? It’s right when you don’t yet have money to collaborate with professionals, but you still have the time and desire to figure out WordPress or Joomla. The same situation is with applications. Self-created programs for iOS and Android can be roughly compared to websites built on open source engines.

You don't have to register to start working. Click the Create Now button on the main page or select the Create App menu in the upper right corner on any page of the service.


Select the appropriate application template. If we are talking about a content project, you may be interested in the following options:

  • Manual. This template allows you to create a guide program.
  • Blog. The application will help your blog audience read new notes from the screen of a smartphone or tablet.
  • Website. The template converts a website into an application.
  • Pages. With this template you can convert any content into an application with simple functionality.
  • News. The template allows you to create an application that is an aggregator of industry or regional news.
  • Page. The template converts offline content, such as an e-book, into the application.
  • VK Page and Facebook Page. Create an application that allows you to monitor updates of open groups on VKontakte and Facebook.
  • YouTube. Use the template to promote your YouTube channel.

How to Create a Blog App

Use the Blog template. In the appropriate field, enter the URL of your blog or RSS feed. Select a note title color.


Enter the name of the application.


Add a description.


Choose a standard one or add a custom icon. The appropriate image size is 512 by 512 pixels.


To create a download file, click the Create App button. After this, you need to register in the system. Confirm your registration and go to your personal account. Here you can install the application on your mobile device, publish it on Google Play and Amazon App Store. The system also offers a monetization option. If you use this feature, advertisements will be displayed in the application.


Check how the application works on your mobile device. On a tablet, the program should display a list of blog posts in title and announcement format.

In your AppsGeyser personal account, you can monitor the number of installations, create push notifications, publish the application in stores, monetize the program using advertising, and edit the application.


Want more apps? Then create a guide app using the Manual template.


After editing the content, specify the name of the application, add a description and an icon. Click the Create App button. After creating the download file, install it on your mobile device and check its functionality.

Please note that most mobile devices block the installation of applications from unknown sources by default. If a user downloads a program from your site or an app builder site, they will see a security warning when they try to install it. Some clients will probably refuse to install the program.


8 constructors similar to AppsGeyser

If the universal AppsGeyser constructor is not suitable for you, pay attention to similar services:

  • AppsMakerStore. Using the service, you can create applications of various types: from programs for Ecommerce to solutions for content projects. The designer makes applications for iOS and Android. The service interface is Russified. For beginners, there is an informative guide to using the constructor. The service is paid.
  • Mobincube. A tool for creating and monetizing iOS and Android applications. The basic functionality of the service is available for free. The designer allows you to create applications of different types.
  • Good Barber. Using this service you can develop Android and iOS applications. The constructor is paid, the cost of use is 16 USD per month.

Most of the services offered have an English-language interface. If you are uncomfortable working with constructors in English, choose platforms with Russian-language content.

Application designers: a stone ax or a thin modern tool?

Don't go from one extreme to another. With the help of the proposed services, you can really create functional functional applications. The resulting programs can be used to solve various problems: from facilitating online trading to distributing content and educating audiences. Applications created in the designer can be published on Google Play and the App Store, edited, and monetized using advertising or paid installations.

Do not overestimate the services offered. Their obvious drawback remains their stereotyped nature. We are talking about both the design and functionality of the programs. In addition, access to platforms with decent functionality is paid. What is better: to pay the developers for their work once or to pay the owners of the designer for many years? Do the math for yourself.

And one more thing: if you don’t have time to create a mobile application yourself, contact our company. We develop mobile applications and .

Contact us Shall we discuss? Order a free consultation

How to create a mobile application in Android Studio

Android Studio is an integrated development environment (IDE) based on IntelliJ IDEA, which Google calls the official IDE for Android applications.

This manual describes android application development:

  • Navigate between files using File Explorer
  • Installing the AndroidManifest.xml file
  • Importing files into a project
  • Advanced layout editor with dynamic preview feature
  • Using Logcat and Android Monitor to Debug Applications

Getting started in Android Studio

Launch Android Studio, in a window Android Studio Setup Wizard select Start a new Android Studio project(start a new project).

In the window Create New Project select Application Name(application name) as Fortune ball, enter the company domain; in field Project location select the location where the application will be saved. Click Next.

There is a window in front of you Target Android Devices. Select Phone and Tablet. In field Minimum SDK please indicate API 15. Click Next.

In the window Add an activity to Mobile select Basic Activity. Evaluate all the options, this window provides an overview of the available layouts.

Click Next.

In the window Customize the Activity, the screenshot of which is posted below, you can change Activity Name(name of activity), Layout Name(layout name), Title(common name) and Menu Resource Name(resource menu name). Leave the default values ​​and click Finish.

After a few seconds the following window will appear:

The same window will appear on your device or emulator. The emulator functions as a device and will take some time to load.

This is already an application. He lacks a lot, but now he can move on to the next step.

Project and file structure

The window shows the project files.

The drop-down menu (screenshot below) has several filters for files. The main ones are Project and Android.

The Project filter will show all application modules - each project contains at least one module. Other types of modules include modules from third-party libraries, or modules from other Android applications (such as Android Wear applications, Android TV). Each module has its own set of characteristics, including a gradle file, resources and source files (java files).

Note. If the project is not open, click the Project tab on the left side of the panel, as shown in the screenshot. By default, the Android filter is installed, which groups files by specific type. At the top level you will see the following folders:

  • manifests
  • Gradle Scripts

The following sections describe each of these folders in detail, starting with manifests.

Overview of AndroidManifest.xml

Every Android application has an AndroidManifest.xml file, which is located in the manifests folder. This XML file tells your system about the application's requirements. The presence of this file is mandatory, because it is what allows the Android system to create an application.

Open manifests folder and AndroidManifest.xml. Double click will open the file.

The manifest and application tags are needed for manifest and appear only once.

Each tag also defines a set of attributes, along with the element's name. For example, some attributes in application could be like this:

android:icon, android:label and android:theme

Among other things, the following may appear in manifest:

  • uses-permission: Requests a special permission that is given to the application in order to function correctly. For example, an application must ask the user for permission to access the network - in case you add the android.permission.INTERNET permission.
  • activity: Reports an activity that is partially responsible for the visual UI and logic. Any activity that is provided in the application must be added to the manifest - the system will not notice an unmarked activity, and it will not be displayed in the application.
  • service: Adds a service that you intend to use to implement long-running operations or advanced API communications with other applications. An example in this case would be a network call through which an application receives data. Unlike activities, services do not have user interfaces.
  • receiver: With a broadcast message receiver, an application receives signals about system messages or messages from other applications, even when other application components are not running. An example of such a situation is a battery with a low charge level and the operating system notifying about it.

A complete list of tags can be found in the manifest file on the Android Developer website.

Manifest file settings

Add the following attribute to activity:

android:screenOrientation=”portrait”. to limit the screen to portrait mode only. If this is not done, the screen, depending on the location of the device, will be in either landscape or portrait mode. After adding the attribute, the manifest file will look like the screenshot.

Create and run the application. If you are testing on your device, flip it over, make sure the screen does not move to landscape mode if you have limited this ability in the AndroidManifest file.

Gradle overview

Let's move on to Gradle. Gradle turns an Android project into an installable APK that can be installed on devices. The build.gradle file is present in Gradle scripts, at two levels: module and project.

Open the build.gradle file (Module:app). You will see the default gradle installation:

apply plugin: "com.android.application" android (compileSdkVersion 25buildToolsVersion "25.0.2" defaultConfig (applicationId "com.raywenderlich.fortuneball" minSdkVersion 15targetSdkVersion 25versionCode 1versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnit Runner")buildTypes (release (minifyEnabled falseproguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"))) dependencies (compile fileTree(dir: "libs", include: ["*.jar"])androidTestCompile(" com.android.support.test.espresso:espresso-core:2.2.2", (exclude group: "com.android.support", module: "support-annotations"))compile "com.android.support:appcompat- v7:25.1.0"compile "com.android.support:design:25.1.0"testCompile "junit:junit:4.12")

Let's look at the main components:

  • apply plugin: 'com.android.application' applies the Android plugin at the parent level and makes available the top-level tasks needed to build the application.
  • Next to the android(…) section are settings options such as targetSdkVersion. The target SDK for your application should be at the latest API level. Another important component is minSDKVersion (defines the minimum SDK version that must be installed on the device for the application to run). For example, if the SDK version is 14, then the application will not be able to run on that device, since in this particular case the minimum supported version is 15.
  • The last component is dependencies(…). It is necessary to note compile 'com.android.support:appcompat-v7:VERSION' and compile 'com.android.support:design:VERSION'. They provide support and compatibility of features of new and old APIs.

In addition to Android compatibility libraries, you can add third-party libraries to the dependencies(...) component. The animation library, for example, contains UI effects. Find dependencies, then add the following two lines down:

dependencies ( ... compile "com.daimajia.easing:library:2.0@aar" compile "com.daimajia.androidanimations:library:2.2@aar")

Here you can add third-party dependencies. Libraries are automatically downloaded and integrated into Android Studio. Click Sync Now to integrate these dependencies into your application.

Synchronization takes a few seconds. Gradle updates appear in the Messages tab of the bottom panel.

These are all the settings you will need in Gradle for now. Such manipulations will add animation to the application.

Importing files

When developing an Android application, integration with other resources is important: images, custom fonts, sounds, videos, etc. These resources are imported into Android Studio and placed in the appropriate folders, which allows the operating system to select the correct resources for the application. Our Fortune Ball application will need to import images into the drawable folders. These folders can contain images or special XML drawables files (i.e. you can draw shapes using XML code and use them in your layouts).

In Android Studio, go from Android to Project

Open the res folder (app > src > main). Right-click on the res folder, select New > Android resource directory.

A window called New Resource Directory will appear.

From the Resource type drop-down list, select the drawable option. In the Available qualifiers list, select Density, then click the button that is highlighted in the screenshot.

In the next window, select XX-High Density from the Density list. Click OK.

Repeat everything to create drawable-xhdpi, drawable-hdpi and drawable-mdpi folders. Select X-High, high and medium density respectively from the Density list.

Each folder that has a density identifier (i.e. xxhdpi, xhdpi, hdpi) contains images that are associated with a specific density or resolution. For example, the drawable-xxhdpi folder contains a high-density image, which means that an Android device with a high-resolution screen will draw the image from this folder. The image will look good on all Android devices, regardless of screen quality. More information about screen density can be found in the Android documentation.

Once you've created all the "drawn" folders, you can go back to the unzipped content in the folder and copy (cmd + C) the image from each folder and place (cmd + V) in the corresponding Android Studio folder.

Once you have placed the files, you will see the Copy window. Select OK.

XML View and Dynamic Layout Previews

Creating a layout that users can interact with is an important part of the process. In Android Studio, this can be done in the layout editor. Open content_main.xml from res/layout. In the Design tab you can move interface elements (buttons, text fields).

To the right of Design there is a Text tab that allows you to edit XML directly in the layout.

Before creating the appearance, you need to define some values. Open strings.xml in the res/values ​​tab and add the following:

Suggest the question, which you can answer “yes” or “no”, then click on the magic ball.

strings.xml contains all the strings that appear in the application. Separating these lines into separate files makes internationalization easier because You only need a string file for each language that is required in the application. Even if you don't intend to translate your application into other languages, using a string file is always recommended.

Open dimens.xml in res/values ​​and add the following:

15sp20sp

dimens.xml contains dimensional values, limit intervals for layouts, text size, etc. It is recommended to save this data in a file so that it can be used to create layouts in the future.

Go back to content_main.xml and replace the entire contents of the file with the following code:

This rather large code creates a layout for an application called FortuneBall. At the top level you have added a RelativeLayout (relative layout defines the position of the child components relative to the parent component). RelativeLayout can be stretched to fit the size of the parent component.

Relative markup adds two pieces of text, an image and a button. All these details will be visible in the order they were added. Their contents can be read in strings.xml (text) and drawable (images).

While updating content_main.xml, notice that the Preview window updates the UI:

Note: if the preview window is not visible, in the Text tab, click on the Preview button in the markup editor panel on the right.

Create and launch.

And now you have created the application layout. But at this stage it's just a pretty image - clicking on the button won't lead to anything.

Combining Activity and View

You can use java files located in app/src/main/java to establish logical connections in the application.

Open MainActivity.java and add this data under the existing ones:

Import java.util.Random;import android.view.View;import android.widget.Button;import android.widget.ImageView;import android.widget.TextView; import com.daimajia.androidanimations.library.Techniques;import com.daimajia.androidanimations.library.YoYo;

The first five imports point to the corresponding classes in your code: Random, View, Button, ImageView, and TextView. The following two imports indicate that you will use two classes from libraries, incl. build.gradle for animations. In MainActivity.java, in the MainActivity class, add:

String fortuneList = ("Don't count on it","Ask again later","You may rely on it","Without a doubt","Outlook not so good","It"s decidedly so","Signs point to yes","Yes definitely","Yes","My sources say NO"); TextView mFortuneText;Button mGenerateFortuneButton;ImageView mFortuneBallImage;

In this short piece of code you have set 4 variables for the activity. The first is the lines that define the possible states, the other three are the UI elements you created in the layout/markup.

Now replace the contents of the onCreate() method with the following:

// 1:super.onCreate(savedInstanceState);// 2:setContentView(R.layout.activity_main);Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);setSupportActionBar(toolbar);// 3:mFortuneText = (TextView) findViewById(R.id.fortuneText);mFortuneBallImage = (ImageView) findViewById(R.id.fortunateImage);mGenerateFortuneButton = ( Button) findViewById(R.id.fortuneButton); // 4:mGenerateFortuneButton.setOnClickListener(new View.OnClickListener() (@Overridepublic void onClick( View view) (// 5:int index = new Random().nextInt(fortuneList.length);mFortuneText.setText(fortuneList);// 6:YoYo.with(Techniques.Swing).duration(500).playOn(mFortuneBallImage);)));

  • Check that the activity is ready (superclass implementation).
  • Specify that the layout for this activity is represented by the layout you created earlier, check the toolbar.
  • Fill in the values ​​of the three variables you created earlier in the layout's views components using the findViewById method. The id value is the same as in the XML layout.
  • Add an OnClickListener on the button. This is a simple class that encapsulates (packages) the functionality that a button click calls.
  • Select a custom option from the fortuneList for this application, and update the fortune text to show it.
  • Use a third party library to add the dependency to the gradle file and thus add animation to the application.

It's almost ready. But you need to remove the floating button. Go to res/layout and open activity_main.xml.

This layout file contains a link to the content_main.xml that you previously edited. It defines the content by default (toolbar and floating action button). However, in this particular application (Fortune Ball), a floating button is not needed. Therefore, remove the following block of code from the xml file:

There is no longer a floating button in the lower right corner.

Ask a question (What’s my fortune?) - press the button. Check the application.

Android Monitor

Android Studio contains a wide variety of tools. Open the Android Monitor tab at the bottom of the Android Studio window.

Here you will find many options for the developer.

  • The camera and play button on the left allow you to take screenshots and record videos.
  • The magnifying glass opens up a number of additional options, such as analyzing the application's memory.
  • The Layout Inspector provides a visual interface that determines why an application's interface looks a certain way.

LogCat provides a detailed overview of system messages with the ability to drill down into specific application data, or even use the search bar to filter messages if they don't contain specific characters.

Make sure you have selected Show only selected application in the top right corner as shown in the screenshot above. Now only your app's messages will be visible.

In MainActivity.java, add the following to the list of imports:

Import android.util.Log;

At the end of onCreate() in MainActivity.java add the following line:

Log.v("FORTUNE APP TAG","onCreateCalled");

Log.v calls two parameters - tag and message. In this case, the tag is defined as “FORTUNE APP TAG” and the message is defined as “onCreateCalled”.

Run the application to see the log message in the Logcat panel.

Filter the contents of LogCat, enter onCreateCalled in the search bar above the console:

Then delete the search text to see all log messages again.

Another useful feature is logcat, which is the ability to view error messages. Add a bug to your perfectly functional application to see how things work.

Go to MainActivity.java and change the following line in onCreate():

//mFortuneText = (TextView) findViewById(R.id.fortuneText);

Launch the application. Click the What's My Fortune? button Does not work!

How would you fix the error if you didn't know there was a bug? Logcat will help with this.

Go to the Logcat panel - it looks something like this:

There's a lot of red text here. In this case, the problem is line 50 in the MainActivity.java file. LogCat turned this link into a blue hyperlink. If you press it, you can find out what the problem is.

By changing mFortuneText = (TextView) findViewById(R.id.fortuneText), you created a variable but did not specify its value - hence the null pointer exception. Go back and change the code, run the application. This time everything works smoothly. Logcat is a useful tool for finding errors.

Share this article:

Related Articles

Did you like the article? Share with friends: