Friday 3 January 2020

Mobile World : The next version of Android is officially Android 11 | About android 11 release in 2020 | Android 11 name | Features coming in Android 11



Android 11:   Next Alphabet R Android 11 soon to Arrive

Google is all set to introduce Android 11 after success of its Android 9 and Android 10 in queue. Much of the information is not disclosed for now but is awaited and speculation is that Android 11 will be more oriented on dual display.

Android launch date is expected around September 2020 but rumours had started already. Android 11 will be available for free.  After Android Q version this Android 11 will be called Android R as expected alphabetically. Also, the trends of naming their android after desserts is also said to be maintained.  Android 10 was in some non-Google company like Oneplus 7T and 7T Pro but possibly it could be different for Android 11. Although it will be available for smart phones who want to be upgrade possibly.

Android 11 in Smart phones

If to put in simple language Android is an open source operating system that powers Google and Smart phones. Also, this operating system is based on a modified version of the Linux Kernel. It’s a decade old and the most popular mobile operating system in world.  Android 11 like other Android software is for smart phones and tablets. Although to compare it with iPhones, Androids varies a lot. But today both are multitasking. Android 11 like other old version will be empowering Samsung series, Xperia, HTC series and many more.  It is at least believes to be on pixel phones.

Android 11 features
Now if talking about Android 11 features, most of it is unknown for now and soon expected to be disclosed but expectation are “Scoped Storage” which is supposed to be in Android 10 but Google pushed it back due to complaints from Android developers. This feature makes memory read speeds much quicker, improves security, and stops you needing to give every new apps permission.  Also all those features which is gone missing or not as expected in Android 10 will be anticipated to be there in Android 11. Just to name few:


1.  Near field Communication (NFC)
NFC determines how your Android phone connects or interacts with the nearest device. This connection does not depend on Wi-Fi, 3G or LTE.  It helped users to share videos, photos, music by not using any apps but by pressing phone against each other.  But this feature is gone now and causes hindrance to share. NFC is expected in Android 11 to get away with this problem of sharing.

2. Improvement in Dark Mode
Using phone in darker made is a treat to eye. It makes different apps look way far better than it is normally.  Android 10 has lots of problem regarding it. Every app does not have to have its darker mode feature, so if smart phone has it already it will reduce much inconvenience of jumping to different apps. Also on apps that do have dark mode some text aren’t colour wrapped and go invisible. Having better dark mode option is what in line of expectation from Android 11.


3. Easy access like “Chat bubbles” 
Chat bubbles over the top of the apps which enables you to see your whole conversations while you are on other apps. Isn’t amazing feature?  Like Facebook messenger, it should be an Android feature as well.  It allows you to use other apps while chatting. User does not have to dodge every time they get a message. It’s of utmost use when we need notification while working on other apps. Especially with Instagram, , Twitter, WhatsApp, Facebook . You can easily continue with your conversation anytime.



Android 11 Updates over different phones
                                So the phone that going to have this Android version is:
       Ø Nokia:  After google, Nokia is the next original equipment
                       Manufacturer (OEM) which is expected to do software
                       upgrade. Their 'Android R' OTA update is to be done 
                       is – Nokia 9 Pure View
                                             Nokia 6.2
                                             Nokia 7.2
        
       Ø Samsung:  Needless to mention that Samsung Galaxy S10 and 
                            Samsung Galaxy Note 10 will going to be upgraded
                            to  Android 11 Features.

       ØXiaomi:   The MIUI 12 will be expected to be based on 
                            Android R version.



Hope you like this article.
Enjoy reading article :)

    



Tuesday 8 October 2019

Android MVP template | Android MVP Plugin

Hello Friends,
              Today I am sharing the android MVP template which make the development
Faster. This is an android studio template inspired by android view-model template.

When we follow Android MVP architecture in any project, for each module or feature
we need to create an Activity/Fragment,  a Presenter and a Contract class and also
a layout file corresponding to them. This is really an time taking process.

So Taking advantage of Android Studio template I created  a MVP template
which creates all this file at the start.

Getting Started

1.  Download the MVPActivity Teamplate ,which you found at the bottom of this blog.
2.  For WINDOWJust copy directory MVPActivity
                     to  $ANDROID_STUDIO_FOLDER$\plugins\android\lib\templates\activities\
3. For  Mac,  Just copy directory MVPActivity
                     to $ANDROID_STUDIO_FOLDER$/Contents/plugins/android/lib/templates/activities/



4. Below are the few common files,
       A. template.xml  – This will contain information about the template
             name, minSdkVersion, etc    


     B. recipe.xml.ftl - This will contain instructions explaining how to
            create the template, including what variables to ask the user for and
            what should be done with those variables.
    C. globals.xml.ftl – This defines global variables

    D. root/ folder – this will contain the template code.





Download code from here
Hope this will helps some one...
Enjoy Coding........... :)

Monday 7 October 2019

Kotlin Android - RecyclerView Example

Hello Friends,
          Today I am sharing the demo of RecyclerView in Kotlin.
A RecyclerView is essentially a ViewGroup of containers called ViewHolders which
populate a particular item.



So lets first familiar with RecyclerView and What RecyclerView requires:
1. It requires a set of data objects to work with
2. An xml file of the individual view item
3. An adapter to bind that data to the views shown in the ViewHolders
4. ViewHolder to populate the UI from the xml item file


Getting Started

Download code from here
Hope this will helps someone.
Enjoy coding.... :)

Saturday 5 October 2019

Kotlin Android – AlertDialog – Example

Hello Friends,
                Here is the demo Alert Dialog in Kotlin. Android AlertDialog class
                is used to display a dialog box to user with positive and negative buttons.
It Appears on top of the activity layout. You may not physically access any other
UI components of activity. It will be run on UI thread.






To Create an AlertDialog, step by step process is :

1. Create an AlertDialog Builder using the activity’s context.
2. Set message content using the builder.
3. Set Positive Button Text and Action to be taken when the button is clicked using the builder.
4. Set Negative Button Text and Action to be taken when the button is clicked using the builder.
5. Create AlertDialog from the builder.
6. You may set the title to the AlertDialog box using setTitle() method.

1. MainActivity.kt
package com.android.developer.soulutions.myapplication

import android.content.DialogInterface
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.support.v7.app.AlertDialog
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        btnShowAlert.setOnClickListener {
            // build alert dialog
            val dialogBuilder = AlertDialog.Builder(this)

            // set message of alert dialog
            dialogBuilder.setMessage("Do you want to close this  ?")
                    // if the dialog is cancelable
                    .setCancelable(false)
                    // positive button text and action
                    .setPositiveButton("OK", DialogInterface.OnClickListener { dialog, id ->
                        finish()
                    })
                    // negative button text and action
                    .setNegativeButton("Cancel", DialogInterface.OnClickListener { dialog, id ->
                        dialog.cancel()
                    })

            // create dialog box
            val alert = dialogBuilder.create()
            // set title for alert dialog box
            alert.setTitle("AlertDialogExample")
            // show alert dialog
            alert.show()
        };
    }
}
 

Download the code from here

Hope this will helps someone.
Enjoy Coding................... :)


Friday 14 December 2018

React Native- Invariant Violation: The navigation prop is missing for this navigator | react-navigation 3- navigation prop is missing for this navigator.

Hello Friend,
       Recently I faced few issue while implementing the react-navigation in my app.
I spent lots of time in it and then finally I found the actual cause of it.

1. undefined is not an object (evaluating 'RNGestureHandlerModule.State')



Then I follow following steps to resolve this,

  1. remove node_modules and package-lock.json
  2. npm install
  3. npm install --save react-navigation
  4. npm install --save react-native-gesture-handler
  5. react-native link
After following this I face another issue i:e,


2. Invariant Violation: The navigation prop is missing for this navigator. In 
react-navigation 3 you must set up your app container directly. More info: 
https://reactnavigation.org/docs/en/app-containers.html
              



Note  This is an react-navigation 3.0 bug. You can go through the below link for more details. 

- React Navigation 3.0 has a number of breaking changes including an explicit app container required for the root navigator.

In the past, any navigator could act as the navigation container at the top-level of your app because they were all wrapped in “navigation containers”. The navigation container, now known as an app container, is a higher-order-component that maintains the navigation state of your app and handles interacting with the outside world to turn linking events into navigation actions and so on.

In v2 and earlier, the containers in React Navigation are automatically provided by the create Navigator functions. As of v3, you are required to use the container directly. In v3 we also renamed createNavigationContainer to createAppContainer.


Below are the complete code,

/**
 * This is an example code for Navigator
 */
import React, { Component } from 'react';
import {createStackNavigator,createAppContainer} from 'react-navigation';
 
import FirstPage from './src/component/FirstPage';
import SecondPage from './src/component/SecondPage';
//import all the screens we are going to switch 
 
const RootStack = createStackNavigator({
    //Constant which holds all the screens like index of any book 
    FirstPage: { screen: FirstPage }, 
    //First entry by default be our first screen if we do not define initialRouteName
    SecondPage: { screen: SecondPage }, 
  },
  {
    initialRouteName: 'FirstPage',
  }
);
const App = createAppContainer(RootStack);


Download complet code from here
Hope this will helps someone........

Enjoy coding..... :)


Wednesday 5 December 2018

Kotlin-Create TextView Programatically

Hello Friends,
      In this tutorial I am going create a textview dynamically in kotlin and add it to Linearlayout layout.

1. activity_main.xml: Following is the activity_main.xml containing the TextView with the text .

<?xml version="1.0" encoding="utf-8"?>  
 <android.support.constraint.ConstraintLayout xmlns:android="https://schemas.android.com/apk/res/android"  
  xmlns:app="http://schemas.android.com/apk/res-auto"  
  xmlns:tools="http://schemas.android.com/tools"  
  android:layout_width="match_parent"  
  android:layout_height="match_parent"  
  tools:context=".TextViewSample">  
  <LinearLayout  
   android:id="@+id/ll_main_layout"  
   android:layout_width="match_parent"  
   android:layout_height="wrap_content"  
   android:orientation="vertical">  
   <TextView  
    android:id="@+id/tv_static"  
    android:layout_width="wrap_content"  
    android:layout_height="wrap_content"  
    android:textSize="20sp"  
    android:padding="20sp"  
    android:justificationMode="inter_word"  
    android:text="This textview is created from xml"/>  
  </LinearLayout>  
 </android.support.constraint.ConstraintLayout>

2. Creation of textview dynamically,
val tv_programtically = TextView(this)
tv_programtically.textSize = 20f
tv_programtically.text = "This textview is an dynamic textview in kotlin"

3. Finally the complete code is:

  TextViewSample.kt
package com.android.developer.kotlinsample

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.widget.LinearLayout
import android.widget.TextView
class TextViewSample : AppCompatActivity() {

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_text_view_sample)

    /** Dynamic creation of text view */
    val tv_programtically = TextView(this)
    tv_programtically.textSize = 20f
    tv_programtically.text = "This textview is an dynamic textview in kotlin"
    /**------end--------**/

    // add TextView to LinearLayout
    val ll_main_layout = findViewById(R.id.ll_main_layout) as LinearLayout
    ll_main_layout.addView(tv_programtically)
  }
}
Hope this will help some one. Enjoy Coding.... :)

Kotlin-bind OnClickListener on view

Hello Friends,
 In this tutorial I am showing you how to bind the click listener on View in Kotlin.

1. Code snippet to set OnClickListener on Textview in Kotlin Android
val tvStatic = findViewById(R.id.tv_static) as TextView
tvStatic.setOnClickListener {
 // your code to perform when the user clicks on the TextView
 Toast.makeText(this, "You clicked on TextView 'Click Me'.", Toast.LENGTH_SHORT).show()
}

2. Code snippet to set OnClickListener on Button in Kotlin Android
// get reference to button
val btn_click = findViewById(R.id.btn_click_me) as Button
// set on-click listener
btn_click.setOnClickListener {
    Toast.makeText(this@MainActivity, "You clicked on Button.", Toast.LENGTH_SHORT).show()
}

3. Code snippet to set OnClickListener on ImageView in Kotlin Android
// get reference to ImageView
val iv_profile = findViewById(R.id.image_view) as ImageView
// set on-click listener for ImageView
iv_profile.setOnClickListener {
    // your code here
}

Hope this will help someone.
Enjoy Coding..... :)

Saturday 23 June 2018

Android Live Data Tutorial | Live Data | Data Binding | Architecture Components

Hello Friends,
              Today I am going to share me small tutorial of LiveData with Data Binding.

-What is LiveData?
     LiveData is an observable data holder class that can be observed within
     a given lifecycle. It lets the components in your app, usually the UI,
     observe LiveData objects for changes.

-The advantages of using LiveData

  •      Ensures your UI matches your data state
  •      No memory leaks
  •      No crashes due to stopped activities
  •      No more manual lifecycle handling
  •      Always up to date data
  •      Proper configuration changes
  •      Sharing resources
-How to use it in our app

   a. Add below dependency in app/build.gradle

implementation "android.arch.lifecycle:extensions:1.1.1" 


   
   b. UserViewModel.java : Creating a ViewModel class

package com.android.developer.livedatademo.model;

import android.arch.lifecycle.MutableLiveData;
import android.arch.lifecycle.ViewModel;

/**
 * Created by mukesh on 13/6/18.
 */
public class UserViewModel extends ViewModel {

    // Create a LiveData with a String
    private MutableLiveData mUser;

    public MutableLiveData getUser() {
        if (mUser == null) {
            mUser = new MutableLiveData();
        }
        return mUser;
    }
} 

In Activity class we creates an observer which updates the ui.
final Observer nameObserver = new Observer() {
      @Override
      public void onChanged(@Nullable final User user) {
      // Update the UI, in this case, a TextView.
      binding.tvUserName.setText(user.getName());
    }
};

Next step is observe the livedata, passing in the activity as a LifecycleOwner and the Observer.
userViewModel.getUser().observe(this, nameObserver);
binding.btnClick.setOnClickListener(this); 

The complete code,

package com.android.developer.livedatademo;

import android.arch.lifecycle.Observer;
import android.arch.lifecycle.ViewModelProviders;
import android.databinding.DataBindingUtil;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.android.developer.livedatademo.databinding.ActivityMainBinding;
import com.android.developer.livedatademo.model.User;
import com.android.developer.livedatademo.model.UserViewModel;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    UserViewModel userViewModel;
    ActivityMainBinding binding;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
        // Get the ViewModel.
        userViewModel = ViewModelProviders.of(this).get(UserViewModel.class);
        // Create the observer which updates the UI.
        final Observer nameObserver = new Observer() {
            @Override
            public void onChanged(@Nullable final User user) {
                // Update the UI, in this case, a TextView.
                binding.tvUserName.setText(user.getName());
            }
        };

        // Observe the LiveData, passing in this activity as the LifecycleOwner and the observer.
        userViewModel.getUser().observe(this, nameObserver);
        binding.btnClick.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        User user = new User();
        user.setName("Mukesh Yadav");
        user.setAge("25");
        userViewModel.getUser().setValue(user);
    }
} 

Download the complete code here

Hope this will helps someone.
Enjoy Coding... :)

Sunday 17 December 2017

Android MVP for Beginners | Android MVP tutorial | Model-View-Presenter: Android | Android Architecture with MVP

Hello Friends,
          Today I am  going to share a very simple example of Android MVP.
In this sample I am using MVP pattern for network call and and user
form(login form) data validation which is mainly used in most of the android
application.

Model View Presenter divides application into three layers i.e: Model, View and Presenter.
  1. Model: This handles the data part of our application
  2. Presenter: It acts as a bridge that connects a Model and a View.
  3. View: This is responsible for laying out views with the relevant data as instructed by the Presenter     

Note: The View never communicates with Model directly

1. LoginActivity.java 
package android.developer.solutions.androidmvp.activity.login.view;

import android.content.Intent;
import android.developer.solutions.androidmvp.R;
import android.developer.solutions.androidmvp.activity.home.view.HomeActivity;
import android.developer.solutions.androidmvp.activity.login.interactor.LoginInteractorImpl;
import android.developer.solutions.androidmvp.activity.login.presenter.ILoginPresenter;
import android.developer.solutions.androidmvp.activity.login.presenter.LoginPresenterImpl;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;

public class LoginActivity extends AppCompatActivity implements ILoginView {
    EditText username;
    EditText password;
    ProgressBar progress;
    Button button;
    private ILoginPresenter presenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        progress = (ProgressBar) findViewById(R.id.progress);
        button = (Button) findViewById(R.id.btnLogin);
        password = (EditText) findViewById(R.id.password);
        username = (EditText) findViewById(R.id.username);
        presenter = new LoginPresenterImpl(this, new LoginInteractorImpl());
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                presenter.validateCredentials(username.getText().toString(), password.getText().toString());
            }
        });
    }

    @Override
    protected void onDestroy() {
        presenter.onDestroy();
        super.onDestroy();
    }

    @Override
    public void showProgress() {
        progress.setVisibility(View.VISIBLE);
    }

    @Override
    public void hideProgress() {
        progress.setVisibility(View.GONE);
    }

    @Override
    public void setUsernameError() {
        username.setError("Invalid user name");
    }

    @Override
    public void setPasswordError() {
        password.setError("Invalid password");
    }

    @Override
    public void navigateToHome() {
        startActivity(new Intent(this, HomeActivity.class));
        finish();
    }
}


2. ILoginView.java

package android.developer.solutions.androidmvp.activity.login.view;

/**
 * Created by Mukesh on 12/16/2017.
 * androiddevelopersolutions.com
 */
public interface ILoginView {
    void showProgress();
    void hideProgress();
    void setUsernameError();
    void setPasswordError();
    void navigateToHome();
}


Download complete code from here

Hope this will helps some one.
Enjoy Coding............ :)

Monday 27 November 2017

Android O: Fonts – Part 1 | Working with custom font Android O | Custom font | Fonts in XML

Hello Friends,
              Android 8.0 (API level 26) introduces a new feature, Fonts in XML, which lets you use fonts as resources. You can add the font file in the res/font/ folder to bundle fonts as resources. These fonts are compiled in your R file and are automatically available in Android Studio. You can access the font resources with the help of a new resource type, font. For example, to access a font resource, use @font/myfont, or R.font.myfont.

To use the Fonts in XML feature on devices running Android API version 14 and higher, use the Support Library 26. For more information on using the support library, refer to the Using the support library section.

Steps

  • To add fonts as resources, perform the following steps in the Android Studio

    • Right-click the res folder and go to New > Android resource directory       
    • The New Resource Directory window appears.


    • In the Resource type list, select font, and then click OK.






      Note: The name of the resource directory must be font.

  • Using fonts in XML layouts 
    • In the layout XML file, set the font Family attribute to the font file you want to access.






    Download Complete code from here.
    Hope this will help some one.
    Enjoy coding..................  ;)   

 

Copyright @ 2013 Android Developers Blog.