Skip to content

Krishanadave671/-hackfest-App-session

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Hackfest Intro App

πŸ‘‹ Hello guys This repository is made for learning the contents in structured way what you all performed in hackfest Android development session .

Table of contents :

Introduction

Let's get started with Android development πŸ”₯πŸ”₯πŸ”₯

Before starting with android development Just have a little overview on what android is ?

Android is a mobile operating system based on a modified version of the Linux kernel and other open-source software, designed primarily for touchscreen mobile devices such as smartphones and tablets. Android is developed by a consortium of developers known as the Open Handset Alliance and commercially sponsored by Google.

so now we will start developing our first app and understand how to develop a app?

Android Studio is the official integrated development environment (IDE) for Google's Android operating system, built on JetBrains' IntelliJ IDEA software and designed specifically for Android development. It is available for download on Windows, macOS and Linux based operating systems.

Install Android studio

Note : Install Android studio if system has at least 8GB RAM

But even if you have a system having 4GB+ of ram, you can still install it and work on it. We also initially started Android development on a 4GB system.

For those of you having less than 8GB ram follow this link to set up USB debugging, DONT INSTALL VIRTUAL EMULATORS

Android meme

Now we have Installed Android studio our setup is ready Let's Goo πŸ”₯πŸ”₯

Let us create our first android project

Create a new Project

Android dolphin photo

Click on create new project

Create new project

Choose an Empty Activity

choose Activity

So here , you can see that there are various activities which we can use according to our need

There are lots of activities available like Map activity , login activity etc ... All this Activity have predefined components code available.

As a beginner we will choose Empty activity we will built our app from scratch to better understand components of android.

What is Activity ?

An Android activity is one screen of the Android app’s user interface. In that way an Android activity is very similar to windows in a desktop application. An Android app may contain one or more activities, meaning one or more screens

Then we comes to our next screen

image

First give Name to your project (package name is automatically choosen by Android studio)

Note: choose packagename unique There is no issue for our local projects . when we upload app on playstore unique package name is required so better to keep package name unique

Choose language : There are two options java and kotlin

we will choose java language for our project .

what is SDK?

Android SDK stands for Android Software Development Kit which is developed by Google for Android Platform. With the help of Android SDK, we can create android Apps easily.

Android SDK is a collection of libraries and Software Development tools that are essential for Developing Android Applications. Whenever Google releases a new version or update of Android Software, a corresponding SDK also releases with it. In the updated or new version of SDK, some more features are included which are not present in the previous version

In simple words , just you can understand your android mobile versions like jelly bean , lollipop etc we will choose minimum sdk that should be compatible to many devices .

we will choose Min sdk for our project : API 21 : Android 5.0(Lollipop)

image

Now our Android studio

image

on Bottom left side Gradle sync finished

As we start our new project Gradle download some packages and sync the project so it takes time to load the project

if you want to know more about android build.gradle click here

let's understand first project structure of Android App

Main Activity.java code

code to create Instance of class

TextInputLayout name , year , branch ;
    Button button ;

Code to hide action bar

getSupportActionBar().hide();

Code to connect variables to text fields

name = findViewById(R.id.textField);
year = findViewById(R.id.textField2);
branch = findViewById(R.id.textField3);

Code to connect variables to button

button = findViewById(R.id.button);

Code to get data from text fields

String studentName = name.getEditText().getText().toString();
String studentyear= year.getEditText().getText().toString();
String studentbranch = branch.getEditText().getText().toString();

Code to create your message

String text = "Hello guys ! my name is " + studentName + "\n I am from " + studentyear + " studying in " + studentbranch + " I made my first app today It was amazing πŸ₯³πŸ₯³πŸ₯³πŸ’–";

Code to send a pop up message

Toast.makeText(MainActivity.this, "Hello my name is" + studentName + " " + studentyear + " " + studentbranch , Toast.LENGTH_SHORT).show();

Code to change activity

Code to add click listener to button

button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                String studentName = name.getEditText().getText().toString();
                String studentyear= year.getEditText().getText().toString();
                String studentbranch = branch.getEditText().getText().toString();
                String text = "Hello guys ! my name is " + studentName + "\n I am from " + studentyear + " studying in " + studentbranch +
                        " I made my first app today It was amazing πŸ₯³πŸ₯³πŸ₯³πŸ’–";
                Toast.makeText(MainActivity.this, "Hello my name is" + studentName + " " + studentyear + " " + studentbranch , Toast.LENGTH_SHORT).show();
                Intent i = new Intent(MainActivity.this , MainActivity2.class);
                i.putExtra("text" , text );
                startActivity(i);

            }
        });

MainActivity2 .java code

Code to create Instance of classes

Button button2 ;
TextView textView2 ;

Code to connect variables to text fields

button2 = findViewById(R.id.button2);
textView2 = findViewById(R.id.textView2);

Code to get data from previous activity

Intent intent = getIntent();
String text = intent.getStringExtra("text");

Code to set text of the text fields

textView2.setText(text);

Code to send message to WhatsApp

Intent whatsappIntent = new Intent(Intent.ACTION_SEND);
whatsappIntent.setType("text/plain");
whatsappIntent.setPackage("com.whatsapp");
whatsappIntent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(whatsappIntent);

Code to add click listener to button
button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent whatsappIntent = new Intent(Intent.ACTION_SEND);
                whatsappIntent.setType("text/plain");
                whatsappIntent.setPackage("com.whatsapp");
                whatsappIntent.putExtra(Intent.EXTRA_TEXT, text);
                startActivity(whatsappIntent);
            }
        });

For support, email krishnadave671@gmail.com

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages