Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I having some issue in creating a dialog of type group in quickblox chat service on android. I am able to get all the user from the server side of quickblox, able to build dialog and adding those users i got in it but when it comes to call groupChatManager.createDialog(dialog, new QBEntityCallbackImpl(). I am getting a null pointer exception on that. I found later that i have to initialise chatService in class that extends application i did that but still same error. here is my code
enter code here
My applicationSingeltonClass
public class ApplicationSingleton extends Application
{
private QBUser currentUser;
//quickBlox
private static final String APP_ID = "key";
private static final String AUTH_KEY = "authkey";
private static final String AUTH_SECRET = "authsec";
private static ApplicationSingleton instance;
private Map<Integer, QBUser> dialogsUsers = new HashMap<Integer, QBUser>();
private QBRoomChat currentRoom;
#Override
public void onCreate()
{
super.onCreate();
initApplication();
initImageLoader(getApplicationContext());
}
public static ApplicationSingleton getInstance()
{
return instance;
}
private void initImageLoader(Context context)
{
// This configuration tuning is custom. You can tune every option, you may tune some of them,
// or you can create default configuration by
// ImageLoaderConfiguration.createDefault(this);
// method.
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
.threadPriority(Thread.NORM_PRIORITY - 2)
.denyCacheImageMultipleSizesInMemory()
.discCacheFileNameGenerator(new Md5FileNameGenerator())
.tasksProcessingOrder(QueueProcessingType.LIFO)
.enableLogging() // Not necessary in common
.build();
// Initialize ImageLoader with configuration.
ImageLoader.getInstance().init(config);
}
public QBUser getCurrentUser()
{
return currentUser;
}
public void setCurrentUser(QBUser currentUser)
{
this.currentUser = currentUser;
}
public Map<Integer, QBUser> getDialogsUsers()
{
return dialogsUsers;
}
public void setDialogsUsers(List<QBUser> setUsers)
{
dialogsUsers.clear();
for (QBUser user : setUsers)
{
dialogsUsers.put(user.getId(), user);
}
}
public void addDialogsUsers(List<QBUser> newUsers)
{
for (QBUser user : newUsers)
{
dialogsUsers.put(user.getId(), user);
}
}
public Integer getOpponentIDForPrivateDialog(QBDialog dialog)
{
Integer opponentID = -1;
for(Integer userID : dialog.getOccupants())
{
if(userID != getCurrentUser().getId())
{
opponentID = userID;
break;
}
}
return opponentID;
}
private void initApplication()
{
instance = this;
QBChatService.setDebugEnabled(true);
QBSettings.getInstance().fastConfigInit(APP_ID, AUTH_KEY,AUTH_SECRET);
}
}
here is my other class were i create a dialog
enter code here
protected void onPostExecute(final Boolean success)
{
if(status.equals("accepted"))
{
pagedRequestBuilder.setPage(1);
pagedRequestBuilder.setPerPage(10);
final ArrayList<String> usersLogins = new ArrayList<String>();
usersLogins.add(userID);
usersLogins.add(herocivID);
final ArrayList<Integer> occupantIdsList = new ArrayList<Integer>();
occupantIdsList.add(civID);
occupantIdsList.add(heroCivID);
QBUsers.getUsersByFacebookId(usersLogins, pagedRequestBuilder, new QBEntityCallbackImpl<ArrayList<QBUser>>() {
#Override
public void onSuccess(ArrayList<QBUser> users, Bundle params)
{
if (!QBChatService.isInitialized())
{
QBChatService.init(getApplicationContext());
chatService = QBChatService.getInstance();
chatService.addConnectionListener(chatConnectionListener);
}
QBDialog dialog = new QBDialog();
dialog.setName("chat with mostafa wo may");
dialog.setType(QBDialogType.GROUP);
dialog.setOccupantsIds(occupantIdsList);
QBGroupChatManager groupChatManager = chatService.getInstance().getGroupChatManager();
groupChatManager.createDialog(dialog, new QBEntityCallbackImpl<QBDialog>()
{
#Override
public void onSuccess(QBDialog dialog, Bundle args)
{
Log.i("", "dialog: " + dialog);
}
#Override
public void onError(List<String> errors) {
Toast.makeText(getBaseContext(), "Something went wrong", Toast.LENGTH_SHORT).show();
}
});
}
#Override
public void onError(List<String> errors)
{
Toast.makeText(getBaseContext(), "Something went wrong", Toast.LENGTH_SHORT).show();
}
});
Toast.makeText(getBaseContext(), "you accepted the request", Toast.LENGTH_SHORT).show();
}
else if(status.equals("rejected"))
{
Toast.makeText(getBaseContext(), "you rejected the request", Toast.LENGTH_SHORT).show();
}
}
i need to know were exactly i have to configure the chat service to prevent the null pointer while creating a dialog.
Any help would be appreciated thank you.
You're right,
chatService.getInstance().getGroupChatManager();
is null if you're not logged in ti Chat
so you have to login to chat first and then call this method
I managed to solve this issue.
First you need to check roomChatManager if its equal to null you have to ask the user to login in.
Second in the login wether your using social provider or by mail you have to login to chatService ( ApplicationSingleton.getInstance().chatService.login(userResult);)
ApplicationSingleton is a java class were it extends Application in it you initialise the ChatService.
Thats it now you can create your dialog successfully.
Related
Force update code is not implemented in the previous version So I add Force update code in the new version(Version Code 6) and uploaded testing version on play store.
Now For testing, I create new release build of version code 5 and install it in my device.
On Login Popup to update and cancel is showing but on clicking on the update button it is navigating to play store where there is an open button instead of an update although higher version is available.
I search and try different methods mentioned on StackOverflow but none of them is working for me.
Please help me out to fix this issue.
public class AppointActivity extends AppCompatActivity implements ForceUpdateChecker.OnUpdateNeededListener{
}
private void redirectStore(String updateUrl) {
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(updateUrl));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
#Override
public void onUpdateNeeded( final String updateUrl) {
AlertDialog dialog = new AlertDialog.Builder(this)//Alert dialog have implemetation have two options
.setTitle("New version available")
.setMessage("Please, update app to new version to continue searching.")
.setPositiveButton("Update Now",
new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
redirectStore(updateUrl);
}
}).setNegativeButton("Later",
new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).create();
dialog.setCancelable(true);
dialog.show();
}
public class ForceUpdateChecker {
private static final String TAG = ForceUpdateChecker.class.getSimpleName();
public static final String KEY_UPDATE_REQUIRED = "force_update_required";
public static final String KEY_CURRENT_VERSION = "force_update_current_version";
public static final String KEY_UPDATE_URL = "force_update_store_url";
private OnUpdateNeededListener onUpdateNeededListener;
private Context context;
public interface OnUpdateNeededListener {
void onUpdateNeeded(String updateUrl);
}
public static Builder with(#NonNull Context context) {
return new Builder(context);
}
public ForceUpdateChecker(#NonNull Context context,
OnUpdateNeededListener onUpdateNeededListener) {
this.context = context;
this.onUpdateNeededListener = onUpdateNeededListener;
}
public void check() {
final FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.getInstance();
if (remoteConfig.getBoolean(KEY_UPDATE_REQUIRED)) {
String currentVersion = remoteConfig.getString(KEY_CURRENT_VERSION);
String appVersion = getAppVersion(context);
String updateUrl = remoteConfig.getString(KEY_UPDATE_URL);
if (!TextUtils.equals(currentVersion, appVersion)
&& onUpdateNeededListener != null) {
onUpdateNeededListener.onUpdateNeeded(updateUrl);
}
}
}
private String getAppVersion(Context context) {
String result = "";
try {
result = context.getPackageManager()
.getPackageInfo(context.getPackageName(), 0)
.versionName;
result = result.replaceAll("[a-zA-Z]|-", "");
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, e.getMessage());
errorClass.logError(e);
}
return result;
}
public static class Builder {
private Context context;
private OnUpdateNeededListener onUpdateNeededListener;
public Builder(Context context) {
this.context = context;
}
public Builder onUpdateNeeded(OnUpdateNeededListener onUpdateNeededListener) {
this.onUpdateNeededListener = onUpdateNeededListener;
return this;
}
public ForceUpdateChecker build() {
return new ForceUpdateChecker(context, onUpdateNeededListener);
}
public ForceUpdateChecker check() {
ForceUpdateChecker forceUpdateChecker = build();
forceUpdateChecker.check();
return forceUpdateChecker;
}
}
}
Thank you
If you have installed your application through adb or installed from other sources, Google play will show "Open" instead of "Update".
If your app have been installed through Google Play or it should be installed through a system application to show an update in Google Play,
This is issue of play store.I have also face same issue.If you go back and again go to same app it will be show update button instead of open.
Off-topic : Why you are not use InAppUpdate instead of your code?
For InAppUpdate please prefer below link of my answer
https://stackoverflow.com/a/59930031/11158194
I hope this can help you!
Thank You.
Check your version name and version code in build.gradle file of app level
You can check this link "https://github.com/hummatli/AndroidAppUpdater"
I tried implementing a signIn method from the OneDrive API, but I am not sure I correctly understood the workflow.
Basically, on first launch of the app, I want to have both the login window and the "authorise the app to..." window". But then, when the user launches the app again, I would like to be directly connected to the app, without any window.
Instead, with the following code, I keep having the second window (where the user decides to accept the app)
#Override
public void signIn() {
//personal code
linkingStarted = true;
signInStatus = SignInStatus.SIGNING_IN;
activity.setUpWait(R.layout.popup_waitgif_white);
//end of personal code
mAuthClient = AuthClientFactory.getAuthClient(activity.getApplication());
if (mAuthClient.getSession().isExpired() && Util.isConnectedToInternet(activity)) {
activity.alertOnUIThread("Login again");
activity.runOnUiThread(new Runnable() {
#Override
public void run() {
mAuthClient.login(activity, SCOPES, mAuthListener);
}
});
} else if (!Util.isConnectedToInternet(activity)) {
activity.alertOnUIThread(activity.getString(R.string.alert_verifyconnection));
} else {
activity.alertOnUIThread("Resigned In OneDrive");
signInStatus = SignInStatus.SIGNED_IN;
mAuthClient.initialize(SCOPES, new AuthListener() {
#Override
public void onAuthComplete(final AuthStatus status, final AuthSession session, final Object userState) {
if (status == AuthStatus.CONNECTED) {
authToken = session.getAccessToken();
oneDriveService = getOneDriveService();
signInStatus = SignInStatus.SIGNED_IN;
} else {
authenticationFailure();
Log.v(TAG, "Problem connecting");
}
}
#Override
public void onAuthError(final AuthException exception, final Object userState) {
//mAuthClient.login(activity, SCOPES, mAuthListener);
}
}, null, authToken);
}
}
and the AuthClientFactory is just this:
public class AuthClientFactory {
private static AuthClient authClient;
private static final String CLIENT_ID = "00000000XXXXX";
public static AuthClient getAuthClient(Context context) {
if (authClient == null)
authClient = new AuthClient(context, OneDriveOAuthConfig.getInstance(), CLIENT_ID);
return authClient;
}
}
You would have an easier time with the OneDrive SDK for Android, as authentication is a much simpler process.
final MSAAuthenticator msaAuthenticator = new MSAAuthenticator() {
#Override
public String getClientId() {
return "<msa-client-id>";
}
#Override
public String[] getScopes() {
return new String[] { "onedrive.appfolder", "wl.offline_access"};
}
}
final IClientConfig oneDriveConfig = new DefaultClientConfig.createWithAuthenticator(msaAuthenticator);
final IOneDriveClient oneDriveClient = new OneDriveClient
.Builder()
.fromConfig(oneDriveConfig)
.loginAndBuildClient(getActivity());
That will take care of the user authentication flow and then give you a service object that makes interacting with OneDrive straight-forward. See the full example application.
When I use HTC Android, it do very well. However, when I use API of Facebook to login using Samsung Android 4.2, I show an Toast message like "login fail please contact the marker of this app and ask them to issue 1732910 to facebook"
Please help me to fix it!
public class FacebookLogin {
/* variable Facebook */
private static final String FACEBOOK_APPID = "578073962236765";
private FacebookConnector facebookConnector;
private final Handler mFacebookHandler = new Handler();
ActivityBase activity;
Request.GraphUserCallback userCallback;
LoginService.OnSwimLogedInEvents swimLoginCallBack;
LoginService loginService;
Dialog changeDialog;
LoadingDialog loadingDialog;
public FacebookLogin(ActivityBase activity, Request.GraphUserCallback userCallback, LoginService.OnSwimLogedInEvents swimLoginCallBack) {
this.activity = activity;
this.loadingDialog = new LoadingDialog();
this.userCallback = userCallback;
this.swimLoginCallBack = swimLoginCallBack;
this.loginService = new LoginService(activity);
this.facebookConnector = new FacebookConnector(FACEBOOK_APPID,
activity, activity, new String[]{
"publish_stream", "email", "user_birthday", "read_stream", "offline_access"});
}
public void login() {
Session.initializeStaticContext(activity);
if (facebookConnector.getFacebook().isSessionValid()) {
facebookConnector.getFacebook().getSession()
.closeAndClearTokenInformation();
}
AuthListener listener = new AuthListener() {
#Override
public void onAuthSucceed() {
doLogin();
}
#Override
public void onAuthFail(String error) {
//(new MessageAlert()).showDialog("Facebook authetication fail\r\nError:" + error, activity);
}
};
SessionEvents.addAuthListener(listener);
facebookConnector.login();
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
facebookConnector.getFacebook().authorizeCallback(requestCode, resultCode, data);
}
private void doLogin() {
AsyncTaskBase<Void, Void, Void> t = new AsyncTaskBase<Void, Void, Void>(
activity) {
#Override
protected Void doInBackground(Void... params) {
mFacebookHandler.post(facebookUserInfoRunner);
return super.doInBackground(params);
}
#Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
}
};
t.execute();
}
final Runnable facebookUserInfoRunner = new Runnable() {
#Override
public void run() {
loadingDialog.showDialogLoading(activity);
Request.executeMeRequestAsync(facebookConnector.getFacebook()
.getSession(), new Request.GraphUserCallback() {
#Override
public void onCompleted(GraphUser user, Response response) {
SwimAccount currentAccount = ((SwimApp) activity.getApplication()).getCurrentAccount();
currentAccount.setAvatarUrl("https://graph.facebook.com/" + user.getId() + "/picture");
currentAccount.setIsLogin(true);
currentAccount.setFirstName(user.getFirstName());
currentAccount.setLastName(user.getLastName());
currentAccount.setStringId(user.getId());
currentAccount.setAccountType("facebook");
currentAccount.setEmail((String) response.getGraphObject().getProperty("email"));
currentAccount.setBirthdate(user.getBirthday());
currentAccount.setGender((String) response.getGraphObject().getProperty("gender"));
if (userCallback != null) {
userCallback.onCompleted(user, response);
}
loginService.login(currentAccount.getEmail(), "", currentAccount.getAccountType(), currentAccount.getStringId(), swimLoginCallBack);
//changeDialog.dismiss();
}
});
}
};
}
Found a solution to my problem. Try deleting the android:noHistory="true" from the Facebook login activity in your manifest. This messes with the authentication flow of the Session.
It looks like people on XDA have had this same problem.
They are claiming that you can try either of these:
(1) "Don't keep activities" option on Settings > Developer Options. If it's ON, then when an app calls some popup, system closes app, so then system restarts it ... and there got your loop.
(2) If you uninstall the Facebook App, you can then login through your app, and then re-install the Facebook app.
Not sure how "official" these answers are, but thought it might be worth a shot to you.
Sources:
http://forum.xda-developers.com/showthread.php?p=43200939 and http://forum.xda-developers.com/showthread.php?t=2186035
I have developed an android app. In this app I have integrated tapjoy and everbadge offerwalls. In tapjoy offerwall, I am calling following method to show offerwall.
TapjoyConnect.getTapjoyConnectInstance().showOffers();
but when I complete an offer I am not able to see tap points in toast. following is the code I have written for tapjoy offerwall.
public class TapjoyOfferwall implements TapjoyEarnedPointsNotifier, TapjoyNotifier{
private Activity context;
//private AppPreferences appPreferences;
private String AppId_TapJoy = "bba49f11-b87f-4c0f-9632-21aa810dd6f1";
private String SecretKey_TapJoy = "yiQIURFEeKm0zbOggubu";
private String displayText = "";
boolean update_text = false;
boolean earnedPoints = false;
int point_total;
String currency_name;
public TapjoyOfferwall(Activity context) {
super();
this.context = context;
//appPreferences = new AppPreferences(context);
// Enables logging to the console.
TapjoyLog.enableLogging(true);
// OPTIONAL: For custom startup flags.
Hashtable<String, String> flags = new Hashtable<String, String>();
flags.put(TapjoyConnectFlag.ENABLE_LOGGING, "true");
// Connect with the Tapjoy server. Call this when the application first starts.
// REPLACE THE APP ID WITH YOUR TAPJOY APP ID.
// REPLACE THE SECRET KEY WITH YOUR SECRET KEY.
TapjoyConnect.requestTapjoyConnect(context,AppId_TapJoy, SecretKey_TapJoy,flags);
//TapjoyConnect.getTapjoyConnectInstance().setUserID(""+appPreferences.GetUserID());
// Set our earned points notifier to this class.
TapjoyConnect.getTapjoyConnectInstance().setEarnedPointsNotifier(this);
//LaunchTapJoyOfferwall();
}
#Override
public void earnedTapPoints(int amount)
{
earnedPoints = true;
update_text = true;
displayText = "You've just earned " + amount + " Tap Points!";
// We must use a handler since we cannot update UI elements from a different thread.
System.out.println("displayText :: "+displayText);
OEPUtil.showAppToast(context, displayText);
}
public void LaunchTapJoyOfferwall() {
TapjoyConnect.getTapjoyConnectInstance().showOffers();
}
#SuppressWarnings("deprecation")
public void SetBannerAutoRefresh() {
TapjoyConnect.getTapjoyConnectInstance().enableBannerAdAutoRefresh(false);
}
public void SetShutDown() {
TapjoyConnect.getTapjoyConnectInstance().sendShutDownEvent();
}
}
this class I am accessing in one of my activity class on click of a button.
Please let me know whatever I am doing is correct or not and how can I get points??
This might help you..
http://www.jjask.com/32814/android-tapjoy-offerwall-never-makes-callback
basically
#Override
protected void onResume()
{
TapjoyConnect.getTapjoyConnectInstance().getTapPoints(this);
super.onResume();
}
Currently I'm writing an adapter class to provide a convenient way for communication with the facebook API.
The way I thought about using it is to run the authentication when the app is starting up, downloading user's private picture, and later in the app publishing updates on users facebook wall using an AsyncFacebookRunner.
However flipping through the documentation it seems for every authorize() implementation the first parameter have to be an activity.
void authorize(Activity activity, final DialogListener listener):
And here I begin to wonder.
Thinking about activities and life cycles what will happen when the activity I threw in will be destroyed? Wouldn't the reference for this object Facebook.mAuthActivity become invalid as well.
I see the logout() method "only" asks for a context.
String logout(Context context) throws ...:
context - The Android context in which the logout should be called: it should be the same context in which the login occurred in order to clear any stored cookies
From what I see I can not guarantee the "login-activity" will still be present as app's uptime increases - actually the opposite is more likely.
Are there any special situations I should consider to prevent the app form total crashing in a later state?
You can try use my FBHelper class.
public class FBHelper {
private SharedPreferences mPrefs;
private Context context;
private final String ACCES_TOKEN = "access_token";
private final String ACCES_EXPIRES = "access_expires";
private Facebook facebook;
private FBHelperCallbacks callback;
public FBHelper(Context context, Facebook facebook)
{
this.context = context;
this.facebook = facebook;
}
public void setSignInFinishListener(FBHelperCallbacks callback)
{
this.callback = callback;
}
public void FacebookSingleSignIn() {
mPrefs = ((Activity)context).getPreferences(Context.MODE_PRIVATE);
String access_token = mPrefs.getString(ACCES_TOKEN, null);
long expires = mPrefs.getLong(ACCES_EXPIRES, 0);
if(access_token != null) {
facebook.setAccessToken(access_token);
}
if(expires != 0) {
facebook.setAccessExpires(expires);
}
/*
* Only call authorize if the access_token has expired.
*/
if(!facebook.isSessionValid()) {
Log.i("Facebook","Facebook session is not valid based on acces token... authorizing again");
facebook.authorize((Activity)context, new String[] {"user_about_me"},new DialogListener() {
#Override
public void onFacebookError(FacebookError e) {
e.printStackTrace();
callback.onError(e.toString());
}
#Override
public void onError(DialogError e) {
Log.i("Facebook","onError inner");
callback.onError(e.toString());
}
#Override
public void onComplete(Bundle values) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString(ACCES_TOKEN, facebook.getAccessToken());
Log.i("Facebook","Saving acces token:"+facebook.getAccessToken());
editor.putLong(ACCES_EXPIRES, facebook.getAccessExpires());
editor.commit();
callback.onSignedInFinished(facebook.getAccessToken());
}
#Override
public void onCancel() {
callback.onError("onCancel");
}
});
}
else
{
Log.i("Facebook","Accces token read form preferencesno no need to authorize");
callback.onSignedInFinished(facebook.getAccessToken());
}
}
public String LogOut()
{
try {
//set ACCES_TOKEN to null
mPrefs = ((Activity)context).getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString(ACCES_TOKEN, null);
editor.putLong(ACCES_EXPIRES, 0);
editor.commit();
return facebook.logout(context);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "Error";
}
public static abstract class FBHelperCallbacks{
public abstract void onSignedInFinished(String accesToken);
public abstract void onError(String message);
}
}
This is how you use this class.
public class LogInActivity extends Activity {
private static final String TAG = "LogInActivity";
public static final int REQUEST_CODE = 1;
private Context context;
private Facebook facebook;
private FBHelper fbhelper;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_log_in);
this.context = this;
Handler pauser = new Handler();
pauser.postDelayed (new Runnable() {
public void run() {
facebook = new Facebook(context.getString(R.string.FACEBOOK_APP_ID));
fbhelper = new FBHelper(context, facebook);
if (aHelper.isLogedIn())
{
//log out
fbhelper.LogOut();
}
else
{
//facebook login
fbhelper.setSignInFinishListener(fbcallback);
fbhelper.FacebookSingleSignIn();
}
}
}, 100);
}
FBHelperCallbacks fbcallback = new FBHelperCallbacks() {
#Override
public void onSignedInFinished(String accesToken) {
Log.d(TAG,"log in finish");
}
#Override
public void onError(String message) {
setResult(RESULT_CANCELED);
finish();
}
};
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
facebook.authorizeCallback(requestCode, resultCode, data);
}
}
aHelper is object that hold some application specific data. Basically you should decide here if you want to log in or log out.
using facebook API for the android is easy and in your case you don't need to save the Facebook instance the only thing you need is to save the authKey of the facebook on the first login then you can use it anywhere.
this means that you can create more than one instance of the facebook object in mutiple activities based on the authKey.
Otherwise you need to put this facebook object in a singleton handler to save it among the application :
class x {
private Facebook obj;
private static x instance;
private x (){
}
public static x getX(){
if(instance == null){
instance = new x();
}
return instance;
}
public void setIt(Facebook obj){
this.obj = obj;
}
public Facebook getIt(){
return obj;
}
}
but this way is not the best way to implement the code you need to create a Facebook instance for each activity using the authKy.