Create apk based on mobile device Density or layout CPU type android

Android application you can build APK for specific CPU . You just need to config your app gradle
with some properties and CPU name

you can splits function to achieve your goal . now you just put below function into your app gradle file  like below mention


splits {
  
    abi {
      
          // Enables building multiple APKs per ABI.   
           enable true       
         // By default all ABIs are included, so use reset() and include to specify that we only       
         // want APKs for x86, armeabi-v7a, and mips.
         // Resets the list of ABIs that Gradle should create APKs for to none.        reset()
         // Specifies a list of ABIs that Gradle should create APKs for.     
           include "x86", "armeabi-v7a"     
        // Specifies that we do not want to also generate a universal APK that includes all ABIs.  
           universalApk false   
   }
}


   In this code I config here 2 type CPU "x86" and "armeabi-v7a" and based on 
   this APK will be generate .  


   




Full gradle file details below 

apply plugin: 'com.android.application'
android {
    compileSdkVersion 29   
 buildToolsVersion "29.0.2"  
  defaultConfig {
        applicationId "com.ntss.test"   
     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'     
       }
    }

    splits{

        // Configures multiple APKs based on ABI.        abi {
            // Enables building multiple APKs per ABI.            enable true            // By default all ABIs are included, so use reset() and include to specify that we only            // want APKs for x86, armeabi-v7a, and mips.            // Resets the list of ABIs that Gradle should create APKs for to none.            reset()
            // Specifies a list of ABIs that Gradle should create APKs for.            include "x86", "armeabi-v7a"            // Specifies that we do not want to also generate a universal APK that includes all ABIs.            universalApk false        }
    }

}

dependencies {
   implementation fileTree(dir: 'libs', include: ['*.jar'])
   implementation 'androidx.appcompat:appcompat:1.0.2'  
   implementation 'com.google.android.material:material:1.0.0' 
   implementation 'androidx.constraintlayout:constraintlayout:1.1.3'   
   implementation 'androidx.navigation:navigation-fragment:2.0.0'
   implementation 'androidx.navigation:navigation-ui:2.0.0' 
   implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
   testImplementation 'junit:junit:4.12'  
   androidTestImplementation 'androidx.test.ext:junit:1.1.0'  
   androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}



for more details you can see this like 













Android Auto view pager or Slide image very 3 second android

XML define of View Pager

// create custom view pager and declare into xml as below //


main activity XML



<com.AutoScrollViewPager    android:id="@+id/pagerView"    android:layout_width="match_parent"    android:layout_height="@dimen/dimens150dp"    app:layout_constraintStart_toStartOf="parent"    app:layout_constraintStart_toEndOf="parent"    app:layout_constraintTop_toTopOf="parent"    >



main activity java code


viewPager= findViewById(R.id.pagerView);
viewPager.startAutoScroll();
viewPager.setInterval(3000);
viewPager.setCycle(true);
viewPager.setStopScrollWhenTouch(true);

PagerAdapter adapter = new ViewPagerAdapter(HomeActivity.this,imageId,imagesName);
viewPager.setAdapter(adapter);





Custom pager view class 


import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.animation.Interpolator;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;

import java.lang.ref.WeakReference;
import java.lang.reflect.Field;

public class AutoScrollViewPager extends ViewPager {

    public static final int        DEFAULT_INTERVAL            = 1500;

    public static final int        LEFT                        = 0;
    public static final int        RIGHT                       = 1;

    /** do nothing when sliding at the last or first item **/    public static final int        SLIDE_BORDER_MODE_NONE      = 0;
    /** cycle when sliding at the last or first item **/    public static final int        SLIDE_BORDER_MODE_CYCLE     = 1;
    /** deliver event to parent when sliding at the last or first item **/    public static final int        SLIDE_BORDER_MODE_TO_PARENT = 2;

    /** auto scroll time in milliseconds, default is {@link #DEFAULT_INTERVAL} **/    private long                   interval                    = DEFAULT_INTERVAL;
    /** auto scroll direction, default is {@link #RIGHT} **/    private int                    direction                   = RIGHT;
    /** whether automatic cycle when auto scroll reaching the last or first item, default is true **/    private boolean                isCycle                     = true;
    /** whether stop auto scroll when touching, default is true **/    private boolean                stopScrollWhenTouch         = true;
    /** how to process when sliding at the last or first item, default is {@link #SLIDE_BORDER_MODE_NONE} **/    private int                    slideBorderMode             = SLIDE_BORDER_MODE_NONE;
    /** whether animating when auto scroll at the last or first item **/    private boolean                isBorderAnimation           = true;
    /** scroll factor for auto scroll animation, default is 1.0 **/    private double                 autoScrollFactor            = 1.0;
    /** scroll factor for swipe scroll animation, default is 1.0 **/    private double                 swipeScrollFactor           = 1.0;

    private Handler handler;
    private boolean                isAutoScroll                = false;
    private boolean                isStopByTouch               = false;
    private float                  touchX                      = 0f, downX = 0f;
    private CustomDurationScroller scroller                    = null;

    public static final int        SCROLL_WHAT                 = 0;

    public AutoScrollViewPager(Context paramContext) {
        super(paramContext);
        init();
    }

    public AutoScrollViewPager(Context paramContext, AttributeSet paramAttributeSet) {
        super(paramContext, paramAttributeSet);
        init();
    }

    private void init() {
        handler = new MyHandler(this);
        setViewPagerScroller();
    }

    /**     * start auto scroll, first scroll delay time is {@link #getInterval()}     */    public void startAutoScroll() {
        isAutoScroll = true;
        sendScrollMessage((long)(interval + scroller.getDuration() / autoScrollFactor * swipeScrollFactor));
    }

    /**     * start auto scroll     *     * @param delayTimeInMills first scroll delay time     */    public void startAutoScroll(int delayTimeInMills) {
        isAutoScroll = true;
        sendScrollMessage(delayTimeInMills);
    }

    /**     * stop auto scroll     */    public void stopAutoScroll() {
        isAutoScroll = false;
        handler.removeMessages(SCROLL_WHAT);
    }

    /**     * set the factor by which the duration of sliding animation will change while swiping     */    public void setSwipeScrollDurationFactor(double scrollFactor) {
        swipeScrollFactor = scrollFactor;
    }

    /**     * set the factor by which the duration of sliding animation will change while auto scrolling     */    public void setAutoScrollDurationFactor(double scrollFactor) {
        autoScrollFactor = scrollFactor;
    }

    private void sendScrollMessage(long delayTimeInMills) {
        /** remove messages before, keeps one message is running at most **/        handler.removeMessages(SCROLL_WHAT);
        handler.sendEmptyMessageDelayed(SCROLL_WHAT, delayTimeInMills);
    }

    /**     * set ViewPager scroller to change animation duration when sliding     */    private void setViewPagerScroller() {
        try {
            Field scrollerField = ViewPager.class.getDeclaredField("mScroller");
            scrollerField.setAccessible(true);
            Field interpolatorField = ViewPager.class.getDeclaredField("sInterpolator");
            interpolatorField.setAccessible(true);

            scroller = new CustomDurationScroller(getContext(), (Interpolator)interpolatorField.get(null));
            scrollerField.set(this, scroller);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**     * scroll only once     */    public void scrollOnce() {
        PagerAdapter adapter = getAdapter();
        int currentItem = getCurrentItem();
        int totalCount;
        if (adapter == null || (totalCount = adapter.getCount()) <= 1) {
            return;
        }

        int nextItem = (direction == LEFT) ? --currentItem : ++currentItem;
        if (nextItem < 0) {
            if (isCycle) {
                setCurrentItem(totalCount - 1, isBorderAnimation);
            }
        } else if (nextItem == totalCount) {
            if (isCycle) {
                setCurrentItem(0, isBorderAnimation);
            }
        } else {
            setCurrentItem(nextItem, true);
        }
    }

    /**     * <ul>
     * if stopScrollWhenTouch is true     * <li>if event is down, stop auto scroll.</li>
     * <li>if event is up, start auto scroll again.</li>
     * </ul>
     */    @Override    public boolean dispatchTouchEvent(MotionEvent ev) {
        int action = ev.getActionMasked();

        if (stopScrollWhenTouch) {
            if ((action == MotionEvent.ACTION_DOWN) && isAutoScroll) {
                isStopByTouch = true;
                stopAutoScroll();
            } else if (ev.getAction() == MotionEvent.ACTION_UP && isStopByTouch) {
                startAutoScroll();
            }
        }

        if (slideBorderMode == SLIDE_BORDER_MODE_TO_PARENT || slideBorderMode == SLIDE_BORDER_MODE_CYCLE) {
            touchX = ev.getX();
            if (ev.getAction() == MotionEvent.ACTION_DOWN) {
                downX = touchX;
            }
            int currentItem = getCurrentItem();
            PagerAdapter adapter = getAdapter();
            int pageCount = adapter == null ? 0 : adapter.getCount();
            /**             * current index is first one and slide to right or current index is last one and slide to left.<br/>
             * if slide border mode is to parent, then requestDisallowInterceptTouchEvent false.<br/>
             * else scroll to last one when current item is first one, scroll to first one when current item is last             * one.             */            if ((currentItem == 0 && downX <= touchX) || (currentItem == pageCount - 1 && downX >= touchX)) {
                if (slideBorderMode == SLIDE_BORDER_MODE_TO_PARENT) {
                    getParent().requestDisallowInterceptTouchEvent(false);
                } else {
                    if (pageCount > 1) {
                        setCurrentItem(pageCount - currentItem - 1, isBorderAnimation);
                    }
                    getParent().requestDisallowInterceptTouchEvent(true);
                }
                return super.dispatchTouchEvent(ev);
            }
        }
        getParent().requestDisallowInterceptTouchEvent(true);

        return super.dispatchTouchEvent(ev);
    }

    private static class MyHandler extends Handler {

        private final WeakReference<AutoScrollViewPager> autoScrollViewPager;

        public MyHandler(AutoScrollViewPager autoScrollViewPager) {
            this.autoScrollViewPager = new WeakReference<AutoScrollViewPager>(autoScrollViewPager);
        }

        @Override        public void handleMessage(Message msg) {
            super.handleMessage(msg);

            switch (msg.what) {
                case SCROLL_WHAT:
                    AutoScrollViewPager pager = this.autoScrollViewPager.get();
                    if (pager != null) {
                        pager.scroller.setScrollDurationFactor(pager.autoScrollFactor);
                        pager.scrollOnce();
                        pager.scroller.setScrollDurationFactor(pager.swipeScrollFactor);
                        pager.sendScrollMessage(pager.interval + pager.scroller.getDuration());
                    }
                default:
                    break;
            }
        }
    }

    /**     * get auto scroll time in milliseconds, default is {@link #DEFAULT_INTERVAL}     *     * @return the interval     */    public long getInterval() {
        return interval;
    }

    /**     * set auto scroll time in milliseconds, default is {@link #DEFAULT_INTERVAL}     *     * @param interval the interval to set     */    public void setInterval(long interval) {
        this.interval = interval;
    }

    /**     * get auto scroll direction     *     * @return {@link #LEFT} or {@link #RIGHT}, default is {@link #RIGHT}     */    public int getDirection() {
        return (direction == LEFT) ? LEFT : RIGHT;
    }

    /**     * set auto scroll direction     *     * @param direction {@link #LEFT} or {@link #RIGHT}, default is {@link #RIGHT}     */    public void setDirection(int direction) {
        this.direction = direction;
    }

    /**     * whether automatic cycle when auto scroll reaching the last or first item, default is true     *     * @return the isCycle     */    public boolean isCycle() {
        return isCycle;
    }

    /**     * set whether automatic cycle when auto scroll reaching the last or first item, default is true     *     * @param isCycle the isCycle to set     */    public void setCycle(boolean isCycle) {
        this.isCycle = isCycle;
    }

    /**     * whether stop auto scroll when touching, default is true     *     * @return the stopScrollWhenTouch     */    public boolean isStopScrollWhenTouch() {
        return stopScrollWhenTouch;
    }

    /**     * set whether stop auto scroll when touching, default is true     *     * @param stopScrollWhenTouch     */    public void setStopScrollWhenTouch(boolean stopScrollWhenTouch) {
        this.stopScrollWhenTouch = stopScrollWhenTouch;
    }

    /**     * get how to process when sliding at the last or first item     *     * @return the slideBorderMode {@link #SLIDE_BORDER_MODE_NONE}, {@link #SLIDE_BORDER_MODE_TO_PARENT},     *         {@link #SLIDE_BORDER_MODE_CYCLE}, default is {@link #SLIDE_BORDER_MODE_NONE}     */    public int getSlideBorderMode() {
        return slideBorderMode;
    }

    /**     * set how to process when sliding at the last or first item     *     * @param slideBorderMode {@link #SLIDE_BORDER_MODE_NONE}, {@link #SLIDE_BORDER_MODE_TO_PARENT},     *        {@link #SLIDE_BORDER_MODE_CYCLE}, default is {@link #SLIDE_BORDER_MODE_NONE}     */    public void setSlideBorderMode(int slideBorderMode) {
        this.slideBorderMode = slideBorderMode;
    }

    /**     * whether animating when auto scroll at the last or first item, default is true     *     * @return     */    public boolean isBorderAnimation() {
        return isBorderAnimation;
    }

    /**     * set whether animating when auto scroll at the last or first item, default is true     *     * @param isBorderAnimation     */    public void setBorderAnimation(boolean isBorderAnimation) {
        this.isBorderAnimation = isBorderAnimation;
    }
}



//------------------------------------------------------------------------------------//

 class CustomDurationScroller below details 



import android.content.Context;
import android.view.animation.Interpolator;
import android.widget.Scroller;

public class CustomDurationScroller extends Scroller {

    private double scrollFactor = 1;

    public CustomDurationScroller(Context context) {
        super(context);
    }

    public CustomDurationScroller(Context context, Interpolator interpolator) {
        super(context, interpolator);
    }

    public void setScrollDurationFactor(double scrollFactor) {
        this.scrollFactor = scrollFactor;
    }

    @Override    public void startScroll(int startX, int startY, int dx, int dy, int duration) {
        super.startScroll(startX, startY, dx, dy, (int)(duration * scrollFactor));
    }
}


//----------------------------------------------------------------------------//





Build your first android app using android studio

Build your st 1st android app you need to some environment (IDE) that you can get from https://developer.android.com/ site and download as per you OS (Mac ,Windows ,Linux)
you can download directly from below link also https://developer.android.com/studio after following instaction from official site you need to download android SDK  

Now you can start  your 1st project from here also can follow some guild line from below link 


we   

Google bought Fitbit $2.1 billion

Google, the company that helped make it fun to just sit around surfing the web, is jumping into the fitness-tracker business with both feet, buying Fitbit for about $2.1 billion.

The deal could put Google in direct competition with Apple and Samsung in the highly competitive market for smartwatches and other wearable electronics. But it also raises questions about privacy and Google's dominance in the tech industry.

The company's announcement Friday came with a promise that it won't sell ads using the intimate health data that Fitbit devices collect.

for more details check original new from below link

https://economictimes.indiatimes.com/news/international/business/google-buys-fitbit-for-2-1-billion/into-the-fitness-tracker-business/slideshow/71862709.cms

How can convert JSON from Model class or Pojo Class

You can easily convert JSON String from to Model class or Pojo Class . This very help full when you want to update your JSON date , At first you convert total data to projo class from your JSON string
and then using set or get method to update you model class and then agian convert it to JSON from
Pojo class .


Here a sample code to understand how it work :

Sample JSON Array String :

{
  users: [
    {
      name: "name1",
      email: "abc1@gmail.com",
     
    },
    {
      name: "name2",
     email: "abc2@gmail.com",     
    }
  ]


------------------------------------------------------------------------
Pojo Class :


public class MyModel{
    private List<User> users;
    // +getters/setters
}

public class User {
    private String name;
    private String email;
  
}
Implementation :
Data data = gson.fromJson(json, Data.class);
data.setName("new Name"); 
data.setEmail("new email");
implementation 'com.google.code.gson:gson:2.8.6' add dependency for using gson


Reduce apk size , Delivery apps and features on demand with the Android App Bundle

By publishing your apps using the Android App Bundle, you can reduce the size of your app, simplify releases, and deliver features on demand. Because of its added benefits, the Android App Bundle is the recommended publishing format on Google Play.

How app bundles work

App bundles use a new serving model, known as Google Play’s Dynamic Delivery, to build and deliver APKs that are optimized for each device configuration. By removing unused code and resources for other devices, this delivery model results in a smaller, more efficient app for users to install.
Note: To use app bundles, you must enroll in app signing by Google Play.

Difference between apk (.apk) and app bundle (.aab)

App Bundles are a publishing format, whereas APK (Android application PacKage) is the packaging format which eventually will be installed on device.
App Bundles use bundletool to create a set of APK. (.apks) This can be extracted and the base and configuration splits as well as potential dynamic feature modules can be deployed to a device.
The dependencies can look something like this:


The contents of an App Bundle look kind of like this:




Google play store upload bundle replace of apk

Google play store allow apk size 500 MB from 100 MB previously  , Also Google Play console introduce bundle  concept for uploading  android application

An Android App Bundle is a new upload format that includes all your app’s compiled code and resources, but defers APK generation and signing to Google Play.
Google Play’s new app serving model, called Dynamic Delivery, then uses your app bundle to generate and serve optimized APKs for each user’s device configuration, so they download only the code and resources they need to run your app. You no longer have to build, sign, and manage multiple APKs to support different devices, and users get smaller, more optimized downloads.
Additionally, you can add dynamic feature modules to your app project and include them in your app bundle. These modules contain features and assets that you can decide not to include when users first download and install your app. Using the Play Core Library, your app can later request to download those modules as dynamic feature APKs, and, through Dynamic Delivery, Google Play serves only the code and resources for that module to the device.
To build app bundles and support Dynamic Delivery, follow these steps:
  1. Download Android Studio 3.2 or higher—it's the easiest way to add dynamic feature modules and build app bundles.
  2. Add support for Dynamic Delivery by including a base module, organizing code and resources for configuration APKs, and, optionally, adding dynamic feature modules.
  3. Build an Android App Bundle using Android Studio. If you're not using the IDE, you can instead build an app bundle from the command line.
  4. Test your Android App Bundle by using it to generate APKs that you deploy to a device.
  5. Enroll into app signing by Google Play. Otherwise, you can't upload your app bundle to the Play Console.
For more details you can visit google official blog .
YouTube link :



IRCTC Share Price Declines by 2% Despite 30% Jump in Q4 Net Profit; Board Announces Dividend of INR 2 per Share

Introduction: The share price of Indian Railway Catering and Tourism Corporation (IRCTC) experienced a decline of 2% in today's trading ...