Facebook won't log in to new activity - android

I have a log in activity that connects to Facebook at the moment, after the user logs in I want it to connect to facebook and then I want it to connect to my Activity2 class but currently it redirects back to my original activity instead.

Is their anything wrong I'm doing in this part of my code:

private CallbackManager mCallbackManager; private FacebookCallback<LoginResult> mCallback=new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { AccessToken accessToken = loginResult.getAccessToken(); Profile profile = Profile.getCurrentProfile(); if (profile != null) { Intent intent = new Intent(getActivity(), MainActivity2Activity.class); startActivity(intent); } }

-------------Problems Reply------------

Checking if profile is null wouldn't work as ProfileManager fetches the profile asynchronously and getCurrentProfile() would likely return null immediately after logging in.

You could instead check if loginResult.getAccessToken() returns a non-null value.

Category:android Views:3 Time:2018-06-29

Related post

  • Access intent after starting new activity android 2011-05-28

    Hey everyone, I am having an issue with something and I don't really know where to look or how to search for this, so I am asking here. Basically, I am starting a new activity from my main activity using this bit of code: Intent intent = new Intent(v

  • Cannot call 'SetContentView' on new activity - Android Mono 2012-03-06

    I've had a search for this problem but nothing seems to help me to solve this particular error I am getting. I am writing my first Android app and am coming across a java.lang.RuntimeException whenever I call SetContentView on a new activity. There i

  • my blackberry tablet won,t log into the new outlook 2013-04-19

    My blackberry tablet browser won,the open the new outlook therefore I can't write emails-mails or check spam --------------Solutions------------- Hi, Sorry for the delayed response. Please answer the following for our investigation: How did you acces

  • facebook won't let me log off 2012-05-15

    facebook won't log off , won't let me play games or poke people. what can I do to shut this down? --------------Solutions------------- Hi, 1. Which web browser are you using to access facebok? 2. What is the exact error message? 3. Have you made any

  • Make new activity take the place of the parent in the stack 2010-12-02

    I have read about activities, stacks and launch modes, but have a hard time understanding how to apply this info to my specific problem. Basically what I want to do is to launch a new activity, and make sure that it takes the parent's place in the st

  • I try to log onto facebook using IE9 it won't log in and goes back to thefacebook log on page 2014-12-02

    When I try to log onto facebook using IE9 it won't log in and goes back to thefacebook log on page. I don't have the problem logging in through fireefox. Can anyone help? --------------Solutions------------- Hi, 1. Did you make any changes to your co

  • Logging in to a web page using Facebook won't work with IE11 2014-03-29

    I have Windows 8.1 and am using IE11. I can go to Facebook and log in with no problems. When I am at another website and want to login to that account using my Facebook account, I click the FB button and nothing happens. This happens on all websites

  • facebook connect: javascript logs session but php doesn't 2012-03-07

    I had the sample facebook login implementation, and just realized that it stopped working: <?php // Create our Application instance (replace this with your appId and secret). $facebook = new Facebook(array( 'appId' => 'myappid', 'secret' =>

  • AsyncTask won't stop even when the activity has destroyed 2010-03-27

    I have an AsyncTask object which starts executing when the activity is created and does stuff in the background (downloads upto 100 images). Everything works fine but there is this peculiar behavior which i'm not able to understand. For eg: when the

  • UIThread is causing problems when I want to open a new Activity 2011-05-10

    I have a SurfaceView in an Activity, and I want to open up a new Activity when something occurs in the SurfaceView(when you run out of lives - lives == 0). I've tried different things, but I keep having problems with it. If I stop my UIThread first,

  • MSN games won't work. Facebook won't open. 2013-04-01

    I recently downloaded a coupon download from JoAnn Fabrics. I thought it was safe, but since then, my MSN games won't load and Facebook won't open. I'm getting pop ups when I shouldn't be. Scan says no virus or malware. I've done all the things MSN a

  • Calling finish() After Starting a New Activity 2010-04-26

    The first Activity that loads in my application is an initialization activity, and once complete it loads a new Activity. I want to ensure if the user presses 'Back' they go straight to the Launcher, and not the initialization screen. Side note, is t

  • Starting a new activity 2010-08-18

    I'm relatively new to programming in general so be gentle =| I'm trying to start a new activity from a basic one that displays a couple of text inputs, a checkbox, and a button. When the button is pressed I want it to switch to the new activity. The

  • Threads interrupted when new activity is started. Android 2010-08-29

    I have a slightly strange thing happening in my code atm, which I don't understand... I would much appreciate any input anyone may have. So here's the issue: In my main Activity I fire a Service, using an Intent, when a button is pressed on screen. T

  • New Activity nullpointerexception Problem 2010-09-03

    I have a noob problem. Here is my situation: I want to start a new activity from the main activity. The code to launch the new activity is found in a separate class file. I seem to be passing the wrong arguments and I am ending up in a nullpointerexc

  • prob in starting new activity 2010-10-29

    Please help me In my Project when i m starting new activity it is crashing public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.shortnews); showNewsListView = (ListView)findViewById(R.id.shortn

  • How to start new activity on button click 2010-11-15

    In an Android application, how do you start a new activity (GUI) when a button in another activity is clicked, and how do you pass data between these two activities? --------------Solutions------------- Easy. [Re-ordered] Intent myIntent = new Intent

  • Can I select which Facebook accounts can log in using Facebook Connect? 2010-11-24

    For a website for our sports club, it would be interesting to let our users log in with their Facebook account. If I'm not mistaken, this requires Facebook Connect? But if I understand correctly, this would let all Facebook users log in to our site.

  • Error in starting new Activity 2010-12-07

    in my application i m showing List in side the Tabview , in one tab when ever i m trying to start a new activity on onclick a list view touch event . i want to start a new activity in web view . showNewsListView.setAdapter(listAdapter); showNewsListV

  • I can`t do any action on new activity 2010-12-11

    I am new to android. I would like to ask you some question. When I calling new activity from main activity by commands Intent myIntent = new Intent(v.getContext(), PolarView.class); //startActivityForResult(myIntent, 0); startActivityForResult(myInte

  • Android service connection leaked after starting new activity 2010-12-21

    I am trying to figure out why my service is leaking from my application. The official error I am getting is that the Service is not registered any longer. Here's what works: I create a service which creates a listener, when the listener is triggered

  • null pointer exception when starting new activity 2010-12-28

    Okay, I'm getting a null pointer exception when I start my third activity. Here is the LogCat message: 12-28 04:38:00.350: ERROR/AndroidRuntime(776): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.acithium.main/com.acithium.rs

  • Mapview start new activity when a baloonOverlay is clicked 2011-02-21

    Hi I have implemented a google map with projection points so when i click a point it opens up a balloon showing some information relating to it. I have used this github resource which makes it quite easier (thanks to Paul Sasik for guidance). What i

  • How do I display a single item in a new activity from a ListView of multiple items (Android) 2011-04-21

    If you have any knowledge of ListViews/RSS feeds/Android programming in general, please take a quick look at this question. Thanks! I have a ListView of multiple items(messages) that are listed in my NewsActivity as follows: public class NewsActivity

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.278 (s). 11 q(s)