Facebook Twitter Instagram
    DeepCrazyWorld
    Facebook Twitter Instagram Pinterest YouTube
    • FLUTTER
      • FLUTTER APP
        • QRCode
        • Quiz App
        • Chat GPT
        • PDF App
        • News App
        • Fitness App
        • Weather App
        • BMI Calculator
        • GAME APP
        • Ecommerce App
        • wallpaper App
        • Finance app
        • Chat App
        • Wallet App
        • Taxi App
        • Quran app
        • Music player app
      • FLUTTER UI
        • Splash Screen
        • Onboarding Screen
        • Login Screen
        • Card Design
        • Drawer
    • PROJECT
      • Android Projects
      • College Projects
      • FLUTTER APP
      • Project Ideas
      • PHP Projects
      • Python Projects
    • SOURCE CODE
    • ANDROID
      • ANDROID APP
      • GAME APP
      • ANDROID STUDIO
    • MCQ
      • AKTU MCQ
        • RPA MCQ
        • COA MCQ
        • HPC MCQ
        • SPM MCQ
        • Renewable Energy All MCQ
        • Data Compression MCQ
        • Data Structure MCQ
        • Digital Image Processing MCQ
        • Software Engineering MCQ
        • Machine Learning MCQ
        • Artificial Intelligence MCQ
      • D PHARMA MCQ
        • Pharmaceutics – I MCQ
        • Pharmacognosy MCQ
        • Pharmaceutical Chemistry MCQ
        • Biochemistry and Clinical Pathology MCQ
        • Human Anatomy and Physiology MCQ
        • Heath Education and Community Pharmacy MCQ
    • INTERVIEW QUESTIONS
      • Flutter Interview Questions
      • INTERVIEW QUESTIONS
      • Python Interview Questions
      • Coding ninjas solution
    • MORE
      • WORDPRESS
        • SEO
        • TOP 10 WORDPRESS THEME
      • PRODUCTIVITY
      • Program
      • QUOTES
    DeepCrazyWorld
    Home»ANDROID APP»How to Create News App Android Studio | Source code free
    ANDROID APP

    How to Create News App Android Studio | Source code free

    DeepikaBy DeepikaJune 29, 2020Updated:January 19, 2022No Comments5 Mins Read

    Create News Application Android Studio – Here i will show how to create android news application in android studio. There are more popular news channel will be there but here you can also develop the updated & Create news app in your android platform using API key.

    I have used New York Times API key to get latest news updates, it’s regularly update all topic like social, sports, entertainment news and more. So you have just get the API key and insert from our android news application project. After that the API key automatically fetch all news and show from android application feed.

    Table of Contents

    Toggle
      • Create News Application Android Studio
      • Get API key
    • MainActivity.java
    • ListNewsAdapter.java
      • NOTE- Remaining all code are given in Source code click and download below
    • ADD Dependency on gradle file
    • gradle.app
    • YouTube Video
    • Download Source Code
      • Click below to get the source code android news application.
      • Download News Apk: CLICK ME
      • Download News Logo: CLICK ME
    • Conclusion
      • Cheers!
    • READ MORE…

    Create News Application Android Studio

    <img decoding=

    Let’s start to develop android news application. First very important to get API key from New York Times websites. So in below i give link for how to get API key for your project create news app. Open the link and just register your account via enter email. After that they send API key from your registered email-id. Copy the API key and paste from your project (build.gradle file).

    Get API key

    Link for API website- https://newsapi.org
    Click here to Get NYT API Key – New York Times APIs. Just fill that details in the link they ask your Name and Email-id after fill the SignUP form you get API key.

    Create News App
    As usual File=>create news app project and choose Empty Activity, after creating the project open the default class of MainActivity.java file and add the following below code,

    MainActivity.java

    package com.dude.newsapp;
    
    import android.content.Intent;
    import android.os.AsyncTask;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.AdapterView;
    import android.widget.ListView;
    import android.widget.ProgressBar;
    import android.widget.Toast;
    import androidx.appcompat.app.AppCompatActivity;
    import org.json.JSONArray;
    import org.json.JSONException;
    import org.json.JSONObject;
    import java.util.ArrayList;
    import java.util.HashMap;
    
    public class MainActivity extends AppCompatActivity {
    
        String API_KEY = "8190df9eb51445228e397e4185311a66"; // ### YOUE NEWS API HERE ###
        String NEWS_SOURCE = "techcrunch"; // Other news source code at: https://newsapi.org/sources
        ListView listNews;
        ProgressBar loader;
    
        ArrayList<HashMap<String, String>> dataList = new ArrayList<>();
        static final String KEY_AUTHOR = "author";
        static final String KEY_TITLE = "title";
        static final String KEY_DESCRIPTION = "description";
        static final String KEY_URL = "url";
        static final String KEY_URLTOIMAGE = "urlToImage";
        static final String KEY_PUBLISHEDAT = "publishedAt";
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            listNews = findViewById(R.id.listNews);
            loader = findViewById(R.id.loader);
            listNews.setEmptyView(loader);
    
    
            if (Function.isNetworkAvailable(getApplicationContext())) {
                DownloadNews newsTask = new DownloadNews();
                newsTask.execute();
            } else {
                Toast.makeText(getApplicationContext(), "No Internet Connection", Toast.LENGTH_LONG).show();
            }
    
        }
    
    
        class DownloadNews extends AsyncTask<String, Void, String> {
            @Override
            protected void onPreExecute() { super.onPreExecute(); }
    
            protected String doInBackground(String... args) {
                String xml = Function.excuteGet("https://newsapi.org/v1/articles?source=" + NEWS_SOURCE + "&sortBy=top&apiKey=" + API_KEY);
                return xml;
            }
    
            @Override
            protected void onPostExecute(String xml) {
    
                if (xml.length() > 10) { // Just checking if not empty
    
                    try {
                        JSONObject jsonResponse = new JSONObject(xml);
                        JSONArray jsonArray = jsonResponse.optJSONArray("articles");
    
                        for (int i = 0; i < jsonArray.length(); i++) {
                            JSONObject jsonObject = jsonArray.getJSONObject(i);
                            HashMap<String, String> map = new HashMap<>();
                            map.put(KEY_AUTHOR, jsonObject.optString(KEY_AUTHOR));
                            map.put(KEY_TITLE, jsonObject.optString(KEY_TITLE));
                            map.put(KEY_DESCRIPTION, jsonObject.optString(KEY_DESCRIPTION));
                            map.put(KEY_URL, jsonObject.optString(KEY_URL));
                            map.put(KEY_URLTOIMAGE, jsonObject.optString(KEY_URLTOIMAGE));
                            map.put(KEY_PUBLISHEDAT, jsonObject.optString(KEY_PUBLISHEDAT));
                            dataList.add(map);
                        }
                    } catch (JSONException e) {
                        Toast.makeText(getApplicationContext(), "Unexpected error", Toast.LENGTH_SHORT).show();
                    }
    
                    ListNewsAdapter adapter = new ListNewsAdapter(MainActivity.this, dataList);
                    listNews.setAdapter(adapter);
    
                    listNews.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                        public void onItemClick(AdapterView<?> parent, View view,
                                                int position, long id) {
                            Intent i = new Intent(MainActivity.this, DetailsActivity.class);
                            i.putExtra("url", dataList.get(+position).get(KEY_URL));
                            startActivity(i);
                        }
                    });
    
                } else {
                    Toast.makeText(getApplicationContext(), "No news found", Toast.LENGTH_SHORT).show();
                }
            }
        }
    
    }

    ListNewsAdapter.java

    package com.dude.newsapp;
    
    import android.app.Activity;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.BaseAdapter;
    import android.widget.ImageView;
    import android.widget.TextView;
    
    //import com.squareup.picasso.Picasso;
    
    import com.squareup.picasso.Picasso;
    
    import java.util.ArrayList;
    import java.util.HashMap;
    
    
    class ListNewsAdapter extends BaseAdapter {
        private Activity activity;
        private ArrayList<HashMap<String, String>> data;
    
        public ListNewsAdapter(Activity a, ArrayList<HashMap<String, String>> d) {
            activity = a;
            data=d;
        }
        public int getCount() {
            return data.size();
        }
        public Object getItem(int position) {
            return position;
        }
        public long getItemId(int position) {
            return position;
        }
        public View getView(int position, View convertView, ViewGroup parent) {
            ListNewsViewHolder holder = null;
            if (convertView == null) {
                holder = new ListNewsViewHolder();
                convertView = LayoutInflater.from(activity).inflate(
                        R.layout.list_row, parent, false);
                holder.galleryImage = (ImageView) convertView.findViewById(R.id.galleryImage);
                holder.author = (TextView) convertView.findViewById(R.id.author);
                holder.title = (TextView) convertView.findViewById(R.id.title);
                holder.sdetails = (TextView) convertView.findViewById(R.id.sdetails);
                holder.time = (TextView) convertView.findViewById(R.id.time);
                convertView.setTag(holder);
            } else {
                holder = (ListNewsViewHolder) convertView.getTag();
            }
            holder.galleryImage.setId(position);
            holder.author.setId(position);
            holder.title.setId(position);
            holder.sdetails.setId(position);
            holder.time.setId(position);
    
            HashMap<String, String> song = new HashMap<String, String>();
            song = data.get(position);
    
            try{
                holder.author.setText(song.get(MainActivity.KEY_AUTHOR));
                holder.title.setText(song.get(MainActivity.KEY_TITLE));
                holder.time.setText(song.get(MainActivity.KEY_PUBLISHEDAT));
                holder.sdetails.setText(song.get(MainActivity.KEY_DESCRIPTION));
    
                if(song.get(MainActivity.KEY_URLTOIMAGE).toString().length() < 5)
                {
                    holder.galleryImage.setVisibility(View.GONE);
                }else{
                    Picasso.get()
                            .load(song.get(MainActivity.KEY_URLTOIMAGE))
                            .resize(300, 200)
                            .centerCrop()
                            .into(holder.galleryImage);
                }
            }catch(Exception e) {}
            return convertView;
        }
    }
    
    class ListNewsViewHolder {
        ImageView galleryImage;
        TextView author, title, sdetails, time;
    }

    NOTE- Remaining all code are given in Source code click and download below

    In this project we need to create more java classes and XML files to create perfect android create news app in android studio. So here finally i give the full source code of this project because not enough space to explain all java classes in this article.

    Make browser app click here.

    ADD Dependency on gradle file

     implementation 'com.squareup.picasso:picasso:2.71828'

    gradle.app

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 29
        buildToolsVersion "29.0.2"
        defaultConfig {
            applicationId "com.dude.newsapp"
            minSdkVersion 19
            targetSdkVersion 29
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'androidx.appcompat:appcompat:1.1.0'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test:runner:1.2.0'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
        implementation 'com.squareup.picasso:picasso:2.71828'
    }
    

    Activity Layouts
    Need to integrate XML files into java clsses to make android news application. Open under the path of res =>layout =>activity_main.xml file and add the following code,

    YouTube Video

    Download Source Code

    Click below to get the source code android news application.

    Download News Apk: CLICK ME

    https://www.mediafire.com/file/ka3m455yi36kwba/news_app.apk/file

    Download News Logo: CLICK ME

    Click below to get the full source code android news application.

    GO TO DOWNLOAD PAGE

    Conclusion

    We have successfully created a News App Android application using Android Studio.


    Cheers!

    READ MORE…


    Share. Facebook Twitter LinkedIn WhatsApp Telegram Pinterest Reddit Email
    Previous ArticleConvert website to android app using android studio
    Next Article Music Player android app in android studio with source code

    Related Posts

    Make app more alive with beautiful animated Flutter icons

    Flutter Animation 3 Mins Read

    An Advanced Flutter app showcasing daily news articles

    News App 3 Mins Read

    Flutter news app that displays news from different sources using News API

    News App 2 Mins Read

    TV news app with Flutter a free and open-source

    News App 3 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • Implementing a Dynamic FAQ Screen UI in Flutter Using ExpansionTile March 29, 2025
    • Creating an Instruction UI Screen in Flutter Application March 29, 2025
    • Animated Backgrounds in Flutter: A Complete Guide March 15, 2025
    • How to make Diary App using flutter stepwise using getx August 31, 2024
    • How to Create Music Player UI screen with fully functional in flutter August 30, 2024
    • How to make ListView Builder Ui in flutter with Source Code August 29, 2024
    • Create a TabBar View in flutter with fully functional stepwise August 28, 2024
    • How to create TabBar view in flutter with source code step wise August 27, 2024
    • How to make Heart rate measure app with Flutter stepwise August 26, 2024
    • How to make ChatGpt App in flutter with source code Stepwise August 25, 2024
    Facebook Twitter Instagram Pinterest YouTube
    • About
    • Contact
    • Disclaimer
    • Privacy Policy
    Copyright by DeepCrazyWorld © 2025

    Type above and press Enter to search. Press Esc to cancel.