Friday, 5 March 2021

What is R.java and Why it is there?


What is R.java?


R.java is just only a java class which generated by the android IDE to keep all unique values for the related project.


Why it is used?


When we make our design screens and used some views for the designing like EditText, TextView, ImageView, Button etc. At that time we put some id for the Views to manage at runtime, now the android IDE generate the unique hexadecimal id for those view's id which are created by us and keep all those unique hexadecimal ids in R.java file to avoid the dulicacy.


Enable Developer options in Redmi phone.


 

Hi Friends,

In this video i am telling you about how to enable the Developer options in Redmi phone.

Login Screen Design with example.


 

Hi Friend, 

In this video i am telling you how to create a simple or basic login screen step by step in android with Hindi Language.

FrameLayout and its use cases with example.


 FrameLayout is designed to block out an area on the screen to display a single item. Generally, FrameLayout should be used to hold a single child view, because it can be difficult to organize child views in a way that's scalable to different screen sizes without the children overlapping each other.

Relative Layout and its use-cases with example.


 RelativeLayout is a view group that displays child views in relative positions. The position of each view can be specified as relative to sibling elements (such as to the left-of or below another view) or in positions relative to the parent RelativeLayout area (such as aligned to the bottom, left or center).

LinearLayout and Its Use cases.

 



LinearLayout is a view group that aligns all children in a single direction, vertically or horizontally. You can specify the layout direction with the android:orientation attribute.

Wednesday, 3 March 2021

Views and View Groups In Android in Hindi | Step By Step

 



Implicit Intent With Example in Hindi | Step By Step

 


  • Implicit intents do not name a specific component, but instead declare a general action to perform, which allows a component from another app to handle it. For example, if you want to show the user a location on a map, you can use an implicit intent to request that another capable app show a specified location on a map.

Explicit Intent | Step By Step In Hindi

 



Android Explicit intent specifies the component to be invoked from activity. In other words, we can call another activity in android by explicit intent.

We can also pass the information from one activity to another using explicit intent.

What Is Intent And Types of Intents| Step By Step in Hindi

 


What Is Intent And Types of Intents| Step By Step in Hindi In this Video i will tell you about Intent, types of Intent and its use cases. Intent is basically is the intention of the user, whatever he want to do in the app but in android Intent is the one of the major component available in the android system. Intent is an object which broadcast the message to android system to handle the specific action via obj passed in intent. The following tasks can be done by using intent component. Launch an activity Share data between the Activities Start the service Open Camera to capture photo Open Gallery to select photo or document Display a web page Dial a phone CALL Broadcast a message Compose an email Compose an SMS Implicit Intent When we/developer does not knows the another component to start with the intent, is called implicit intent. For example when you click on link then your android environment check how many browsing apps available to open this page like Opera, Uc Browser, Chrome etc.

Activity and it's life cycle methods explained Step By Step in Hindi

 



Activity is basically a page or a form. It has its own life. This life of activity has some phases and these phases are called activity life cycle.

An Activity is passes through various stages 1. onCreate() 2. onStart() 3. onResume() 4. onPause() 5. onStop() 6. onRestart() 7. onDesroy() are the stages of android activity's lifecycle. #androidinhindi #androidtutorialsinhindi #androidSikho #learnandroid #firstappinandroid #inhindi #firstprograminandroid #helloinandroid #binnyandroid #androidstepbystep #androidappkaisebanaye #WhatisActivity #activityLifeCycle #activitystages

Explained Android Manifest Part two Step By Step With Practical Project| In Hindi


 

AndroidManifest file is the key summary of the android application. It tells the android environment that which is the launcher screen/ initial startup screen of the app. User permissions: Internet, Network, Wifi, Camera, Location, Internal Storage, External Storage, Contacts, SMS etc. It has Activity Tags, Service Tags, Content Provider, Firebase Meta Data Tags, Play Service Meta Data Tag, Broadcast Receiver Tags etc. Finally we can say that the AndroidManifest is the blueprint of the app, Every app has its own separate AndroidManifest.xml file. #androidinhindi #androidtutorialsinhindi #androidSikho #learnandroid #inhindi #binnyandroid #androidstepbystep #androidappkaisebanaye #androidmanifest #whatisandroidmanifest

Explained Android Manifest Part One Step By Step| In Hindi


 

AndroidManifest file is the key summary of the android application. It tells the android environment that which is the launcher screen/ initial startup screen of the app. User permissions: Internet, Network, Wifi, Camera, Location, Internal Storage, External Storage, Contacts, SMS etc. It has Activity Tags, Service Tags, Content Provider, Firebase Meta Data Tags, Play Service Meta Data Tag, Broadcast Receiver Tags etc. Finally we can say that the AndroidManifest is the blueprint of the app, Every app has its own separate AndroidManifest.xml file. #androidinhindi​ #androidtutorialsinhindi​ #androidSikho​ #learnandroid​ #inhindi​ #binnyandroid​ #androidstepbystep​ #androidappkaisebanaye​ #androidmanifest​ #whatisandroidmanifest

Explained Hello/First Project | Step By Step.

 


In this video i will guide you how to create your own Hello Application or your First Project in android. I will guide you how can you find your application file and send it to your friends. #androidinhindi #androidtutorialsinhindi #androidSikho #learnandroid #firstappinandroid #inhindi #firstprograminandroid #helloinandroid #binnyandroid #androidstepbystep #androidappkaisebanaye

What is minimum SDK or API Level in Android?

 


In this video i will tell you the minimum SDK or Minimum API Level of an application. The minimum SDK or Minimum API Level of an application is the SDK or API Level which is supported by a mobile device. Let suppose if you have an android mobile which have Oreo android version so it means that your mobile phone can support the Oreo targeted application in the best way but it does not means that your device will not support the other android version, it can support lower and higher or Oreo but some feature or functionality may be not working. #androidinhindi #androidtutorialsinhindi #androidSikho #learnandroid #firstappinandroid #inhindi #firstprograminandroid #helloinandroid #binnyandroid #androidstepbystep #androidappkaisebanaye #WhatisIntent #TypesofIntent #Intentfilter #minimumSDk #minimumaiLevel #targetedApiLevel

Thursday, 18 February 2021

Gmail Integration In Android | Step By Step.

 Gmail Integration




1)  https://console.developers.google.com/home/dashboard

2)  Create a project  => select country  => input package name => input sha1 key

3) download json file and paste it in the app folder in project (Android View)

4) paste on project level : classpath 'com.google.gms:google-services:3.0.0'

5) paste on app level on top or bottom: apply plugin: 'com.google.gms.google-services' 

6) paste in app level dependencies: compile 'com.google.android.gms:play-services-auth:9.0.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'


7) logout: private void signOut() {
   Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
           new ResultCallback<Status>() {
               @Override
               public void onResult(Status status) {
                   // ...
                   textViewName.setText("");
                   textViewEmail.setText("");
                   profilePhoto.setImageBitmap(null);
               }
           });
}


Full Source:
 MainActivity.java

package com.codecube.sociallogin;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.NetworkImageView;
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.auth.api.signin.GoogleSignInResult;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;

public class MainActivity extends AppCompatActivity implements View.OnClickListener, GoogleApiClient.OnConnectionFailedListener {


   //Signin button
   private SignInButton signInButton;
   private Button btn_signOut;
   private Button signInButtonFB;
   private Button btn_signOutFB;

   //Signing Options
   private GoogleSignInOptions gso;

   //google api client
   private GoogleApiClient mGoogleApiClient;

   //Signin constant to check the activity result
   private int RC_SIGN_IN = 100;

   //TextViews
   private TextView textViewName;
   private TextView textViewEmail;
   private NetworkImageView profilePhoto;

   //Image Loader
   private ImageLoader imageLoader;


   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main);

       //Initializing Views
       textViewName = (TextView) findViewById(R.id.textViewName);
       textViewEmail = (TextView) findViewById(R.id.textViewEmail);
       profilePhoto = (NetworkImageView) findViewById(R.id.profileImage);

       //Initializing google signin option
       gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
               .requestEmail()
               .build();

       //Initializing signinbutton
       signInButton = (SignInButton) findViewById(R.id.sign_in_button);
       btn_signOut = (Button) findViewById(R.id.btn_signOut);
       signInButtonFB = (Button) findViewById(R.id.sign_in_buttonFB);
       btn_signOutFB = (Button) findViewById(R.id.btn_signOutFB);
       signInButton.setSize(SignInButton.SIZE_WIDE);
       signInButton.setScopes(gso.getScopeArray());

       //Initializing google api client
       mGoogleApiClient = new GoogleApiClient.Builder(this)
               .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
               .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
               .build();


       //Setting onclick listener to signing button
       signInButton.setOnClickListener(this);
       btn_signOut.setOnClickListener(this);
   }


   //This function will option signing intent
   private void signIn() {
       //Creating an intent
       Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);

       //Starting intent for result
       startActivityForResult(signInIntent, RC_SIGN_IN);
   }

   @Override
   public void onActivityResult(int requestCode, int resultCode, Intent data) {
       super.onActivityResult(requestCode, resultCode, data);
       //If signin
       if (requestCode == RC_SIGN_IN) {
           GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
           //Calling a new function to handle signin
           handleSignInResult(result);
       }
   }


   //After the signing we are calling this function
   private void handleSignInResult(GoogleSignInResult result) {
       //If the login succeed
       if (result.isSuccess()) {
           //Getting google account
           GoogleSignInAccount acct = result.getSignInAccount();

           //Displaying name and email
           textViewName.setText(acct.getDisplayName());
           textViewEmail.setText(acct.getEmail());

           //Initializing image loader
           imageLoader = CustomVolleyRequest.getInstance(this.getApplicationContext()).getImageLoader();

           try {
               imageLoader.get(
                       acct.getPhotoUrl().toString(),              /*1st parameter*/
                       ImageLoader.getImageListener(profilePhoto/*2nd parameter - ImageView*/
                               R.mipmap.ic_launcher,               /*3rd parameter - default image*/
                               R.mipmap.ic_launcher)               /*4th parameter - error image*/
               );
           } catch (Exception e) {
               e.printStackTrace();
           }

           //Loading image
           try {
               profilePhoto.setImageUrl(acct.getPhotoUrl().toString(), imageLoader);
           } catch (Exception e) {
               e.printStackTrace();
           }

       } else {
           //If login fails
           Toast.makeText(this, "Login Failed", Toast.LENGTH_LONG).show();
       }
   }

   @Override
   public void onClick(View v) {
       if (v == signInButton) {
           //Calling signin
           signIn();
       }

       if (v == btn_signOut) {
           signOut();
       }
   }

   private void signOut() {
       Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
               new ResultCallback<Status>() {
                   @Override
                   public void onResult(Status status) {
                       // ...
                       textViewName.setText("");
                       textViewEmail.setText("");
                       profilePhoto.setImageBitmap(null);
                   }
               });
   }

   @Override
   public void onConnectionFailed(ConnectionResult connectionResult) {

   }
}


------------------------------------------------
CustomVolleyRequest.java

package com.codecube.sociallogin;

import android.content.Context;
import android.graphics.Bitmap;
import android.support.v4.util.LruCache;

import com.android.volley.Cache;
import com.android.volley.Network;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.BasicNetwork;
import com.android.volley.toolbox.DiskBasedCache;
import com.android.volley.toolbox.HurlStack;
import com.android.volley.toolbox.ImageLoader;

/**
* Created by Vinod on 22-04-2017.
*/
public class CustomVolleyRequest {

   private static CustomVolleyRequest customVolleyRequest;
   private static Context context;
   private RequestQueue requestQueue;
   private ImageLoader imageLoader;


   private CustomVolleyRequest(Context context) {
       this.context = context;
       this.requestQueue = getRequestQueue();

       imageLoader = new ImageLoader(requestQueue,
               new ImageLoader.ImageCache() {
                   private final LruCache<String, Bitmap>
                           cache = new LruCache<String, Bitmap>(20);

                   @Override
                   public Bitmap getBitmap(String url) {
                       return cache.get(url);
                   }

                   @Override
                   public void putBitmap(String url, Bitmap bitmap) {
                       cache.put(url, bitmap);
                   }
               });
   }

   public static synchronized CustomVolleyRequest getInstance(Context context) {
       if (customVolleyRequest == null) {
           customVolleyRequest = new CustomVolleyRequest(context);
       }
       return customVolleyRequest;
   }

   public RequestQueue getRequestQueue() {
       if (requestQueue == null) {
           Cache cache = new DiskBasedCache(context.getCacheDir(), 10 * 1024 * 1024);
           Network network = new BasicNetwork(new HurlStack());
           requestQueue = new RequestQueue(cache, network);
           requestQueue.start();
       }
       return requestQueue;
   }

   public ImageLoader getImageLoader() {
       return imageLoader;
   }

}