1. INDEX
S.N
O
Name of the experiment
Page.
no
1. Installation of Android studio. 1
2. Development Of Hello World Application 7
3.
Create an application that takes the name from a textbox and
shows hello message along with the name entered in text
box, when the user clicks the OK
Button
11
4. Project Definition 15
5. Statement of work
5.1 Functional requirements
5.2 Software and Hardware requirements
17
6. Implementation 20
7. Screenshots 24
8. Conclusion 28
9. References 29
2. NEWS APP
Department of Computer Science and Engineering 1
Faculty of Engineering and Technology KBNU, Kalaburagi
1. EXPERIMENT NO.1
INSTALLING AND RUNNING APPLICATIONS ON ANDROID STUDIO
Step 1 - System Requirements
The required tools to develop Android applications are open source and can
be downloaded from the Web. Following is the list of software's you will
need before you start your Android application programming.
Java JDK5 or later version
Java Runtime Environment (JRE) 6 Android Studio
Step 2 - Setup Android Studio
Android Studio is the official IDE for android application development.It
works based on IntelliJ IDEA, You can download the latest version of
android studio from Android Studio 2.2 Download, If you are new to
installing Android Studio on windows,you will find a file, which is named
as android-studio-bundle- 143.3101438-windows.exe.So just download and
run on windows machine according to android studio wizard guideline.
If you are installing Android Studio on Mac or Linux, You can download
the latest version from Android Studio Mac Download,or Android Studio
Linux Download, check the instructions provided along with the
downloaded file for Mac OS and Linux. This tutorial will consider that you
are going to setup your environment on Windows machine having Windows
8.1 operating system. Installation
So let's launch Android Studio.exe,Make sure before launch Android Studio,
Our Machine should required installed Java JDK. To install Java JDK,take a
references of Android environment setup
Once you launched Android Studio, its time to mention JDK7 path or later
version in android studio installer.
3. NEWS APP
Department of Computer Science and Engineering 2
Faculty of Engineering and Technology KBNU, Kalaburagi
Below the image initiating JDK to android SDK
Need to check the components, which are required to create applications, below
the image has selected Android Studio, Android SDK, Android Virtual Machine
and performance(Intel chip).
4. NEWS APP
Department of Computer Science and Engineering 3
Faculty of Engineering and Technology KBNU, Kalaburagi
Need to specify the location of local machine path for Android studio and Android SDK,
below the image has taken default location of windows 8.1 x64 bit architecture.
Need to specify the ram space for Android emulator by default it would take 512MB of
local machine RAM.
At final stage, it would extract SDK packages into our local machine, it would take a while
time to finish the task and would take 2626MB of Hard disk space.
After done all above steps perfectly, you must get finish button and it gonna be open android
studio project with Welcome to android studio message as shown below
5. NEWS APP
Department of Computer Science and Engineering 4
Faculty of Engineering and Technology KBNU, Kalaburagi
You can start your application development by calling start a new android studio project. in a
new installation frame should ask Application name, package information and location of the
project.
After entered application name, it going to be called select the form factors your application
runs on, here need to specify Minimum SDK, in our tutorial, I have declared as API23:
Android 6.0(Mashmallow)
The next level of installation should contain selecting the activity to mobile, it specifies the default
layout for Applications
6. NEWS APP
Department of Computer Science and Engineering 5
Faculty of Engineering and Technology KBNU, Kalaburagi
At the final stage it going to be open development tool to write the application code.
Step 3 - Create Android Virtual Device
To test your Android applications, you will need a virtual Android device. So before we start
writing our code, let us create an Android virtual device. Launch Android AVD Manager
Clicking AVD_Manager icon as shown below
After Click on a virtual device icon, it going to be shown by default virtual devices
which are present on your SDK, or else need to create a virtual device by clicking
Create new Virtual device button
7. NEWS APP
Department of Computer Science and Engineering 6
Faculty of Engineering and Technology KBNU, Kalaburagi
If your AVD is created successfully it means your environment is ready for Android
application development. If you like, you can close this window using top-right cross button.
Better you re- start your machine and once you are done with this last step, you are ready to
proceed for your first Android example but before that we will see few more important
concepts related to Android ApplicationDevelopment.
8. NEWS APP
Department of Computer Science and Engineering 7
Faculty of Engineering and Technology KBNU, Kalaburagi
2. DEVELOPMENT OF HELLO WORLD APPLICATION
AIM: To design an android application to display Hello World First step is to create
a simple Android Application using Android studio. When you click on Android
studio icon, it will show screen as shownbelow
You can start your application development by calling start a new
android studio project. in a new installation frame should ask
Application name, package information and location of the project.−
Configure the Hello World Project Details We'll finish creating the project by
configuring some details about its name, location, and the API version it
9. NEWS APP
Department of Computer Science and Engineering 8
Faculty of Engineering and Technology KBNU, Kalaburagi
Change the name of the application. Change the default Project location to your
preferred directory or just leave it as the default location.
On the minimum API level, ensure that API 15: Android 4.0.3 IceCreamSandwich is
set as the Minimum SDK. This ensures that your application runs on almost all devices.
The next level of installation should contain selecting the activity to mobile, it specifies the default
layout for Applications.
10. NEWS APP
Department of Computer Science and Engineering 9
Faculty of Engineering and Technology KBNU, Kalaburagi
SOURCE CODE:
The Main Activity File
The main activity code is a Java file MainActivity.java. This is the actual
application file which ultimately gets conerted to a Dalvik executable and
runs your applications.
Package com.example.helloworldapplication;
import android.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivty wxtends AppCompatActivity {
@Override
Protected void onCreate(BundlesavedInstanceState) {
Super.onCreate(savedInstanceState);
setContentVIew(R.layout.activity_main);
}
}
The Layout File
The activity_main.xml is a layout file available in res/layout directory, that is referenced by
your application when building it’s interface. You will modify this file very frequently to
change the layout of your application. For your “Hello World!” application, this file will have
following content related to default layout.
<RelativeLayout
xmlns:android=”http://schemas.android.com/apk/res/android”
xmlns:tools=”http://schemas.android.com/tools”
android”layout_width=”match_parent”
android:layout_height=”match_parent”
>
<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_centerHorizontal=”true”
android:layout_centerVertical=”true”
android:padding=”@dim en/padding_medium”
android:text=”@string/hello_world”
tools:context=”MainActivity”/>
11. NEWS APP
Department of Computer Science and Engineering 10
Faculty of Engineering and Technology KBNU, Kalaburagi
I )Running app on Phone:
Connect your Phone to Computer
Plug in your device to your computer with a USB cable. If you're developing on
Windows, you might need to install this universal ADB USB driver or find your specific
USB driver for your
device.
The next step is to enable USB debugging so your phone can interact with your
computer in a developer mode.
The following steps are needed:
1. (Windows Only) Install this ADBDriver
2. Plug-in your Android Device to Computer viaUSB
3. Open the "Settings" App on the Device
4. Scroll down to bottom to find "About phone"item
5. Scroll down to bottom to find "Build number" section
6. Tap on "Build Number" 7 times in quicksuccession
7. You should see the message "You are now adeveloper!"
8. Go back to main "Settings" page
9. Scroll down bottom to find "Developer options"item
10. Turn on "USB Debugging" switch and hit "OK"
11. Unplug and re-plug thedevice
12. Dialog appears "Allow USBDebugging?"
13. Check "Always allow from this computer" and then hit "OK"
Running your App
Now, we can launch apps from Android Studio onto our device:
1. Select one of your projects and click "Run" from the toolbar.
2. In the "Choose Device" window that appears, select the "Choose a running
device" radio button, select the device, and clickOK.
II) Running app on Emulator(AVD)
To run the app from Android studio, open one of your project's activity files
and click Run icon from the tool bar. Android studio installs the app on
your AVDand starts it and if everything is fine with your set-up and
application, it will display following Emulator window −Once Gradle
finishes building, Android Studio should install the app on your connected
device and start it.
12. NEWS APP
Department of Computer Science and Engineering 11
Faculty of Engineering and Technology KBNU, Kalaburagi
3. Create an application that takes the name from a text box and
shows hello message along with the name entered in text box, when the
user clicks the OK button.
Code forMainActivity.java
packagecom.example.akshay.m
rcet; import android.os.Bundle;
import
android.support.v7.app.AppCompatActiv
ity; import android.view.View;
import android.widget.Button;
import
android.widget.EditText;
importandroid.widget.TextVie
w;
public class MainActivity extends AppCompatActivity {
// These are the global
variables EditText editName,
editPassword; TextView
result;
Button buttonSubmit, buttonReset;
@Override
protected void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editName = (EditText)
findViewById(R.id.editName); editPassword =
(EditText) findViewById(R.id.editPassword); result =
(TextView) findViewById(R.id.tvResult);
buttonSubmit = (Button)
findViewById(R.id.buttonSubmit); buttonReset =
(Button) findViewById(R.id.buttonReset);
/*
Submit Button
*/
buttonSubmit.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
String name = editName.getText().toString();
String password = editPassword.getText().toString();
result.setText("Name:t" + name + "nPassword:t" +
password );
}
15. NEWS APP
Department of Computer Science and Engineering 14
Faculty of Engineering and Technology KBNU, Kalaburagi
<TextView
android:id="@+id/
tvResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="143dp"
android:textSize="30sp" />
</RelativeLayout>
16. NEWS APP
Department of Computer Science and Engineering 15
Faculty of Engineering and Technology KBNU, Kalaburagi
4. PROJECT DEFINITION
The Android News App project aims to develop a mobile application that provides users with up-to-
date news and information from various reliable sources. The app is written in Kotlin, leveraging its
features and benefits to create an efficient and user-friendly interface. This report outlines the entire
development process, including project definition, statement of work, functional requirements,
software, and hardware requirements, implementation details, and a concluding remark. As world’s
technology is rapidly growing we has fast connection and network to instantly connect to other
person. Day to day use in mobile, tablets and laptop is increasing, most of the people already have
this facilities. In this fast and information oriented world we need to stay updated with every
incidents and news too. This News app is android mobile application where user have access to latest
news from 120+ newspapers from 50+ countries. The main focus of this application is to connect
news articles from all around the world and deliver it to user as fast as possible in best visualize way.
In today's fast-paced world, staying informed about current events and news is crucial. Mobile
applications have become a popular medium for accessing news due to their convenience and
accessibility. The Android News App provides an efficient and personalized news browsing
experience for Android users. The app aggregates news articles from multiple reputable sources and
allows users to customize their preferences. Android provides simple application structure and requires
Java and Mark-up languages knowledge to work with. Such as, an discrete movement delivers a solitary
screen for a user interface and a service whole completes work in the contextual . We can work on different
module separately and can combine at the end, we can also add future modules easily afterwards. In 2014, a
design language has been created by google named Material Design which is based on “cards” uses
grind based layouts, responsive animation, padding and depth effects like shadow to create an
responsive, attractive and easy user interface. With the use of different libraries and material design
it is possible to use attractive UI. News apps provide a convenient and a customizable way for users
to access news content. This is tailored to their interests and preferences. They offer a wider range of
sources & real-time updates, making them an essential tool for staying informed about the world
around us.
The online News App is a revolution of news industry. The traditional bookstores and stores
operation time, address and space is limited. So the types of newspapers and articles to find, received
a degree of restriction But the online News App broke the management mode of traditional
bookstores and shops as long as you have a mobile phone, You can use the News App anywhere,
saving time and effort, shortening the time of news selection link effectively. The online news
system based on the principle provides convenience and service to people.
The Android News App is designed to cater to users who seek a user-friendly and reliable platform to
access news articles. The primary objectives of the project include:
Creating a visually appealing and intuitive user interface.
Implementing a backend system to fetch news articles from various sources.
Allowing users to customize their news feed based on categories and preferences.
Providing features for saving and sharing articles.
Ensuring smooth performance and responsiveness of the application.
17. NEWS APP
Department of Computer Science and Engineering 16
Faculty of Engineering and Technology KBNU, Kalaburagi
The primary objective of the Android News App is to deliver a seamless and efficient news reading
experience to users. The key features of the app include:
News Categories: The app offers various categories such as politics, technology, sports,
entertainment, etc., allowing users to explore news articles of their interest.
Real-time Updates: News articles are fetched from reputable news APIs, ensuring the content is
up-to-date and reliable.
Search Functionality: Users can search for specific news articles or topics using keywords.
Bookmarks: The app provides the option to bookmark favorite articles for later reading.
Available Features:
Global Support: Different type of newspaper will be available from all around the world in
different languages with this user will be able to get news from all around the world.
Sharing: User will be able to share news easily on social media.
Short News: News will be displayed in short format with title, image and little description in list
view. It will help user to access required news faster.
Search Option: User will be able to search from not only one source but many different sources
available within API.
Favorites / Offline Reading: News can be added as favorites which will automatically will be
saved for offline reading.
5. STATEMENT OF WORK
5. 1 Functional Requirements
User Registration and Login: Users can create accounts and log in to access personalized news feeds.
News Categories: The app will offer various categories such as politics, sports, technology,
entertainment, etc., allowing users to select their preferred topics.
Search Functionality: Users can search for specific news articles.
Save and Share: Users can save articles to read later and share interesting articles with others through
various platforms.
Offline Access: The app will support offline access to previously fetched news articles.
Push Notifications: Users will receive notifications for news or articles.
News feed: this app should display a personalized news feed based on the user’s chosen categories
and interests.
18. NEWS APP
Department of Computer Science and Engineering 17
Faculty of Engineering and Technology KBNU, Kalaburagi
Article Viewing: Users should be able to view complete news articles with images and relevant
details.
Category Management: The app should provide options to add, remove, or reorder news categories.
Trending News: A section displaying trending news articles to keep users updated with the most
popular topics.
Font Size Customization: Users should have the ability to adjust the font size for better readability.
Dark Mode: Implementing a dark mode feature for better usability in low-light conditions.
5.2 SOFTWARE AND HARDWARE Requirements
The successful implementation of the Android News App relies on specific software and hardware
prerequisites. This section discusses the required development tools, programming languages, and
technologies, including Kotlin, Android Studio, and API integrations. It also outlines the hardware
specifications necessary for the app to run optimally on Android devices.
Software:
Android Studio: Integrated Development Environment (IDE) for Android app development.
Kotlin: The programming language used for writing the Android app.
Firebase: Backend-as-a-Service (BaaS) for user authentication and data storage.
News API: External API to fetch news articles from various sources.
Hardware:
Android device or emulator for testing the app during development.
Minimum 8GB RAM
Quad-core processor
Android OS version 5.0 (Lollipop) or higher
Internet connectivity (Wi-Fi or mobile data)
19. NEWS APP
Department of Computer Science and Engineering 18
Faculty of Engineering and Technology KBNU, Kalaburagi
DESIGN
Fig. Android News Application Flowchart
20. NEWS APP
Department of Computer Science and Engineering 19
Faculty of Engineering and Technology KBNU, Kalaburagi
6. IMPLEMENTATION
SOURCE CODE :
The Main Activity File - The main activity code is a Kotlin file MainActivity.kt.
package com.example.newsapp
import android.content.Context
import android.content.Intent
import android.net.ConnectivityManager
import android.net.NetworkCapabilities
import android.os.Build
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.lifecycle.ViewModelProvider
import androidx.viewpager2.widget.ViewPager2
import com.example.newsapp.adapters.FragmentAdapter
import com.example.newsapp.architecture.NewsViewModel
import com.example.newsapp.utils.Constants.BUSINESS
import com.example.newsapp.utils.Constants.ENTERTAINMENT
import com.example.newsapp.utils.Constants.GENERAL
import com.example.newsapp.utils.Constants.HEALTH
import com.example.newsapp.utils.Constants.HOME
import com.example.newsapp.utils.Constants.SCIENCE
import com.example.newsapp.utils.Constants.SPORTS
import com.example.newsapp.utils.Constants.TECHNOLOGY
import com.example.newsapp.utils.Constants.TOTAL_NEWS_TAB
import com.facebook.shimmer.ShimmerFrameLayout
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
class MainActivity : AppCompatActivity() { // Tabs Title
private val newsCategories = arrayOf(
HOME, BUSINESS,
ENTERTAINMENT, SCIENCE,
SPORTS, TECHNOLOGY, HEALTH
)
private lateinit var viewModel: NewsViewModel
private lateinit var tabLayout: TabLayout
private lateinit var viewPager: ViewPager2
private lateinit var fragmentAdapter: FragmentAdapter
private lateinit var shimmerLayout: ShimmerFrameLayout
private var totalRequestCount = 0
21. NEWS APP
Department of Computer Science and Engineering 20
Faculty of Engineering and Technology KBNU, Kalaburagi
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main) // Set Action Bar
val toolbar: Toolbar = findViewById(R.id.toolbar)
setSupportActionBar(toolbar)
tabLayout = findViewById(R.id.tab_layout)
viewPager = findViewById(R.id.view_pager)
shimmerLayout = findViewById(R.id.shimmer_layout)
viewModel = ViewModelProvider(this)[NewsViewModel::class.java]
if (!isNetworkAvailable(applicationContext)) {
shimmerLayout.visibility = View.GONE
val showError: TextView = findViewById(R.id.display_error)
showError.text = getString(R.string.internet_warming)
showError.visibility = View.VISIBLE
} // Send request call for news data
requestNews(GENERAL, generalNews)
requestNews(BUSINESS, businessNews)
requestNews(ENTERTAINMENT, entertainmentNews)
requestNews(HEALTH, healthNews)
requestNews(SCIENCE, scienceNews)
requestNews(SPORTS, sportsNews)
requestNews(TECHNOLOGY, techNews)
fragmentAdapter = FragmentAdapter(supportFragmentManager, lifecycle)
viewPager.adapter = fragmentAdapter
viewPager.visibility = View.GONE
}
private fun requestNews(newsCategory: String, newsData: MutableList<NewsModel>) {
viewModel.getNews(category = newsCategory)?.observe(this) {
newsData.addAll(it)
totalRequestCount += 1 // If main fragment loaded then attach the fragment to viewPager
if (newsCategory == GENERAL) {
shimmerLayout.stopShimmer()
shimmerLayout.hideShimmer()
shimmerLayout.visibility = View.GONE
setViewPager()
}
if (totalRequestCount == TOTAL_NEWS_TAB) {
viewPager.offscreenPageLimit = 7
}
}
}
private fun setViewPager() {
if (!apiRequestError) {
viewPager.visibility = View.VISIBLE
TabLayoutMediator(tabLayout, viewPager) { tab, position ->
tab.text = newsCategories[position]
}.attach()
}
22. NEWS APP
Department of Computer Science and Engineering 21
Faculty of Engineering and Technology KBNU, Kalaburagi
else {
val showError: TextView = findViewById(R.id.display_error)
showError.text = errorMessage
showError.visibility = View.VISIBLE
}
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_item_mainactivity, menu)
return super.onCreateOptionsMenu(menu)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
intent = Intent(applicationContext, SavedNewsActivity::class.java)
startActivity(intent)
return super.onOptionsItemSelected(item)
} // Check internet connection
private fun isNetworkAvailable(context: Context): Boolean {
val connectivityManager =
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
// For 29 api or above
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
val capabilities =
connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)
?: return false
return when {
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> true
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> true
capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> true
else -> false
}
} else { // For below 29 api
if (connectivityManager.activeNetworkInfo != null &&
connectivityManager.activeNetworkInfo!!.isConnectedOrConnecting) {
return true
}
}
return false
}
companion object {
var generalNews: ArrayList<NewsModel> = ArrayList()
var entertainmentNews: MutableList<NewsModel> = mutableListOf()
var businessNews: MutableList<NewsModel> = mutableListOf()
var healthNews: MutableList<NewsModel> = mutableListOf()
var scienceNews: MutableList<NewsModel> = mutableListOf()
var sportsNews: MutableList<NewsModel> = mutableListOf()
var techNews: MutableList<NewsModel> = mutableListOf()
var apiRequestError = false
var errorMessage = "error"
}
}
23. NEWS APP
Department of Computer Science and Engineering 22
Faculty of Engineering and Technology KBNU, Kalaburagi
News Model file
package com.example.newsapp
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity(tableName = "News_Table")
data class NewsModel(
@PrimaryKey(autoGenerate = false)
@ColumnInfo(name = "headline")
val headLine: String,
@ColumnInfo(name = "imgurl")
val image: String?,
@ColumnInfo(name = "description")
val description: String?,
@ColumnInfo(name = "url")
val url: String?,
@ColumnInfo(name = "source")
val source: String?,
@ColumnInfo(name = "time")
val time: String?,
@ColumnInfo(name = "content")
val content: String?
)
24. NEWS APP
Department of Computer Science and Engineering 23
Faculty of Engineering and Technology KBNU, Kalaburagi
7. SNAPSHOTS
HOME PAGE OF NEWS APP WITH ANDROID VIRTUAL DEVICE FRAME
25. NEWS APP
Department of Computer Science and Engineering 24
Faculty of Engineering and Technology KBNU, Kalaburagi
HOME PAGE OF NEWS APP
26. NEWS APP
Department of Computer Science and Engineering 25
Faculty of Engineering and Technology KBNU, Kalaburagi
DIFFERENT SECTIONS OF NEWS APP (SCIENCE)
27. NEWS APP
Department of Computer Science and Engineering 26
Faculty of Engineering and Technology KBNU, Kalaburagi
SAVED BOOKMARKS SECTION OF NEWS APP
28. NEWS APP
Department of Computer Science and Engineering 27
Faculty of Engineering and Technology KBNU, Kalaburagi
Conclusion
The Android News App project successfully developed a user-friendly and efficient mobile
application that allows users to access news articles from various sources. The app's intuitive
interface, personalized news feed, and offline access feature enhance the user experience.
Throughout the development process, the team followed best practices and utilized the Kotlin
programming language to take advantage of its robust features. The project achieved its stated
objectives and provides a solid foundation for future enhancements and updates.
The Android News App is a valuable and timely project that aims to deliver a reliable and user-
friendly platform for news consumers. Through this application, users can access real-time news
articles from various categories and stay informed about current affairs. The development process
will follow agile practices to ensure flexibility and adherence to project goals. The successful
completion of the Android News App will provide a valuable learning experience in Kotlin and
Android app development, contributing to the enhancement of mobile development skills.
In conclusion, the Android News App represents a valuable tool for users seeking an all-in-one
platform to stay informed and up-to-date with the latest news and events.
29. NEWS APP
Department of Computer Science and Engineering 28
Faculty of Engineering and Technology KBNU, Kalaburagi
References
www.developer.android.com
www.source.android.com
www.wikipedia.com
www.images.google.com
www.firebase.google.com