Android Facebook login Using Facebook sdk3.0

First we check Facebook session in open or not Useing this

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mCurrContext = this;
setContentView(R.layout.fb_activity_main);
facebook_button = (Button) findViewById(R.id.LikeFB_Button);

Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);
        fb_session = Session.openActiveSessionFromCache(mCurrContext);

If Your Facebook session in null and not open state click this button to login facebook

          Button button =(Button) findViewById(R.id.button_share);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (fb_session != null && fb_session.isOpened()) {
makeMeRequest(fb_session);
Log.i("Facebook Login State == >", "Facebook Login State");
} else {
if (fb_session == null) {
fb_session = new Session(mCurrContext);          
       }
Session.setActiveSession(fb_session);
ConnectToFacebook();
  Log.i("Facebook not Login State == >", "Facebook Not login State");
}
}
});
   }

This methods used for Login to Facebook Session

  private void ConnectToFacebook(){
Session session = Session.getActiveSession();
        if (!session.isOpened() && !session.isClosed()) {
        Log.i("ConnectToFacebook  if == >", "ConnectToFacebook if");
        OpenRequest newSession = new Session.OpenRequest(this);
        newSession.setCallback(callback);
        session.openForRead(newSession);          
        try {
        Session.OpenRequest request = new Session.OpenRequest(this);
        request.setPermissions(Arrays.asList("email"));
        } catch (Exception e) {
        e.printStackTrace();
        }
        } else {
        Log.i("ConnectToFacebook  else == >", "ConnectToFacebook else");
            Session.openActiveSession(this, true, callback);        
        }
}

private Session.StatusCallback callback = new Session.StatusCallback() {
       public void call(final Session session, final SessionState state, final Exception exception) {
           onSessionStateChange(session, state, exception);
       }
   };
 
   private void onSessionStateChange(final Session session, SessionState state, Exception exception) {
       if (session != null && session.isOpened()) {
        makeMeRequest(session);
       }
   }
 
   private void makeMeRequest(final Session session) {
     Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
    public void onCompleted(GraphUser user, Response response) {
    try{
      //UserInfoDisplay(user);
    //FrieddsInfoDisplay(session);
       } catch (Exception e) {
    e.printStackTrace();
    }
    }
    });              
       request.executeAsync();
   }

NOTE:

InManifestfile you Implement facebook login activity like this

  <activity
            android:name="com.facebook.LoginActivity"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />        

        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/app_id" />

And your App id create create in  res/values/string
  Like this

<resources>   
    <string name="app_id">FACEBOOKAPPLICATIONID</string> 
</resources> 

Android Store data and Image to server?

First Declare file to global like this
private File file;
After that convert to Drawable Image to Bitmap usein this two lines

Drawable myDrawable = getResources().getDrawable(R.drawable.logo);
Bitmap myLogo = ((BitmapDrawable) myDrawable).getBitmap();
After that call your method where we want  "SaveImage_State" and give String name by default

SaveImage_State(myLogo, "name");


private String SaveImage_State(Bitmap finalBitmap, String name) {
String root = Environment.getExternalStorageDirectory().toString() + "/pm";
File myDir = new File(root);
myDir.mkdirs();
Random generator = new Random();
int n = 10000;
n = generator.nextInt(n);
String fname = name + ".jpg";
file = new File(myDir, fname);
if (file.exists())
file.delete();
try {
FileOutputStream out = new FileOutputStream(file);
finalBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
return file.toString();
}


Call this where you want button on click like ......


AsyncTask<Void, Void, HttpEntity> editProfileTask = new AsyncTask<Void, Void, HttpEntity>() {
        
@Override
 protected HttpEntity doInBackground(Void... params) {          
 HttpClient httpclient = new DefaultHttpClient();
 HttpPost httppost = new HttpPost("Your url"); // your url

 try {                     
 MultipartEntity reqEntity = new MultipartEntity();
  reqEntity.addPart("firstname",new StringBody(firstnameEV.getText().toString(),
   "text/plain",Charset.forName("UTF-8")));
                   "text/plain",Charset.forName("UTF-8")));
 if (file != null) {
   reqEntity.addPart("image",new FileBody(((File) file),"application/zip"));
 }         
 httppost.setEntity(reqEntity);
 HttpResponse resp = httpclient.execute(httppost);          
 HttpEntity resEntity = resp.getEntity();
  return resEntity;
 } catch (ClientProtocolException e) {
  e.printStackTrace();
 } catch (IOException e) {
  e.printStackTrace();
 }return null;
 }
   @Override
   protected void onPostExecute(HttpEntity resEntity) {
     if (resEntity != null) {             
       try {
         JSONObject responseJsonObject = new JSONObject(EntityUtils.toString(resEntity));
          String status = responseJsonObject.getString("status");             
           if (status.equals("success")) {
                Toast.makeText(activity, "Your Profile is updated", Toast.LENGTH_LONG).show();
                 String data = responseJsonObject.getString("data");              
                 isUpdatedSuccessfully=true;            
           } else {
              Toast.makeText(activity, "Profile not updated", Toast.LENGTH_LONG).show();
         }
        } catch (Exception e) {
       e.printStackTrace();
      }
        }            
  }
       };
 editProfileTask.execute(null, null, null);
      



Select DateRange UsingRangePicker.

  /* * This Method is for select range from picker. * */ private fun selectDateRangeUsingRangePicker () { pageNumber = 1 val displ...