How to integrate Facebook Api in Android – Mobile App Development, Android App Development, iphone App Development class="post-template-default single single-post postid-3657 single-format-standard wp-custom-logo"

How to integrate Facebook Api in Android

Before you start to generate Facebook App id. Take a look on facebook development.

Facebook allows you to obtain a token to access Facebook’s API on behalf of someone using your app. You can use this feature in place of building your own account system or to add Facebook services to your existing accounts.The Facebook SDK for Android provides methods to implement Facebook Login for your app. And to access this feature into your app you need facebook app id.

Now start to generate facebbok id , you should need a facebook account as a developer or you can use your personal account also.

Step1: Goto facebook developer site and login.

Here is facebook developer link https://developers.facebook.com/apps open this and login to developer account.

How to integrate Facebook Api in Android

Step2: click on “Add a New App” and than select your app platform, here we are using Android so click on “Android”.

How to integrate Facebook Api in Android

Step3: Now click on “Create App Id” enter your app details and finally click on “Create App Id”

How to integrate Facebook Api in Android

Step4: Your Facebook App Id is generated, copy this app id and used for your app development.

How to integrate Facebook Api in Android

Step5: If you need facebook app secret key than click on “show” button and you will get your secret key.

Step6: Goto to https://developers.facebook.com/docs/android and download facebook api.

Step6: After download facebook sdk extract it. You will get facebook api project import it to you workspace.

How to integrate Facebook Api in Android

Step7: Create a project name ImageSharing and add facebooksdk lib into your project from properties. And write this codes.

Write this code in MainActivity.java

[code lang=”js”]
Write this code in MainActivity.java
package com.example.imagesharing;
import java.io.File;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.Signature;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Base64;
import android.util.Log;

import com.facebook.UiLifecycleHelper;
import com.facebook.widget.FacebookDialog;

public class MainActivity extends Activity {
private UiLifecycleHelper uiHelper;
FacebookDialog shareDialog;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
showHashKey(this);
uiHelper = new UiLifecycleHelper(this, null);
uiHelper.onCreate(savedInstanceState);

// to share photo=================

Bitmap bm = BitmapFactory.decodeResource(getResources(),
R.drawable.ic_launcher);
List<Bitmap> image = new ArrayList<Bitmap>();
image.add(bm);
if (FacebookDialog.canPresentShareDialog(getApplicationContext(),
FacebookDialog.ShareDialogFeature.PHOTOS)) {
FacebookDialog shareDialog = new FacebookDialog.PhotoShareDialogBuilder(
this).addPhotos(image).build();
uiHelper.trackPendingDialogCall(shareDialog.present());
} else {
}
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

uiHelper.onActivityResult(requestCode, resultCode, data,
new FacebookDialog.Callback() {
@Override
public void onError(FacebookDialog.PendingCall pendingCall,
Exception error, Bundle data) {
Log.e("Activity",
String.format("Error: %s", error.toString()));
}

@Override
public void onComplete(
FacebookDialog.PendingCall pendingCall, Bundle data) {
Log.i("Activity", "Success!");
}
});
}

@Override
protected void onResume() {
super.onResume();
uiHelper.onResume();
}

@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
uiHelper.onSaveInstanceState(outState);
}

@Override
public void onPause() {
super.onPause();
uiHelper.onPause();
}

@Override
public void onDestroy() {
super.onDestroy();
uiHelper.onDestroy();
}
//this function is to get hash key of your project.
//you can check it in log.
public static void showHashKey(Context context) {
try {
PackageInfo info = context.getPackageManager().getPackageInfo(
"com.example.imagesharing",
PackageManager.GET_SIGNATURES); // Your package name here
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.i("KeyHash:",
Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
}

}
Open string.xml in value folder and write this line
<string name="app_id">1533995260210845</string>
Now finally in your manifest.xml write this codes.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.imagesharing"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.imagesharing.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.LoginActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/app_id" />
<provider android:authorities="com.facebook.app.NativeAppCallContentProvider1533995260210845"
android:name="com.facebook.NativeAppCallContentProvider"
android:exported="true"/>
</application>

</manifest>
[/code]

Run your app now you will get direct facebook page to share image on facebook.com


Warning: _() expects exactly 1 parameter, 2 given in /home2/mobilemeri7/public_html/wp-content/themes/mobilemerit/comments.php on line 28

Write a Reply or Comment

Your email address will not be published.


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Tags:

Cracked Accounts Free Netflix Accounts VPN Proxy Shares Hack Programları Hack dökümanları Hack methodsları Wordlist Combolist Warez Scriptler Download Warez Files WhatsApp Numara çekme +90 Abazalardan Para kazanma Telegram Mavi tik alma 2022 Numara sorgulama Azuere Aws Sanal Kart Method WhatsApp vurma Güncel Method 2022 Bedava .Com .Org .Net VDS Premium Host YouTube Sahte Telif Methodu Tıklama hilesi ile para kazanmak Azure Hack method Pubg Mobile Uc Almak Hedef Kişinin herşeyini öğrenmek instagram Telif taslağı 2022 Ölüm Belgesi ile instagram hesap kaptma instagram form ile ebedi hesap kapatma instagram taklitsiz hesap kapatma instagram Çift faktör geçme instagram tiktok hesap çalma method instagram 2 Faktörlü doğrulama geçme instagram hesap kapatma 2022 instagram rever kırmak instagram Revert Kırma Abaza Dayı Methodu Aylık Dolar kazamak 1500 dolar instagram Çalmak istiyorum instagram düşmeyen takipçi instagram hackleme sitesi Whatsapp Kapatma %100 Abaza tokatlayarak para kazanmak Spotify ile para kazanma Günde 100 tl kazanma sınırsız kazanç Yatakta yatarak para kazanma YouTube izlenme arttırme yöntemi Oturduğun yerde para kazanma yöntemi Discord Hack tool Discord hack programları Cerebrus Rat v2 kodları PP Takipçi Çeken Telif Scripti Facebook profil kapatma methodu 2022 instagram yapay ile banned methodu instagram hesap satşı Sosyal medya hesap satışı Sosyal medya hack Leak Forum Crack Forum Cracking Forum Warez Forum Hack Forum illegal Forum Hacking Forum instagram Forum instagram Forumu Hacklink Hack forum php Shell indir Hack haber
https://www.ankihlasnakliyat.com/jigolosahibinden.comankara nakliyatankara nakliyatistanbul nakliyatankara nakliyatJigolodiyarijigolo sitesigerçek jigolo sitesijigolo sitelerimjigolo şirketlerijigolo sitelerijigolo başvurujigolo arayan kadınlara ulaşKocuceKo cuce