Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing Access_Token from one activity to another
    text
    copied!<p>I want to achieve the simple task of having the user go through Facebook SSO process on the first activity and having their name display on the second activity. Here's my code.</p> <p>Snippet from First Activity (Bundle made to pass token)</p> <pre><code>if (access_token != null) { facebook.setAccessToken(access_token); Intent newPage = new Intent( PreLogin.this, PostLogin.class); Bundle tokenBundle = new Bundle(); tokenBundle.putString("token", facebook.getAccessToken()); newPage.putExtras(tokenBundle); startActivity(newPage); </code></pre> <p>Second Activity On Create method</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.postlogin); myName = (TextView) this.findViewById(R.id.tv_name); Bundle tokenBundle = getIntent().getExtras(); String access_token = tokenBundle.getString("token"); facebook.setAccessToken(access_token); mAsyncRunner = new AsyncFacebookRunner(facebook); mAsyncRunner.request("me", new IDRequestListener()); } </code></pre> <p>Second Activity IDRequestListener Method</p> <pre><code>private class IDRequestListener implements RequestListener { @Override public void onComplete(String response, Object state) { try { JSONObject json = Util.parseJson(response); final String name = json.getString("name"); PostLogin.this.runOnUiThread(new Runnable() { public void run() { myName.setText("Welcome: " + name); } }); } catch (JSONException e) { } catch (FacebookError e) { } } @Override public void onIOException(IOException e, Object state) { Log.w("WARNING", "IOException"); } @Override public void onFileNotFoundException(FileNotFoundException e, Object state) { } @Override public void onMalformedURLException(MalformedURLException e, Object state) { } @Override public void onFacebookError(FacebookError e, Object state) { } } </code></pre> <p>My textview does not get changed and when the program comes into the IDRequestListener method it gets the exception where I wrote to the log. Any suggestions for why the run() method does not get called?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload