protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); FacebookSdk.SdkInitialize(this.ApplicationContext); LoadApplication(new App()); callbackManager = CallbackManagerFactory.Create(); LoginManager.Instance.RegisterCallback(callbackManager, new FacebookCallback <LoginResult>() { HandleSuccess = loginResult => { var accessToken = loginResult.AccessToken; App.OnFacebookAuthSuccess(accessToken.Token); }, HandleCancel = () => { App.OnFacebookAuthFailed(); }, HandleError = loginError => { App.OnFacebookAuthFailed(); } }); }
private void OnInitialize() { Type[] types = AssemblyLoader.LoadFrom(this.ManagedCallbacksDll).GetTypes(); Type type1 = (Type)null; foreach (Type type2 in types) { if (((IEnumerable <Type>)type2.GetInterfaces()).Contains <Type>(typeof(ICallbackManager))) { type1 = type2; break; } } CoreManaged._callbackManager = type1.GetConstructor(new Type[0]).Invoke(new object[0]) as ICallbackManager; CoreManaged._callbackManager.Initialize(); Delegate[] delegates = CoreManaged._callbackManager.GetDelegates(); for (int index = 0; index < delegates.Length; ++index) { try { CoreManaged.PassManagedCoreCallbackMethodPointers(delegates[index]); } catch (Exception ex) { CoreManaged.PassManagedCoreCallbackMethodPointers((Delegate)null); // ISSUE: variable of a boxed type __Boxed <int> local = (ValueType)index; Console.WriteLine(ex.ToString() + " " + (object)local); } } MBAPI.SetObjects(CoreManaged._callbackManager.GetScriptingInterfaceObjects()); Module.CreateModule(); }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); ////Per ottenere la hash key da inserire in facebook //PackageInfo info = this.PackageManager.GetPackageInfo("it.trilogik.AppFocGenova", PackageInfoFlags.Signatures); //foreach (Android.Content.PM.Signature signature in info.Signatures) //{ // MessageDigest md = MessageDigest.GetInstance("SHA"); // md.Update(signature.ToByteArray()); // string keyhash = Convert.ToBase64String(md.Digest()); // Console.WriteLine("KeyHash:", keyhash); //} FacebookSdk.SdkInitialize(ApplicationContext); callbackManager = CallbackManagerFactory.Create(); LoginManager.Instance.RegisterCallback(callbackManager, new facebookCallBack()); LoadApplication(new App()); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); TabLayoutResource = Resource.Layout.tabs; ToolbarResource = Resource.Layout.toolbar; CachedImageRenderer.Init(); global::Xamarin.Forms.Forms.Init(this, bundle); if (callbackManager == null) { callbackManager = CallbackManagerFactory.Create(); } if (IsPlayServicesAvailable()) { var intent = new Intent(this, typeof(RegistrationIntentService)); StartService(intent); } var userId = Intent.GetStringExtra("userId"); var token = Intent.GetStringExtra("token"); var userName = Intent.GetStringExtra("userName"); LoadApplication(new App(new AndroidInitializer(), token)); }
protected override void OnActivityResult(int requestCode, Result resultCode, Android.Content.Intent data) { try { FacebookSdk.SdkInitialize(this); // FacebookSdk.ApplicationId = "444917649791842"; //pune el id de la app de facebook AppEventsLogger.ActivateApp(Application); //no se que hace esta linea mprofileTracker = new MyProfileTracker(); mprofileTracker.mOnProfileChanged += MprofileTracker_mOnProfileChanged; mprofileTracker.StartTracking(); // Set our view from the "main" layout resource // SetContentView(Resource.Layout.configCuenta); //BtnFBLogin = FindViewById<LoginButton>(Resource.Id.fb_btn); BtnFBLogin.SetReadPermissions(new List <string> { "public_profile", "user_friends", "email", "user_birthday" }); mFBCallManager = CallbackManagerFactory.Create(); BtnFBLogin.RegisterCallback(mFBCallManager, this); //base.OnActivityResult(requestCode, resultCode, data); mFBCallManager.OnActivityResult(requestCode, (int)resultCode, data); } catch (Exception e) { Console.WriteLine(e); Console.WriteLine(e); Console.WriteLine(e); Console.WriteLine(e); Console.WriteLine(e); Console.WriteLine(e); Console.WriteLine(e); Console.WriteLine(e); Console.WriteLine(e); Console.WriteLine(e); Console.WriteLine(e); } }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); //facebook implementation callbackManager = CallbackManagerFactory.Create(); var loginCallback = new FacebookCallback <LoginResult> { HandleSuccess = (loginResult) => { //proceed next page App.ProceedToHome(); }, HandleCancel = () => { //handle cancel }, HandleError = (loginError) => { //handle error } }; LoginManager.Instance.RegisterCallback(callbackManager, loginCallback); LoadApplication(new App()); FirebaseApp.InitializeApp(this); }
/** * Init Facebook */ public void Init() { FacebookSdk.SdkInitialize(activity.ApplicationContext); FacebookSdk.ApplicationId = activity.Resources.GetString(Resource.String.facebook_app_id); callbackManager = CallbackManagerFactory.Create(); var loginCallback = new FacebookCallback <LoginResult> { HandleSuccess = loginResult => { token = loginResult.AccessToken; (Xamarin.Forms.Application.Current as Hauynite).OnLogin(token.UserId); var intent = new Intent(FacebookLoginReceiver.ActionKey); intent.PutExtra(FacebookLoginReceiver.ExtraResult, (int)Result.Success); intent.PutExtra(FacebookLoginReceiver.ExtraUserId, token.UserId); activity.SendBroadcast(intent); }, HandleCancel = () => { var intent = new Intent(FacebookLoginReceiver.ActionKey); intent.PutExtra(FacebookLoginReceiver.ExtraResult, (int)Result.Cancel); activity.SendBroadcast(intent); }, HandleError = loginError => { var intent = new Intent(FacebookLoginReceiver.ActionKey); intent.PutExtra(FacebookLoginReceiver.ExtraResult, (int)Result.Error); activity.SendBroadcast(intent); } }; LoginManager.Instance.RegisterCallback(callbackManager, loginCallback); }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); //((DroidLoginProvider)DependencyService.Get<ILoginProvider>()).Init(this); FacebookSdk.SdkInitialize(ApplicationContext); callbackManager = CallbackManagerFactory.Create(); //var loginCallback = new FacebookCallback<LoginResult> //{ // HandleSuccess = loginResult => { // var tck =AccessToken.CurrentAccessToken.Token; // //CoffeeCups.Helpers.Settings.FacebookAccessToken = AccessToken.CurrentAccessToken.Token; // App.GoToMainPage(); // }, // HandleCancel = () => { // }, // HandleError = loginError => { // } //}; LoginManager.Instance.RegisterCallback(callbackManager, new facebookCallBack()); LoadApplication(new App()); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.login_activity); //return base.OnOptionsItemSelected(item); FirebaseApp.InitializeApp(this); _auth = FirebaseAuth.Instance; GoogleButton = FindViewById <SignInButton>(Resource.Id.gButton); GoogleButton.Click += (object sender, System.EventArgs e) => { var signGoogleintent = Auth.GoogleSignInApi.GetSignInIntent(_googleApiClient); StartActivityForResult(signGoogleintent, Constants.ActionResult.GoogleLoginResul); }; FacebookButton = FindViewById <LoginButton>(Resource.Id.fButton); FacebookButton.SetReadPermissions("email", "public_profile"); callbackManager = CallbackManagerFactory.Create(); FacebookButton.RegisterCallback(callbackManager, this); _googleApiClient = LoginHelper.ConfigureGoogleSignIn(this); }
//CognitoAccessTokenTracker tracker; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); callbackManager = CallbackManagerFactory.Create(); LoginManager.Instance.RegisterCallback(callbackManager, new FacebookCallback <LoginResult>() { HandleSuccess = loginResult => { var accessToken = loginResult.AccessToken; CognitoSyncUtils.UpdateCredentials(accessToken.Token); Intent todoActivity = new Intent(this, typeof(TodoActivity)); StartActivity(todoActivity); }, HandleCancel = () => { CognitoSyncUtils.UpdateCredentials(string.Empty); }, HandleError = loginError => { CognitoSyncUtils.UpdateCredentials(string.Empty); } }); LoginManager.Instance.LogInWithReadPermissions(this, new List <string> { "public_profile" }); CognitoSyncUtils.Initialize(); }
public static void RegisterFacebookCallbacks() { CallbackManager = CallbackManagerFactory.Create(); LoginCallback = new FacebookCallback <LoginResult> { HandleSuccess = loginResult => { FacebookSdk.ClientToken = AccessToken.CurrentAccessToken.Token; FacebookProfileTracker.StartTracking(); FacebookLoggedIn = true; }, HandleCancel = () => { }, HandleError = loginError => { Console.WriteLine("fb login error"); }, HandleLogout = () => { } }; LoginManager.Instance.RegisterCallback(CallbackManager, LoginCallback); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate (savedInstanceState); facebookcallbackmanager = global::Xamarin.Facebook.CallbackManagerFactory.Create(); // LoginManager.Instance.RegisterCallback (facebookcallbackmanager,new FaceBookLikeLoginResult(this)); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.LoginView); if (Profile.CurrentProfile != null && AccessToken.CurrentAccessToken?.Token != null) { ChangeActivity(); } var button = FindViewById <LoginButton>(Resource.Id.login_button); mCallBackManager = CallbackManagerFactory.Create(); button.SetReadPermissions("user_friends"); button.RegisterCallback(mCallBackManager, this); // resolve keyHash //var info = this.PackageManager.GetPackageInfo("com.test.PartyOrganizer", Android.Content.PM.PackageInfoFlags.Signatures); //foreach (var signature in info.Signatures) //{ // var md = MessageDigest.GetInstance("SHA"); // md.Update(signature.ToByteArray()); // var keyHash = Convert.ToBase64String(md.Digest()); //} }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); callbackManager = CallbackManagerFactory.Create(); var loginCallback = new FacebookCallback <LoginResult> { HandleSuccess = loginResult => { OnFacebookLoginSuccess(); /// raise event this.Finish(); }, HandleCancel = () => { OnFacebookLoginCancel(); // raise event this.Finish(); }, HandleError = loginError => { OnFacebookLoginError(); // raise event this.Finish(); } }; LoginManager.Instance.RegisterCallback(callbackManager, loginCallback); string[] PERMISSIONS = Intent.GetStringArrayExtra("permissions"); LoginManager.Instance.LogInWithReadPermissions(this, PERMISSIONS); }
public static void Init(String version, String optionsFilename, ILogManager defaultLog, IShutdown shutdown, ICallbackManager callbacks, IServerManager servers, MeasureStringControl measure, String defaultRegistryLoc) { _versionString = version; _defaultLogManager = defaultLog; _shutdownMethod = shutdown; _callbackManager = callbacks; _serverManager = servers; _measureControl = measure; _applianceFrameMap = new Hashtable(); _store = new PUC.PersistentData.DataStore(optionsFilename); if (!_store.IsKeyValid(Globals.REGISTRY_FILE_ATTR)) { _store.Set(Globals.REGISTRY_FILE_ATTR, defaultRegistryLoc); _store.Set(Globals.RECENT_SERVER_ATTR, 10); _store.Set(Globals.RECENT_COUNT_ATTR, 0); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); //FacebookSDK Config FacebookSdk.SdkInitialize(this.ApplicationContext); CallbackManager = CallbackManagerFactory.Create(); //AWS SDK Config var loggingConfig = AWSConfigs.LoggingConfig; loggingConfig.LogMetrics = true; loggingConfig.LogResponses = ResponseLoggingOption.Always; loggingConfig.LogMetricsFormat = LogMetricsFormatOption.JSON; loggingConfig.LogTo = LoggingOptions.SystemDiagnostics; AWSConfigs.AWSRegion = "eu-west-1"; //Google Maps Config Xamarin.FormsMaps.Init(this, bundle); ActionBar.SetIcon(Android.Resource.Color.Transparent); LoadApplication(new App()); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Facebook API initialization FacebookSdk.SdkInitialize(this.ApplicationContext); AppEventsLogger.ActivateApp(this.Application); _masterProfileTracker = new FBProfileTracker(); _masterProfileTracker.mOnProfileChanged += MasterProfileTracker_mOnProfileChanged; _masterProfileTracker.StartTracking(); // Create your application here SetContentView(Resource.Layout.FacebookLoginView); _fullNameTextView = FindViewById <TextView>(Resource.Id.fullNameTextView); _facebookLoginButton = FindViewById <LoginButton>(Resource.Id.facebookLoginButton); _facebookLoginButton.SetReadPermissions(new List <string> { "user_friends", "public_profile" }); _masterFBCallManager = CallbackManagerFactory.Create(); _facebookLoginButton.RegisterCallback(_masterFBCallManager, this); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_login); this.Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); this.Window.ClearFlags(WindowManagerFlags.TranslucentStatus); this.Window.SetStatusBarColor(Color.ParseColor("#204060")); progressBar = FindViewById <ProgressBar>(Resource.Id.progressBar); googlebutton = FindViewById <Button>(Resource.Id.googlebutton); googlebutton.Click += Googlebutton_Click; facebookbutton = FindViewById <Button>(Resource.Id.facebookbutton); facebookbutton.Click += Facebookbutton_Click; fb_dummybuttton = FindViewById <LoginButton>(Resource.Id.fb_dummybuttton); fb_dummybuttton.SetReadPermissions(new List <string> { "public_profile", "email" }); callbackManager = CallbackManagerFactory.Create(); fb_dummybuttton.RegisterCallback(callbackManager, this); gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn).RequestIdToken("787402240794-prndui4ntngl1je2lglu46lev1esogsi.apps.googleusercontent.com") .RequestEmail().Build(); googleApiClient = new GoogleApiClient.Builder(this).AddApi(Auth.GOOGLE_SIGN_IN_API, gso).Build(); googleApiClient.Connect(); firebaseAuth = AppDataHelper.GetFirebaseAuth(); prefs = PreferenceManager.GetDefaultSharedPreferences(this); AppDataHelper.editor = prefs.Edit(); }
private void InitializedFB() { activity = this.Context as Activity; view = activity.LayoutInflater.Inflate(Resource.Layout.FacebookLayout, this, false); FacebookSdk.SdkInitialize(this.Context); NativeFacebookPageRenderer.callbackManager = CallbackManagerFactory.Create(); #region CHECKING IF ALREADY LOGGED IN TO FACEBOOK profile = Profile.CurrentProfile; if (profile != null) { firstname = profile.FirstName; lastname = profile.LastName; GetUserInfoViaGraphRequest(); } #endregion LoginManager.Instance.RegisterCallback(NativeFacebookPageRenderer.callbackManager, this); var buttonFB = view.FindViewById <Button>(Resource.Id.buttonFB); buttonFB.Click += ButtonFB_Click; profilePictureView = view.FindViewById <ProfilePictureView>(Resource.Id.profilePicture); this.AddView(view); NativeView = view; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); Window.RequestFeature(WindowFeatures.NoTitle); #pragma warning disable CS0618 // Type or member is obsolete FacebookSdk.SdkInitialize(this.ApplicationContext); #pragma warning restore CS0618 // Type or member is obsolete SetContentView(Resource.Layout.Main); //LoginButton button = FindViewById<LoginButton>(Resource.Id.login_button); //button.SetReadPermissions("user_friends"); mCallBackManager = CallbackManagerFactory.Create(); //button.RegisterCallback(mCallBackManager, this); LoginManager.Instance.RegisterCallback(mCallBackManager, this); FindViewById <Button>(Resource.Id.button).Click += (o, e) => { LoginManager.Instance.LogInWithReadPermissions(this, new List <string> { "public_profile", "user_friends" }); }; }
private static void Initialize() { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); Type[] types = AssemblyLoader.LoadFrom(Managed.ManagedCallbacksDll).GetTypes(); Type type1 = (Type)null; foreach (Type type2 in types) { if (((IEnumerable <Type>)type2.GetInterfaces()).Contains <Type>(typeof(ICallbackManager))) { type1 = type2; break; } } Managed._callbackManager = type1.GetConstructor(new Type[0]).Invoke(new object[0]) as ICallbackManager; Managed._callbackManager.Initialize(); Delegate[] delegates = Managed._callbackManager.GetDelegates(); for (int index = 0; index < delegates.Length; ++index) { try { Managed.PassManagedEngineCallbackMethodPointers(delegates[index]); } catch (Exception ex) { Managed.PassManagedEngineCallbackMethodPointers((Delegate)null); // ISSUE: variable of a boxed type __Boxed <int> local = (ValueType)index; Console.WriteLine(ex.ToString() + " " + (object)local); } } LibraryApplicationInterface.SetObjects(Managed._callbackManager.GetScriptingInterfaceObjects()); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); RequestWindowFeature(WindowFeatures.NoTitle); SetContentView(Resource.Layout.AuthActivity); DroidDAL.HockeyAppRegister(this); _view = FindViewById <AuthView>(Resource.Id.auth_view); InitStatusBar(); ThemeHolder.Init(DataService.RepositoryController.RepositoryThemes); _interactor = new InteractorAuth(new AuthController(ConnectionController.GetInstance(), WebMsgParser.ParseResponseAuth), new ValidationRA()); #if MOCK _presenter = new PresenterAuthMOCK(_view, _interactor, new RouterAuth(this), FacebookCallLoginAction, GoogleCallLoginAction, VkCallLoginAction, OkCallLoginAction, new AuthStylesHolderDroid <GlobalControlsTheme>(new ThemeParser <GlobalControlsTheme>()), DataService.RepositoryController.RepositoryRA.LangRA); #else _presenter = new PresenterAuth(_view, _interactor, new RouterAuth(this), FacebookCallLoginAction, GoogleCallLoginAction, VkCallLoginAction, OkCallLoginAction, new AuthStylesHolderDroid <GlobalControlsTheme>(new ThemeParser <GlobalControlsTheme>()), DataService.RepositoryController.RepositoryRA.LangRA); #endif _presenter.SetConfig(); _callbackManager = CallbackManagerFactory.Create(); _facebookCallback = new FacebookCallback(_interactor); LoginManager.Instance.RegisterCallback(_callbackManager, _facebookCallback); _interactor.OnSocialLogOut += SocialLogOut; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); FacebookSdk.SdkInitialize(this.ApplicationContext); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); LoginButton button = FindViewById<LoginButton>(Resource.Id.login_button); button.SetReadPermissions("user_friends"); callBackManager = CallbackManagerFactory.Create(); button.RegisterCallback(callBackManager, this); if (AccessToken.CurrentAccessToken != null) { Console.WriteLine("USER IS LOGGED IN"); Console.WriteLine(Profile.CurrentProfile.Id); StartActivity(typeof(Src.Screens.Home)); } else { Console.WriteLine("USER IS NOT LOGGED IN"); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); //PackageInfo info = PackageManager.GetPackageInfo(); // "Package name", //Replace your package name here // PackageManager.GET_SIGNATURES); //for (Signature signature : info.signatures) //{ // MessageDigest md = MessageDigest.getInstance("SHA"); // md.update(signature.toByteArray()); // Log.e("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT)); //} FacebookSdk.SdkInitialize(this.ApplicationContext); mprofileTracker = new MyProfileTracker(); mprofileTracker.mOnProfileChanged += mProfileTracker_mOnProfileChanged; mprofileTracker.StartTracking(); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); BtnFBLogin = FindViewById <LoginButton>(Resource.Id.fblogin); TxtFirstName = FindViewById <TextView>(Resource.Id.TxtFirstname); TxtLastName = FindViewById <TextView>(Resource.Id.TxtLastName); TxtName = FindViewById <TextView>(Resource.Id.TxtName); mprofile = FindViewById <ProfilePictureView>(Resource.Id.ImgPro); BtnFBLogin.SetReadPermissions(new List <string> { "user_friends", "public_profile" }); mFBCallManager = CallbackManagerFactory.Create(); BtnFBLogin.RegisterCallback(mFBCallManager, this); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); //FacebookSdk.ApplicationId should be set before LoginManager.Instance.LogInWithReadPermissions is called, otherwise //the application will crash FacebookSdk.ApplicationId = Constants.FB_APP_ID; FacebookSdk.ApplicationName = Constants.FB_APP_NAME; FacebookSdk.SdkInitialize(this.ApplicationContext); LoadApplication(new App()); callbackManager = CallbackManagerFactory.Create(); LoginManager.Instance.RegisterCallback(callbackManager, new FacebookCallback <LoginResult>() { HandleSuccess = loginResult => { var accessToken = loginResult.AccessToken; App.OnFacebookAuthSuccess(accessToken.Token); }, HandleCancel = () => { App.OnFacebookAuthFailed(); }, HandleError = loginError => { App.OnFacebookAuthFailed(); } }); }
/// <summary> /// Ons the create. /// </summary> /// <param name="savedInstanceState">Saved instance state.</param> protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); #region [ Facebook ] FacebookSdk.SdkInitialize(ApplicationContext); callbackManager = CallbackManagerFactory.Create(); var loginCallback = new FacebookCallback <LoginResult> { HandleSuccess = loginResult => { var facebookToken = AccessToken.CurrentAccessToken.Token; }, HandleCancel = () => { }, HandleError = loginError => { } }; LoginManager.Instance.RegisterCallback(callbackManager, loginCallback); #endregion LoadApplication(new App()); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); Window.RequestFeature(WindowFeatures.NoTitle); Com.Pixate.Freestyle.PixateFreestyle.Init(this); FacebookSdk.SdkInitialize(this.ApplicationContext); mProfileTracker = new MyProfileTracker(); mProfileTracker.mOnProfileChanged += mProfileTracker_mOnProfileChanged; mProfileTracker.StartTracking(); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); Button btnFacebook = FindViewById <Button>(Resource.Id.btnFacebook); mBtnCriar = FindViewById <Button>(Resource.Id.btnCriarConta); mTxtLogarEmail = FindViewById <TextView>(Resource.Id.logarEmail); mBtnCriar.Click += MBtnCriar_Click; mTxtLogarEmail.Click += mTxtLogarEmail_Click; if (AccessToken.CurrentAccessToken != null) { //The user is logged in through Facebook btnFacebook.Text = "Sair"; } // LoginButton button = FindViewById<LoginButton>(Resource.Id.btnFacebook); // button.SetReadPermissions("user_friends"); mCallBackManager = CallbackManagerFactory.Create(); // button.RegisterCallback(mCallBackManager, this); LoginManager.Instance.RegisterCallback(mCallBackManager, this); btnFacebook.Click += (o, e) => { if (AccessToken.CurrentAccessToken != null) { //The user is logged in through Facebook LoginManager.Instance.LogOut(); btnFacebook.Text = "Logue com Facebook"; } else { //The user is not logged in LoginManager.Instance.LogInWithReadPermissions(this, new List <string> { "public_profile", "user_friends" }); btnFacebook.Text = "Sair"; } }; }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); FacebookSdk.SdkInitialize(this); SetContentView(Resource.Layout.Main); FindViewById <LoginButton>(Resource.Id.login_button).SetReadPermissions("email"); callbackManager = CallbackManagerFactory.Create(); var loginCallback = new FacebookCallback <LoginResult> { HandleSuccess = SignInWithFacebookToken, HandleCancel = () => Log.Debug( Application.PackageName, "Canceled"), HandleError = error => Log.Error( Application.PackageName, Java.Lang.Throwable.FromException(error), "No access") }; LoginManager.Instance.RegisterCallback(callbackManager, loginCallback); carService = new CarService(); tokenTracker = new FacebookTokenTracker(carService) { HandleLoggedIn = UpdateButtons, HandleLoggedOut = UpdateButtons }; tokenTracker.StartTracking(); if (carService.GetLoginStatus() == CarService.LoginStatus.NeedsWebApiToken) { await SignInWithFacebookToken(AccessToken.CurrentAccessToken.Token); } UpdateButtons(); searchCar = FindViewById <AutoCompleteTextView>(Resource.Id.searchCar); findCar = FindViewById <Button>(Resource.Id.findCar); showAvailableCars = FindViewById <Button>(Resource.Id.showAvailableCars); findCar.Click += findCar_Click; findCar.Enabled = false; searchCar.TextChanged += (sender, e) => { if (searchCar.Text.Length > 4) { findCar.Enabled = true; } else { findCar.Enabled = false; } }; showAvailableCars.Click += (sender, args) => StartActivity(typeof(allAvailableActivity)); }
public async Task <IFacebookAccount> AuthenticateAsync(IFacebookAuthOptions options) { await LogoutAsync(); //Check if we have a cached login already that's still good var currentAccessToken = AccessToken.CurrentAccessToken; if (currentAccessToken != null && (currentAccessToken.Expires == null || ToManagedDateTime(currentAccessToken.Expires) > DateTime.UtcNow)) { // If we also have a profile, we have enough information to return a good account // without actuall doing the sign in flow var currentProfile = Profile.CurrentProfile; if (currentProfile != null) { return(populateAccount(currentAccessToken, currentProfile, options.RequestedPhotoSize)); } } var activity = Plugin.SocialAuth.Droid.SocialAuth.CurrentActivity; if (callbackManager == null) { callbackManager = CallbackManagerFactory.Create(); } var loginManager = LoginManager.Instance; var fbHandler = new FbCallbackHandler(); loginManager.RegisterCallback(callbackManager, fbHandler); fbHandler.Reset(); if (options?.WritePermissions ?? false) { loginManager.LogInWithPublishPermissions(activity, options?.Scopes); } else { loginManager.LogInWithReadPermissions(activity, options?.Scopes); } LoginResult result = null; try { result = await fbHandler.Task; } catch (Exception ex) { throw ex; } if (result == null || result.AccessToken == null) { return(null); } return(populateAccount(result.AccessToken, Profile.CurrentProfile, options.RequestedPhotoSize)); }
public FacebookService(Activity activity) { _activity = activity; _callbackManager = CallbackManagerFactory.Create(); LoginManager.Instance.RegisterCallback(_callbackManager, new FacebookCallback(this)); }
private void botonFB(object sender, EventArgs e) { btnFacebook.SetReadPermissions(new List <string> { "public_profile", "user_friends", "email" }); mCallBackManager = CallbackManagerFactory.Create(); btnFacebook.RegisterCallback(mCallBackManager, this); }
private void InitSocialLogins() { try { //#Facebook if (AppSettings.ShowFacebookLogin) { //FacebookSdk.SdkInitialize(this); ProfileTracker = new FbMyProfileTracker(); ProfileTracker.MOnProfileChanged += ProfileTrackerOnMOnProfileChanged; ProfileTracker.StartTracking(); BtnFbLogin = FindViewById <LoginButton>(Resource.Id.fblogin_button); BtnFbLogin.Visibility = ViewStates.Visible; BtnFbLogin.SetPermissions(new List <string> { "email", "public_profile" }); MFbCallManager = CallbackManagerFactory.Create(); BtnFbLogin.RegisterCallback(MFbCallManager, this); //FB accessToken var accessToken = AccessToken.CurrentAccessToken; var isLoggedIn = accessToken != null && !accessToken.IsExpired; if (isLoggedIn && Profile.CurrentProfile != null) { LoginManager.Instance.LogOut(); } string hash = Methods.App.GetKeyHashesConfigured(this); Console.WriteLine(hash); } else { BtnFbLogin = FindViewById <LoginButton>(Resource.Id.fblogin_button); BtnFbLogin.Visibility = ViewStates.Gone; } //#Google if (AppSettings.ShowGoogleLogin) { MGoogleSignIn = FindViewById <Button>(Resource.Id.Googlelogin_button); MGoogleSignIn.Click += GoogleSignInButtonOnClick; } else { MGoogleSignIn = FindViewById <Button>(Resource.Id.Googlelogin_button); MGoogleSignIn.Visibility = ViewStates.Gone; } } catch (Exception e) { Console.WriteLine(e); } }
public override void OnAttach(Activity activity) { base.OnAttach (activity); nn_activity=(Tap5050FragmentActivity)activity; socialshareandroid = new SocialShareAndroid (nn_activity); facebookcallbackmanager = global::Xamarin.Facebook.CallbackManagerFactory.Create(); LoginManager.Instance.RegisterCallback (facebookcallbackmanager,new FaceBookLoginResult(this)); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); //Init FacebookSDK with the application context, then init an instance of CallbackManager FacebookSdk.SdkInitialize(this.ApplicationContext); CallbackManager = CallbackManagerFactory.Create(); //If you are planning to use Parse to authenticate your user via FacebookLogin, configurate here //Parse.ParseClient.Initialize("<YOUR .NET ID>", "<YOUR PROJECT ID>"); //Parse.ParseFacebookUtils.Initialize("<YOUR FACEBOOK APP ID>"); LoadApplication(new App()); }
public static async void Login(WebAuthenticator authenticator) { var fbAuthenticator = authenticator as FacebookAuthenticator; var currentActivity = activityLifecycleManager.CurrentActivity; FacebookSdk.SdkInitialize(currentActivity); callbackManager = CallbackManagerFactory.Create(); var loginManager = LoginManager.Instance; var fbHandler = new FbCallbackHandler(); loginManager.RegisterCallback(callbackManager, fbHandler); fbHandler.Reset(); if (RequestPublishPermissions) loginManager.LogInWithPublishPermissions(currentActivity, fbAuthenticator.Scope); else loginManager.LogInWithReadPermissions(currentActivity, fbAuthenticator.Scope); LoginResult result = null; try { result = await fbHandler.Task; } catch (Exception ex) { fbAuthenticator.OnError(ex.Message); return; } if (result == null) fbAuthenticator.OnCancelled(); DateTime? expires = null; long expiresIn = -1; if (result?.AccessToken.Expires != null) { expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(result.AccessToken.Expires.Time); expiresIn = (long)(expires.Value - DateTime.Now).TotalSeconds; } fbAuthenticator.OnRecievedAuthCode(result?.AccessToken.Token, expiresIn); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); FacebookSdk.SdkInitialize(ApplicationContext); AppEventsLogger.ActivateApp(Application); callbackManager = CallbackManagerFactory.Create(); LoginManager.Instance.RegisterCallback(callbackManager, facebookCallback); this.Window.AddFlags(WindowManagerFlags.Fullscreen); global::Xamarin.Forms.Forms.Init(this, bundle); Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init(); App.UIContext = this; LoadApplication(new ContosoMoments.App()); instance = this; #if PUSH // need to use a Google image on an Android emulator try { // Check to ensure everything's setup right GcmClient.CheckDevice(this); GcmClient.CheckManifest(this); // Register for push notifications System.Diagnostics.Debug.WriteLine("Registering..."); GcmClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS); } catch (Java.Net.MalformedURLException) { CreateAndShowDialog(new Exception("There was an error creating the Mobile Service. Verify the URL"), "Error"); } catch (Exception e) { CreateAndShowDialog(e, "Error"); } #endif }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); #if DEBUG PackageInfo info = this.PackageManager.GetPackageInfo("com.tojeero.tojeero", PackageInfoFlags.Signatures); foreach (Android.Content.PM.Signature signature in info.Signatures) { MessageDigest md = MessageDigest.GetInstance("SHA"); md.Update(signature.ToByteArray()); string keyhash = Convert.ToBase64String(md.Digest()); Console.WriteLine("KeyHash:", keyhash); } #endif //Setup Xamarin forms global::Xamarin.Forms.Forms.Init(this, bundle); LoadApplication(new FormsApp()); CallbackManager = CallbackManagerFactory.Create(); makeUICustomizations(); }
public void SetupFacebook() { FacebookSdk.SdkInitialize (this.ApplicationContext); callback = CallbackManagerFactory.Create (); LoginManager.Instance.RegisterCallback (callback, this); mProfileTracker = new MyProfileTracker (); mProfileTracker.mOnProfileChanged += mProfileTracker_mOnProfileChanged; mProfileTracker.StartTracking (); }
private void SetupFacebookLogin() { callbackManager = CallbackManagerFactory.Create(); LoginButton facebookLoginBtn = FindViewById<LoginButton>(Resource.Id.facebookLoginBtn); facebookLoginBtn.SetReadPermissions("public_profile", "email"); var loginCallback = new FacebookCallback<LoginResult> { HandleSuccess = async loginResult => { AlertsService.ShowToast(this, "Facebook zwróci³ token"); var userIsLogged = await LoginWithFacebook(); if (userIsLogged) { GoToMainActivity(); } else { AlertsService.ShowToast(this, "Facebook zwróci³ token, ale coœ posz³o nie tak z logowaniem na serwerze"); } }, HandleCancel = () => { AlertsService.ShowToast(this, "Przerwano logowanie z facebookiem"); }, HandleError = loginError => { AlertsService.ShowToast(this, "Wyst¹pi³ b³¹ podczas logowanie z facebookiem"); } }; facebookLoginBtn.RegisterCallback(this.callbackManager, loginCallback); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); FacebookSdk.SdkInitialize(this.ApplicationContext); mProfileTracker = new MyProfileTracker(); mProfileTracker.mOnProfileChanged += mProfileTracker_mOnProfileChanged; mProfileTracker.StartTracking(); // Setting Layout SetContentView(Resource.Layout.RegisterAccount); // getting editText nom = FindViewById<EditText>(Resource.Id.reg_lname_text); prenom = FindViewById<EditText>(Resource.Id.reg_fname_text); email = FindViewById<EditText>(Resource.Id.reg_email_text); mdp = FindViewById<EditText>(Resource.Id.reg_pwd_text); mdp2 = FindViewById<EditText>(Resource.Id.reg_confPwd_text); pseudo = FindViewById<EditText>(Resource.Id.reg_pseudo_text); // Login if already have an account TextView loginTextView = FindViewById<TextView>(Resource.Id.reg_signin_text); loginTextView.Click += delegate { StartActivity(typeof(LoginActivity)); }; // Facebook Configuration LoginButton button = FindViewById<LoginButton>(Resource.Id.reg_cnxFacebook_btn); button.SetReadPermissions(new List<string> { "public_profile", "user_friends", "email" }); mCallBackManager = CallbackManagerFactory.Create(); button.RegisterCallback(mCallBackManager, this); // bouton enregistrement inscription Button registerButton = FindViewById<Button>(Resource.Id.register_btn); registerButton.Click += delegate { // verification des champs bool error = false; if (!error) error = verifText("prenom", prenom); if (!error) error = verifText("nom", nom); if (!error) error = verifText("pseudo", pseudo); if (!error) error = verifText("email", email); if (!error) error = verifText("mot de passe", mdp); if (!error) error = verifText("confirmation de mot de passe", mdp2); if (!error && mdp.Text.ToString() != mdp2.Text.ToString()) { error = true; Toast.MakeText(this, "Les mots de passe ne correspondent pas", ToastLength.Long).Show(); } // Vérification de la saisie !!! if (!error) { User user = new User(prenom.Text, nom.Text, pseudo.Text, email.Text, mdp.Text); DataBase.Inscription(user); DataBase.connected = true; StartActivity(typeof(ProfileActivity)); } }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.home); global::Xamarin.Facebook.FacebookSdk.SdkInitialize (this); facebookcallbackmanager = global::Xamarin.Facebook.CallbackManagerFactory.Create(); SocialShareAndroid soccialandroid = new SocialShareAndroid (this); //try to get location this.rootlayout=(RelativeLayout)FindViewById (Resource.Id.rootlayout); locationmanager = new LocationManager (); IntentFilter intetnfilter = new IntentFilter (); intetnfilter.AddAction (Intent.ActionScreenOff); intetnfilter.AddAction (Intent.ActionScreenOn); RegisterReceiver (new ScreenUnlockReceiver(this),intetnfilter); IntentFilter smsfilter = new IntentFilter (); smsfilter.AddAction ("SMS_SENT"); smsfilter.AddAction ("SMS_RECEIVED"); SmsMessagekReceiver smsreceiver = new SmsMessagekReceiver (this); RegisterReceiver (smsreceiver,smsfilter); SmsMessageDelieveredReceiver smsdelieveredreceiver = new SmsMessageDelieveredReceiver (this); RegisterReceiver (smsdelieveredreceiver,smsfilter); AddSpinner (RaffleListScreenData.LoadingScreenTextLocation); locationmanager.GetPosition ((Tap5050WebResponse response) => { if (response.available) { RunOnUiThread(()=>{ RemoveSpinner (); }); var position=(GeonamesCountry)response.parsedobject; GlobalVariable.currentlocation=position.adminName1; //if it is first time login UsernameTableObject obj=App.INSTANCE.databasemanager.GetUsername(GlobalVariable.username); //if first time login show fragment if (obj!=null&&obj.HaveLogged == 0) { ShowTutorialFragment(0); App.INSTANCE.databasemanager.SetLogged (GlobalVariable.username); } else{ InitialFragment(GlobalVariable.currentlocation); } } else { GetAvailableProvince(); } }); // GetAvailableProvince(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SensusServiceHelper.Initialize(() => new AndroidSensusServiceHelper()); _uiReadyWait = new ManualResetEvent(false); _activityResultWait = new ManualResetEvent(false); _facebookCallbackManager = CallbackManagerFactory.Create(); Window.AddFlags(global::Android.Views.WindowManagerFlags.DismissKeyguard); Window.AddFlags(global::Android.Views.WindowManagerFlags.ShowWhenLocked); Window.AddFlags(global::Android.Views.WindowManagerFlags.TurnScreenOn); Forms.Init(this, savedInstanceState); FormsMaps.Init(this, savedInstanceState); MapExtendRenderer.Init(this, savedInstanceState); _app = new App(); LoadApplication(_app); _serviceConnection = new AndroidSensusServiceConnection(); _serviceConnection.ServiceConnected += (o, e) => { // get reference to service helper for use within the UI UiBoundSensusServiceHelper.Set(e.Binder.SensusServiceHelper); // give service helper a reference to this activity e.Binder.SensusServiceHelper.MainActivityWillBeSet = false; e.Binder.SensusServiceHelper.SetMainActivity(this); // display service helper properties on the main page _app.SensusMainPage.DisplayServiceHelper(e.Binder.SensusServiceHelper); }; _serviceConnection.ServiceDisconnected += (o, e) => { DisconnectFromService(); }; OpenIntentAsync(Intent); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); FacebookSdk.SdkInitialize(this.ApplicationContext); mProfileTracker = new MyProfileTracker(); mProfileTracker.mOnProfileChanged += mProfileTracker_mOnProfileChanged; mProfileTracker.StartTracking(); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); Button faceBookButton = FindViewById<Button>(Resource.Id.button); mTxtFirstName = FindViewById<TextView>(Resource.Id.txtFirstName); mTxtLastName = FindViewById<TextView>(Resource.Id.txtLastName); //mTxtName = FindViewById<TextView>(Resource.Id.txtName); mProfilePic = FindViewById<ProfilePictureView>(Resource.Id.profilePic); //mBtnShared = FindViewById<ShareButton>(Resource.Id.btnShare); mBtnKontynuacja = FindViewById<Button>(Resource.Id.btnKontynuacja); mBtnKontynuacja.Click += mBtnKontynuacja_Click; //if (AccessToken.CurrentAccessToken != null) //{ // //The user is logged in through Facebook // faceBookButton.Text = "Logged Out"; //} LoginButton button = FindViewById<LoginButton>(Resource.Id.login_button); button.SetReadPermissions(new List<string> { "public_profile", "user_friends", "email" }); mCallBackManager = CallbackManagerFactory.Create(); button.RegisterCallback(mCallBackManager, this); /*mBtnGetEmail.Click += (o, e) => { GraphRequest request = GraphRequest.NewMeRequest(AccessToken.CurrentAccessToken, this); Bundle parameters = new Bundle(); parameters.PutString("fields", "id,name,age_range,email"); request.Parameters = parameters; request.ExecuteAsync(); }; */ //LoginManager.Instance.RegisterCallback(mCallBackManager, this); //faceBookButton.Click += (o, e) => //{ // if (AccessToken.CurrentAccessToken != null) // { // //The user is logged in through Facebook // LoginManager.Instance.LogOut(); // faceBookButton.Text = "My Facebook login button"; // } // else // { // //The user is not logged in // LoginManager.Instance.LogInWithReadPermissions(this, new List<string> { "public_profile", "user_friends" }); // faceBookButton.Text = "Logged Out"; // } //}; // ShareLinkContent content = new ShareLinkContent.Builder().Build(); //mBtnShared.ShareContent = content; }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.home); if(!IsPlayServicesAvailable()){ RunOnUiThread(()=>{ Toast.MakeText(this, RaffleListScreenData.CannottextpushnotificationHint, ToastLength.Short).Show(); }); }else{ ThreadPool.QueueUserWorkItem(SubscribePushTopic); } global::Xamarin.Facebook.FacebookSdk.SdkInitialize (this); facebookcallbackmanager = global::Xamarin.Facebook.CallbackManagerFactory.Create(); detaltimgoriginal=BitmapFactory.DecodeResource(Resources,TapUtil.defaulticon); SocialShareAndroid soccialandroid = new SocialShareAndroid (this); //try to get location this.rootlayout=(RelativeLayout)FindViewById (Resource.Id.rootlayout); locationmanager = new LocationManager (); IntentFilter intetnfilter = new IntentFilter (); intetnfilter.AddAction (Intent.ActionScreenOff); intetnfilter.AddAction (Intent.ActionScreenOn); RegisterReceiver (new ScreenUnlockReceiver(this),intetnfilter); IntentFilter smsfilter = new IntentFilter (); smsfilter.AddAction ("SMS_SENT"); smsfilter.AddAction ("SMS_RECEIVED"); SmsMessagekReceiver smsreceiver = new SmsMessagekReceiver (this); RegisterReceiver (smsreceiver,smsfilter); SmsMessageDelieveredReceiver smsdelieveredreceiver = new SmsMessageDelieveredReceiver (this); RegisterReceiver (smsdelieveredreceiver,smsfilter); AddSpinner (RaffleListScreenData.LoadingScreenTextLocation); //locationmanager.GetPosition((Tap5050WebResponse response) => //{ // if (response.available) // { // RunOnUiThread(() => // { // RemoveSpinner(); // }); // var position = (GeonamesCountry)response.parsedobject; // GlobalVariable.currentlocation = position.adminName1; // //if it is first time login // UsernameTableObject obj = App.INSTANCE.databasemanager.GetUsername(GlobalVariable.username); // //if first time login show fragment // if (obj != null && obj.HaveLogged == 0) // { // ShowTutorialFragment(0); // App.INSTANCE.databasemanager.SetLogged(GlobalVariable.username); // } // else // { // InitialFragment(GlobalVariable.currentlocation); // } // } // else // { // GetAvailableProvince(); // } //}); GetAvailableProvince(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); FacebookSdk.SdkInitialize(this.ApplicationContext); // Setting Layout SetContentView(Resource.Layout.RegisterAccount); // Login if already have an account TextView loginTextView = FindViewById<TextView>(Resource.Id.reg_signin_text); loginTextView.Click += delegate { StartActivity(typeof(LoginActivity)); }; // Facebook Configuration LoginButton facebookButton = FindViewById<LoginButton>(Resource.Id.reg_cnxFacebook_btn); facebookButton.SetReadPermissions("user_friends"); mCallbackManager = CallbackManagerFactory.Create(); facebookButton.RegisterCallback(mCallbackManager, this); // bouton enregistrement inscription Button registerButton = FindViewById<Button>(Resource.Id.register_btn); registerButton.Click += delegate { EditText nom = FindViewById<EditText>(Resource.Id.reg_fname_text); EditText prenom = FindViewById<EditText>(Resource.Id.reg_lname_text); EditText email = FindViewById<EditText>(Resource.Id.reg_email_text); EditText mdp = FindViewById<EditText>(Resource.Id.reg_pwd_text); EditText mdp2 = FindViewById<EditText>(Resource.Id.reg_confPwd_text); //FindViewById<EditText>(Resource.Id.reg_fname_text).SetError("error", null); // verification bool error = false; if (!error) error = verifText("prenom", prenom); if (!error) error = verifText("nom", nom); if (!error) error = verifText("email", email); if (!error) error = verifText("mot de passe", mdp); if (!error) error = verifText("confirmation de mot de passe", mdp2); if (!error && mdp.Text.ToString() == mdp2.Text.ToString()) { error = true; mdp2.SetError("Les mots de passe ne correspondent pas", null); } // Vérification de la saisie !!! if (!error) StartActivity(typeof(Notification)); error = false; }; }
protected override void OnCreate(Bundle savedInstanceState) { Console.Error.WriteLine("--------------------------- Creating activity ---------------------------"); base.OnCreate(savedInstanceState); _activityResultWait = new ManualResetEvent(false); _facebookCallbackManager = CallbackManagerFactory.Create(); _serviceBindWait = new ManualResetEvent(false); Window.AddFlags(global::Android.Views.WindowManagerFlags.DismissKeyguard); Window.AddFlags(global::Android.Views.WindowManagerFlags.ShowWhenLocked); Window.AddFlags(global::Android.Views.WindowManagerFlags.TurnScreenOn); Forms.Init(this, savedInstanceState); FormsMaps.Init(this, savedInstanceState); MapExtendRenderer.Init(this, savedInstanceState); CrossCurrentActivity.Current.Activity = this; #if UNIT_TESTING Forms.ViewInitialized += (sender, e) => { if (!string.IsNullOrWhiteSpace(e.View.StyleId)) e.NativeView.ContentDescription = e.View.StyleId; }; #endif _app = new App(); LoadApplication(_app); _serviceConnection = new AndroidSensusServiceConnection(); _serviceConnection.ServiceConnected += (o, e) => { // it's happened that the service is created / started after the service helper is disposed: https://insights.xamarin.com/app/Sensus-Production/issues/46 // binding to the service in such a situation can result in a null service helper within the binder. if the service helper was disposed, then the goal is // to close down sensus. so finish the activity. if (e.Binder.SensusServiceHelper == null) { Finish(); return; } if (e.Binder.SensusServiceHelper.BarcodeScanner == null) { try { e.Binder.SensusServiceHelper.BarcodeScanner = new ZXing.Mobile.MobileBarcodeScanner(); } catch (Exception ex) { e.Binder.SensusServiceHelper.Logger.Log("Failed to create barcode scanner: " + ex.Message, LoggingLevel.Normal, GetType()); } } // tell the service to finish this activity when it is stopped e.Binder.ServiceStopAction = Finish; // signal the activity that the service has been bound _serviceBindWait.Set(); // if we're unit testing, try to load and run the unit testing protocol from the embedded assets #if UNIT_TESTING using (Stream protocolFile = Assets.Open("UnitTestingProtocol.json")) { Protocol.RunUnitTestingProtocol(protocolFile); } #endif }; // the following is fired if the process hosting the service crashes or is killed. _serviceConnection.ServiceDisconnected += (o, e) => { Toast.MakeText(this, "The Sensus service has crashed.", ToastLength.Long); DisconnectFromService(); Finish(); }; OpenIntentAsync(Intent); }
//Se acaba todo el desmadre de métodos de facebook y empieza el oncreate protected override void OnCreate (Bundle bundle) { //LE QUITAMOS EL TÍTULO PRIMERO RequestWindowFeature(WindowFeatures.NoTitle); base.OnCreate (bundle); FacebookSdk.SdkInitialize(Application.Context); mProfileTracker = new MyProfileTracker (); mProfileTracker.mOnProfileChanged += mProfileTracker_mOnProfileChanged; mProfileTracker.StartTracking (); //Asignamos los contenedores de facebook infoface = FindViewById<LinearLayout> (Resource.Id.infoface); //LE INDICAMOS EL LAYOUT A CONTROLAR SetContentView (Resource.Layout.login); //CREAMOS LA ANIMACION bounce = AnimationUtils.LoadAnimation (Application.Context, Resource.Animation.bounce); sdown = AnimationUtils.LoadAnimation (Application.Context, Resource.Animation.slidedown); fadein = AnimationUtils.LoadAnimation (Application.Context, Resource.Animation.fadein); //CREAMOS LA REFERENCIA AL BOTÓN DE FACEBOOK LoginButton connectWithFbButton = FindViewById<LoginButton> (Resource.Id.connectWithFbButton); //LE DAMOS LOS PERMISOS DE FACEBOOK AL BOTÓN DE FACEBOOK PARA QUE RECIBA COSAS! List<String> lista = new List<string> () {"public_profile", "email", "user_birthday", "user_friends"}; connectWithFbButton.SetReadPermissions (lista); respuesta = CallbackManagerFactory.Create (); connectWithFbButton.RegisterCallback (respuesta, this); datosfb = new Dictionary<string,string> (); string logout=Intent.GetStringExtra ("logout"); if (logout != null) { //Hay que cerrar la sesión de facebook Log.Debug ("CERRARSESIONFB", "CERAMOS LA SESION DE FACEBOOK!!!"); try{ LoginManager.Instance.LogOut (); }catch(Exception ex){ Log.Debug ("CERRARSESIONFB", "Lel, no había sesión :v"); } }else{ Log.Debug ("CERRARSESIONFB", "No hay nada, no hacemos nada con la sesión"); } //CREAMOS EL OBJETO PARA ACCEDER A LAS PREFERENCIAS var prefs = this.GetSharedPreferences("RunningAssistant.preferences", FileCreationMode.Private); Button iniciar = FindViewById<Button> (Resource.Id.button1); Button registro = FindViewById<Button> (Resource.Id.registro); //Button facebooklog = FindViewById<Button> (Resource.Id.facebooklog); //Toast.MakeText (this, "Inicia actividad Login!", ToastLength.Long).Show(); var toolbar = FindViewById<V7Toolbar>(Resource.Id.toolbar); SetSupportActionBar (toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled (false); var collapsingToolbar = FindViewById<CollapsingToolbarLayout> (Resource.Id.collapsing_toolbar); collapsingToolbar.SetTitle (""); //EJECUTAMOS LA ANIMACION EN LA IMAGEN ImageView logoplif = FindViewById<ImageView> (Resource.Id.logoplif); logoplif.StartAnimation(bounce); LinearLayout slogan = FindViewById<LinearLayout> (Resource.Id.slogan); slogan.StartAnimation (sdown); ImageView backdrop = FindViewById<ImageView> (Resource.Id.backdrop); backdrop.StartAnimation (fadein); LinearLayout logincont = FindViewById<LinearLayout> (Resource.Id.logincont); logincont.StartAnimation (bounce); registro.Click += (object sender, EventArgs e) => { StartActivity(typeof(Registro)); /* FragmentTransaction transaction = FragmentManager.BeginTransaction(); RegistroPlif registrarse = new RegistroPlif(); registrarse.Show(transaction, "dialog fragment");*/ /* var fabeee = FindViewById<CoordinatorLayout> (Resource.Id.snackbarPosition); Snackbar .Make (fabeee, "Regístrate en plif.mx o ingresa con Facebook!", Snackbar.LengthLong) .SetAction ("Ok", (view) => { }) .Show ()*/ }; logoplif.Click += (object sender, EventArgs e) => { logoplif.StartAnimation(bounce); }; //AQUI EMPIEZO A COPIAR TODO LO DEL CODIGO ANTERIOR iniciar.Click += async (sender, e) => { //EditText correo=null; //EditText pass=null; var correo = FindViewById<EditText> (Resource.Id.editText1); var pass = FindViewById<EditText> (Resource.Id.editText2); //FOR SAKE OF SIMPLICITY!!!! //correo.Text="*****@*****.**"; //pass.Text="xveemon1"; if(correo.Text.ToString()=="" || pass.Text.ToString()==""){ // Toast.MakeText (this, "Por favor introduzca su correo y su contraseña", ToastLength.Long).Show(); var fab = FindViewById<CoordinatorLayout> (Resource.Id.snackbarPosition); Snackbar .Make (fab, "Por favor introduce tus datos!", Snackbar.LengthLong) .SetAction ("Ok", (view) => { /*Undo message sending here.*/ }) .Show (); }else{ ProgressBar loader = FindViewById<ProgressBar> (Resource.Id.progressBar1); loader.Visibility=ViewStates.Visible; try{ string url="http://plif.mx/mobile/g_usr_dta?user="******"&pass="******"u"]; JsonValue imagenes; //JsonValue usuarios = preusuarios["users"]; int res=int.Parse(usuarios["id"]); if(res==0){ //Toast.MakeText (this, "El nombre de usuario no existe o la contraseña es incorrecta.", ToastLength.Long).Show(); var fab = FindViewById<CoordinatorLayout> (Resource.Id.snackbarPosition); Snackbar .Make (fab, "Tus datos son incorrectos o no has verificado tu cuenta aún.", Snackbar.LengthLong) .SetAction ("Ok", (view) => { /*Undo message sending here.*/ }) .Show (); }else{ //GUARDAMOS LA INFORMACION DEL USUARIO imagenes = json["i"]; var editor = prefs.Edit (); string n=usuarios["nombre"]; string ap=usuarios["apellidos"]; editor.PutString ("id", usuarios["id"]); editor.PutString ("nombre", n+ap); editor.PutString ("email", correo.Text.ToString()); editor.PutString ("img_perfil", imagenes["ruta"]); editor.Commit(); //JA Toast.MakeText (this, "Inicio de sesión correcto", ToastLength.Long).Show(); StartActivity(typeof(MainActivity)); Finish(); } }catch(Exception ex){ //Toast.MakeText (this, "Ocurrió un error, Inténtalo de nuevo", ToastLength.Long).Show(); Log.Debug("login", "el error fué: "+ex); var fab = FindViewById<CoordinatorLayout> (Resource.Id.snackbarPosition); Snackbar .Make (fab, "Ocurrió un error. Inténtalo de nuevo!", Snackbar.LengthLong) .SetAction ("Ok", (view) => { /*Undo message sending here.*/ }) .Show (); } loader.Visibility=ViewStates.Gone; //JUSTO AQUI ACABA } }; //AQUI TERMINO DE COPIAR TODO LO DEL CODIGO ANTERIOR // Create your application here }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SensusServiceHelper.Initialize(() => new AndroidSensusServiceHelper()); _uiReadyWait = new ManualResetEvent(false); _activityResultWait = new ManualResetEvent(false); _facebookCallbackManager = CallbackManagerFactory.Create(); _isForegrounded = false; Window.AddFlags(global::Android.Views.WindowManagerFlags.DismissKeyguard); Window.AddFlags(global::Android.Views.WindowManagerFlags.ShowWhenLocked); Window.AddFlags(global::Android.Views.WindowManagerFlags.TurnScreenOn); Forms.Init(this, savedInstanceState); FormsMaps.Init(this, savedInstanceState); MapExtendRenderer.Init(this, savedInstanceState); _app = new App(); LoadApplication(_app); _serviceConnection = new AndroidSensusServiceConnection(); _serviceConnection.ServiceConnected += (o, e) => { // it's happened that the service is created / started after the service helper is disposed: https://insights.xamarin.com/app/Sensus-Production/issues/46 // binding to the service in such a situation can result in a null service helper within the binder. if (e.Binder.SensusServiceHelper == null) { Finish(); return; } // get reference to service helper for use within the UI UiBoundSensusServiceHelper.Set(e.Binder.SensusServiceHelper); // give service helper a reference to this activity e.Binder.SensusServiceHelper.MainActivityWillBeSet = false; e.Binder.SensusServiceHelper.SetMainActivity(this); // display service helper properties on the main page _app.SensusMainPage.DisplayServiceHelper(e.Binder.SensusServiceHelper); }; _serviceConnection.ServiceDisconnected += (o, e) => { DisconnectFromService(); }; OpenIntentAsync(Intent); }