Firebase email authentication android

Firebase email authentication android is a process by which we can validate email address of the user. By this we can add a layer of the authentic user. Now a days its is quite useful. Manually if we need to validate the user we need to create a whole system to do so.

Like we need to deploy the database and api and send the email to authenticate user. Instead of doing all this we can just use the firebase email authentication method which saves a lot of time and dependency on the backend technologies.

So lets get started Firebase email authentication android

1- I hope you have already created the account on the firebase console if not you can go thorught this link.

2- Go to firebase console.

3- Go to Authentication and Sign-in Methods Enable email authentication then click save button.

Firebase email authentication

4- To send verification link from the android app create a email password field and submit button added in EmailVerificationActivity.

package com.example.sampleproject;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;

public class EmailVerificationActivity extends AppCompatActivity {

private FirebaseAuth mAuth;
private Helper helper;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_email_verification);
mAuth= FirebaseAuth.getInstance();
helper = new Helper(this);

((Button)findViewById(R.id.bt_submit)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText email = (EditText)findViewById(R.id.et_email);
String email_string = email.getText().toString();
EditText et_password = (EditText)findViewById(R.id.et_password);
String pasword = et_password.getText().toString();
createNewUser(email_string,pasword);

}
});
}
void createNewUser(String email,String password){
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(EmailVerificationActivity.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
// Toast.makeText(SignupMaterial.this, "createUserWithEmail:onComplete:" + task.isSuccessful(), Toast.LENGTH_SHORT).show();
// If sign in fails, helper.display a message to the admin. If sign in succeeds
// the auth state listener will be notified and logic to handle the
// signed in admin can be handled in the listener.

if (!task.isSuccessful()) {
// admin alreeady exists
// VerifyEmail();
helper.display("Email already exists");
helper.hideDialog();
} else {
VerifyEmail();
// startActivity(new Intent(SignupActivity.this, ChangeMailActivity.class));
// finish();
}
}


});
}
private void VerifyEmail() {
final FirebaseUser user = mAuth.getCurrentUser();
if (user != null){
user.sendEmailVerification()
.addOnCompleteListener(EmailVerificationActivity.this, (OnCompleteListener) task -> {
// Re-enable button
if (task.isSuccessful()) {
FirebaseUser firebase_user = mAuth.getCurrentUser();
String firebase_uid=firebase_user.getUid();
helper.display("Email verification send");

} else {
Log.e("", "sendEmailVerification", task.getException());
helper.display("Failed to send verification email.");
}
});
}else {
// Toast.makeText(SignupMaterial.this, "null", Toast.LENGTH_SHORT).show();
}

}
}

on submit button email will be send.

Note: email should be unique.

email from firebase

Tagged : /

Skin Care

Yeah! this lockdown phase is getting on our nerves, but we all are into this together. And it’s very important to look after ourselves in this crucial time. Now as we are inside too much we have excessive time to pamper ourselves. Many of us think, we are inside why we need to take skin care, but our skin need pampering 24*7.

From potato and papaya peels to lemon juice, using home remedies is one of the best and most affordable ways of getting flawless skin. As you can find most of the ingredients in your kitchen, you can prepare do-it-yourself face masks for healthy skin. Save your skin from damage with these skin care home remedies that will be your skin’s knight in shining armour!

Remedies for Dull and Dry Skin

Milk plus honey is magical

Honey and milk can do wonders in bringing out a flawless glow which every woman craves for. Milk helps in preventing acne and moisturizes the skin well. People with sensitive skin can use face washes that contain no chemicals or paraben.

Home-made Coconut moisturiser

This needs just three ingredients – ½ cup coconut oil, few drops of lavender oil and 1-2 vitamin-E capsules. Coconut oil comforts dull skin by replenishing the moisture content and neutralising inflammations while lavender oil and vitamin E promotes skin health for an overall brighter appearance.

Turmeric can do wonders

Turmeric consists of natural anti-oxidant, antiseptic and skin brightening properties. Applying a paste of turmeric will help remove tan and treat blemishes. Lemon is high in Vitamin C and antioxidants, making it another excellent skin brightener. A paste made with curd as base and mixed with turmeric and lemon is excellent for removing tanning. 

Aloe-Vera Gel Mask

Provide your skin with intense nourishment with this 1 ingredient face mask for a total transformation. Dubbed as the ‘plant of immortality’ by the ancient Egyptians, aloe vera has proven to improve dryness. Use a fresh leaf and dig out the clear gel from inside. Rinse out this gel and then apply onto cleansed skin for 5 – 10 minutes.

Skin Care for Acne-prone Skin

Tomato scrub

Grab an old t-shirt and start with a ten-minute steam facial to open up the pores. Dip half a tomato into sugar and use this as a natural scrub. Tomatoes are loaded with antioxidants and vitamin C. This soothes inflammations and rids your skin of dead cells when applied topically.Tomatoes help in shrinking pores. Mix tomato juice with a few drops of lemon and apply on your face. Rinse with lukewarm water. Regular use of this will give you the best results. Tomatoes also help in reducing blackheads. Massage your blackhead prone area with tomato slices to deal with blackheads. 

Yoghurt mask

Create a mixture with 2 tbsp yoghurt, 1/2 tsp turmeric and 1 tsp fullers earth (optional) for a cleansing face mask. Yoghurt has healing properties, and it also moisturises your skin, clears blemishes and fights acne. Turmeric is your skin’s best friend and has been used since ancient times for lustrous and problem-free skin.

Combine honey and cinnamon

People suffering from acne should use a homemade mask made with honey and cinnamon. This mask helps in reducing active acne. Apply fresh Aloe Vera pulp as it is a great moisturiser for acne prone dry skin.

Oily Skin

Banana and honey mask

Mash one small ripe banana and add 1-2 spoons of honey for a deep cleansing and revitalising mask. Banana contains potassium which moisturises and gives you wrinkle-free skin while destroying bacteria. It’s a natural exfoliant that removes sebum and dead skin. Honey soothes the skin, delays ageing and is an excellent skin conditioner.

Cucumber mask

Make this mask with 3 spoons of cucumber juice and 1 spoon of lemon juice. Add fullers’ earth to make a thick paste. Apply evenly over face and neck for a spa treatment in the lap of Mother Nature to treat oily skin. It tightens pores, soothes the skin and is a great toner.

Sensitive Skin

Potato mask

Mash half a small potato and mix it in with 1 spoon of honey and 1 spoon of almond oil. Use this mask once or twice a week to relive your skin of dryness, redness and sensitivity. It will have your skin feeling less irritated and give you crystal clear skin. The Vitamin C and B complex neutralises the skin while removing tan and soothing sunburns.

Raw Milk mask

Raw milk is unpasteurised milk that holds an unbeatable freshness and is a natural cleanser. It will keep your skin sufficiently hydrated while maintaining the firmness and elasticity. Use it as it is or mix it with honey and ground oats for extra exfoliation.

Rose water is the basic

Rose essential oil or rose water is one of the best toners out there, which is suitable for all skin types. Store it in a spray bottle and use it twice a day. It would help to soothe and calm the skin, balance ph levels, and help repair the skin’s elasticity.

So, these are simple tips that can help your skin to rejuvenate and also, protects the skin from becoming dull and pale.

That’s all for skin care. If you know more home remedies do share in your comment.

fight against coronavirus : full coverage http://blogssolutions.co.in/coronavirus-what-is-it-and-how-it-began/

Tagged : / / / / / / /

ART – An Expression of Emotions.

Being an artist is not just about picking up pencil and colors and just draw or paint anything. Art can and does mean so much to so many people in different forms. An artist see the word in a different way through his/her artwork. Moreover art is way to explore life, world and even themselves. It can be exciting, empowering. Art is an expression of emotions.

It is the activity by which a person, having experience an emotion, intentionally transmits it to others” – Leo Tolstoy

Art is be anything and everything you let it !

The power of art –

It is a way of expression, a way of joy, making people understand things which can’t be done verbally. In fact, we can say that everything that is beautiful is art. Art provides mankind with a diverse range of necessities and comforts.However most people don’t realize how much of a role art plays in our lives. Just how much we rely on art in all of its forms in our everyday lives. Art does not show people what to do, yet engaging with a good work. It connects us to the senses of our body and mind.

Most of us get moved by a work of art, whether it is a song, a play, a poem or a painting. We are transport to a whole new place. We become more familiar with the feeling which was unfamiliar to us but which we did not actively focus on before. This transformative experience is what art is constantly seeking. We are surrounded by art in all sense. It just we need to look through a different perspective. Art has always been around in one form or another. It is helping the mankind in the development of diverse activities and their outcomes.

Art is very important in the society because it is an essential ingredient to empowering the hearts of people. When activists are showing images of children suffering from poverty or oppression in their campaigns, this is the art pulling the heartstrings of society’s elite and powerful to make changes.Similarly, when photographers publish the photos of war-torn areas, it catches the attention of masses whose hearts reach out for those who need help.When an artist creates great music and movies, it entertains people around the world. This is art, making a difference in society.A very modern example of art in action is street art. 

Art is also a remarkable mode of depicting culture from all over the world.

Art has the power to take cultural practices from where they are from and then transport and integrate them into different parts of the world without losing their identity. People have now recognize how powerful art can be. It is also consider as a strong therapy.

We use the arts for our entertainment, cultural appreciation, aesthetics, personal improvement, and even social change. We use the arts in order to thrive in this world.

That’s all for art- an expression of emotions.

Do, share your thoughts – What does art mean to you?

clickhttps://www.google.com/url?sa=i&url=https%3A%2F%2Fin.pinterest.com%2Fgarima0305%2F&psig=AOvVaw0y4E5NO5XdWYXLJCv1-MYA&ust=1590230658572000&source=images&cd=vfe&ved=0CA0QjhxqFwoTCIC83Yelx-kCFQAAAAAdAAAAABAD

click http://blogssolutions.co.in/design/

Tagged : / / / /

Trek Freak or a Beach Lover

Wanderlust a strong desire to travel.

One believes the world is a book, and those who do not travel read only one page. People travel because it makes them realize how much they haven’t seen, how much they are not going to see, and how much they still need to see. So we are here to help you out discover yourself as a “Trek Freak or a Beach Lover”.

Some say “they have got a crush on the world”.

Whereas some say “they are born to travel”.

But few can only “fulfill the desire to travel”.

Everyone travels in their life but only few wanders. The desire to travel makes a man happy go lucky in their own way.

It all depends on the person’s taste whether he is a trek freak or a beach lover. What calls him the most – the depths of waters, or the might of mountains? The sound of waves, or the peace and quiet of mountains? A lovely beach vacation or a serene and mountain retreat? 

The options  may differ for every traveler but it is incredible to observe how certain characteristics of a traveler leads them to make a choice between a beach or mountains.

“A beach is not only a sweep of sand, but shells of sea creatures, the sea glass, the seaweed, the incongruous objects washed up by the ocean.”- Henry Grunwald

But

“Somewhere between the bottom of the climb and the summit is the answer to the mystery why we climb.”-Greg Child

Coming from a family who has no culture of travelling at all is tough because you will be having lots of desire to visit various places . At that moment of time one realizes what kinda person he is !

 So helping you out to decide for yourself whether you’re a Trek Freak or a Beach Lover based on these  personality traits.

1.A Chatterbox OR A Listener

Indulging into a conversation with someone is something a beach person is excellent at. Beaches are beautiful spot for sunset and if empty its very soothing. You can talk your heart out and can relax over there. Whereas  a mountain person can be a great listener as for them it is simply about how calming that view can be. That impossible panorama that one gets to see above, feel like they’re above the clouds and they have touched it.

2.An Object-oriented Person OR A Fairy Tale Person

In the world of people high on mountains, some likes to spend fairy tale nights at the beach with their loved ones. This brings them the inner peace and relaxation hearing the sound of the waves which slightly touches their feet is enormous pleasure.

Though the Mountain man is a person with the capability of romancing the nature. The sheer beauty and magnanimity of the mountains is so mesmerizing that one can  watch them without batting an eyelid.

3.Hero personality OR Peace-Lovers

Yes! Mountains being the symbol of beauty and happiness, mountains signifies and teaches us how to deal with the problems of the life. They not only increase your strength but mental power too. The catchy winds of treks, the struggle for basics in life, the chirping of the birds, the steep dives of valleys, the closure with the clouds, the dew like freshness of air that purifies even the impure, everything has a message for you. 

Whereas for a beach lover walking on the soft and wet sand with the cool breeze flowing in my face is as soothing as rain. So they like to glare into the deep blue water that seems to be endless.

4.Believe in carpe deim

So beach lovers mostly believe living to seize the day.And they know how to enjoy the present moment without worrying about the future. They know how to live in the present and they are found to be more joyous. Water babies are music lovers too.

5.An Artist OR A Philosopher

There can never be low key people around you on a beach. From their way of talking, to the way they keep everyone entertained with their sense of humor, is truly toxic. On the other hand, a mountain person can be a great company only if you share similar interests with them. Being a thinker by nature, mountain people give a lot of thought to their words and action. However, whether the person loves beach or mountains, they are great to be with!

If by reading it all , you wish to be everywhere and you wonder who you are, beach or mountain person… then I will tell you, go and explore yourself ! We, travelers, can only plan where we can go first. Think beyond the greed of being everywhere, and you will know where you need to be.

References : https://timesofindia.indiatimes.com/life-style/health-fitness/photo-stories/beach-or-mountain-your-choice-tells-what-you-are-like-deep-inside/photostory/65259761.cms

https://www.learning-mind.com/wp-content/uploads/2016/06/holiday-destination-personality-mountains-or-beach-type.jpg

Tagged : / / / / / / / / /

Firebase JobDispatcher Background Service

We need background service for executing many task. For instance geo location, cloud messaging or to execute heavy task which cannot be done during android lifecycle. Some background service might not run for so long that’s why google created this library for doing long running task which is Firebase jobDispatcher.

What is a Firebase JobDispatcher or job Scheduler?

The JobScheduler is an Android system service available on API levels 21 (Lollipop)+. It provides an API for scheduling units of work (represented by jobservice subclasses) that will execute in your app’s process.

Why is this better than background services and listening for system broadcasts?

Running apps in the background is expensive, which is especially harmful when they’re not actively doing work that’s important to the user. That problem is multiplied when those background services are listening for frequently sent broadcasts (android.net.conn.CONNECTIVITY_CHANGE and android.hardware.action.NEW_PICTURE are common examples). Even worse, there’s no way of specifying prerequisites for these broadcasts. Listening for CONNECTIVITY_CHANGE broadcasts does not guarantee that the device has an active network connection, only that the connection was recently changed.

How to Integrate Firebase JobDispatcher Background Service?

So lets start. The official github repo is here and the implemented code is here

  • implement this code in app.gradle implementation ‘com.firebase:firebase-jobdispatcher:0.8.5’
  • add below code to manifest.
<service
android:name=".FirebaseJobDispatcher.DemoJobService"
android:exported="false">
<intent-filter>
<action android:name="com.firebase.jobdispatcher.ACTION_EXECUTE" />
</intent-filter>
</service>
  • add FirebaseJobDispatcher folder to your project.
  • initialize service on mainactivity to start the job.
void ScheduleJob(){

try {
FirebaseJobDispatcher jobDispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(MainActivity.this));

final Job.Builder builder = jobDispatcher
.newJobBuilder()
.setTag("Repetitive")
.setRecurring(false)
.setLifetime(Lifetime.FOREVER)
.setService(DemoJobService.class)
.setReplaceCurrent(false)
.setRetryStrategy(
jobDispatcher.newRetryStrategy(
RetryStrategy.RETRY_POLICY_EXPONENTIAL,
30,
3600));

builder.setConstraints(Constraint.ON_ANY_NETWORK,Constraint.DEVICE_IDLE);
builder.setTrigger(
Trigger.executionWindow(60, 60 + 50));
jobDispatcher.mustSchedule(builder.build());
}catch (Exception e){
e.printStackTrace();

}
}
  • By calling this you can start the job
  • And in DemoJobService ononStartJob you can define your job
  • I have created a notification service just for example you can create any other service with this.
DemoJobService
Sample notification

Upload image on Firebase storage

Upload image on Firebase storage Uploading an image to any server is quite a hectic task and it also as for so much of memory and processing time on the front end. This can be achieve with new RxJava By using this we can create multiple task with quite a minimum time.

What is Firebase Storage?

Cloud Storage for Firebase lets you upload and share user generated content, such as images and video, which allows you to build rich media content into your apps. Your data is stored in a Google Cloud Storage bucket, an exabyte scale object storage solution with high availability and global redundancy. Cloud Storage lets you securely upload these files directly from mobile devices and web browsers, handling spotty networks with ease.

Why RxJava?

RxJava is a Java VM implementation of Reactive Extensions: a library for composing asynchronous and event-based programs by using observable sequences.

How to upload image on firebase

How to Upload image on Firebase storage

1- First you need to add the android app to Firebase Console if not done yet you can get through this from here.

2- Add firebase storage to your firebase console.

3- In this tutorial we are using dexter for permission and glide.

4- Add Some helper class For camera upload CameraIntent.java and helper.java.

5- Add layout file activity_sign_up.xml.
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/app_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:fitsSystemWindows="true">

        <com.google.android.material.appbar.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="250dp"
            android:fitsSystemWindows="true"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            >

            <androidx.appcompat.widget.AppCompatImageView
                android:layout_width="match_parent"
                android:layout_height="250dp"
                android:id="@+id/iv_profile_pic"
                android:background="@color/white"
                android:fitsSystemWindows="true"
                android:contentDescription="@string/app_name"
                android:src="@mipmap/ic_profile"
                app:layout_collapseMode="parallax"/>

            <androidx.appcompat.widget.Toolbar
                android:id="@+id/Appbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                android:title="recent_news"
                app:layout_collapseMode="pin" />
        </com.google.android.material.appbar.CollapsingToolbarLayout>
    </com.google.android.material.appbar.AppBarLayout>


    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/iv_profile_pic_select"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:clickable="true"
        app:elevation="6dp"
        android:src="@drawable/upload_button"
        app:pressedTranslationZ="12dp"
        app:layout_anchor="@id/app_bar_layout"
        app:layout_anchorGravity="bottom|right|end"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

6- Now signup activity.

Create a function for upload image

private UploadTask saveImage(Bitmap image_bitmap_load, StorageReference storage, String file_name_small,int type) {

    //Play with bitmap
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    image_bitmap_load.compress(Bitmap.CompressFormat.JPEG, 100, baos);
    final byte[] data = baos.toByteArray();
    Date date = new Date();

    final StorageReference ref = storage.child(file_name_small);
    UploadTask  uploadTask = ref.putBytes(data);

    Task<Uri> urlTask = uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
        @Override
        public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
            if (!task.isSuccessful()) {
                Toast.makeText(SignUpActivity.this, "unable to upload", Toast.LENGTH_SHORT).show();

                throw task.getException();
            }


            return ref.getDownloadUrl();
        }
    }).addOnCompleteListener(new OnCompleteListener<Uri>() {
                                 @Override
                                 public void onComplete(@NonNull Task<Uri> task) {
                                     if (task.isSuccessful()) {
                                         Uri downloadUri = task.getResult();

                                     } else {
                                         // Handle failures
                                         Toast.makeText(SignUpActivity.this, "unable to upload", Toast.LENGTH_SHORT).show();

                                     }
                                 }
                             }
    );
    return uploadTask;


}
7- And initialize observable
private final CompositeDisposable disposables = new CompositeDisposable();

Observable<UploadTask> sampleObservable(final UploadTask large_image_task, final UploadTask normal_image_task, final UploadTask small_image_task) {
    StorageReference storage = FirebaseStorage.getInstance().getReference();
    return Observable.defer(new Callable<Observable<UploadTask>>() {
        @Override public Observable<UploadTask> call() throws Exception {
            // Do some long running operation
            //   SystemClock.sleep(5000);

            return Observable.just(large_image_task,normal_image_task,small_image_task);
        }
    });
}

8- Add task to disposables

disposables.add(sampleObservable(large_image_task,normal_image_task,small_image_task)
// Run on a background thread
.subscribeOn(Schedulers.io())
// Be notified on the main thread
.observeOn(AndroidSchedulers.mainThread())

.subscribeWith(new DisposableObserver<Task>() {
@Override public void onComplete() {
Log.d(TAG, "onComplete()");

}

@Override public void onError(Throwable e) {
Log.e(TAG, "onError()", e);
}

@Override public void onNext(Task task) {
Log.d(TAG, "onNext(" + task + ")");
}
}));

It will trigger oncomplete File will be uploaded to the firebase storage. You can comment below for any queries. You can also get the code from here.

That’s all for how to upload image using Rx java.

Tagged : /