I am currently working on an Android app with Android Studio. I followed a Tuto to add the facebook login functions with picture and username . Then I created a new Activity once the Login is successful. But when I start the app, the app crash within 5 seconds with the message Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference  Main activity :  public class MainActivity extends AppCompatActivity {  @Override protected void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     setContentView(R.layout.activity_main);      Bundle inBundle = getIntent().getExtras();      String name = inBundle.get("name").toString();     String surname = inBundle.get("surname").toString();     String imageUrl = inBundle.get("imageUrl").toString();       if (AccessToken.getCurrentAccessToken() == null) {         TextView nameView = (TextView)findViewById(R.id.nameAndSurname);         nameView.setText("" + name + " " + surname);         new DownloadImage((ImageView)findViewById(R.id.profileImage)).execute(imageUrl);          goLoginScreen();     } }  private void goLoginScreen() {     Intent intent = new Intent(this, LoginActivity.class);     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);     startActivity(intent); }  public void logout(View view) {     LoginManager.getInstance().logOut();     goLoginScreen(); }   Activity_main.xml :  &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="tech.alvarez.androidfacebooklogin.MainActivity"&gt;   &lt;TextView     android:id="@+id/nameAndSurname"     android:layout_width="77dp"     android:layout_height="wrap_content"     android:layout_above="@+id/profileImage"     android:layout_centerHorizontal="true"     android:layout_gravity="center_horizontal"     android:layout_marginBottom="-143dp"     android:textSize="22dp"     android:textStyle="bold" /&gt;  &lt;ImageView     android:id="@+id/profileImage"     android:layout_width="87dp"     android:layout_height="101dp"     android:layout_alignParentBottom="true"     android:layout_centerHorizontal="true"     android:layout_gravity="center_horizontal"     android:layout_marginBottom="190dp" /&gt; &lt;Button     style="@style/Widget.AppCompat.Button.Colored"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignParentBottom="true"     android:layout_centerHorizontal="true"     android:onClick="logout"     android:text="@string/logout" /&gt;
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
When is "self" required? What is exactly the density of a black hole and how can it be calculated? How do I shuffle cards for a card game? I am trying to develop an card game for Android Can anyone suggest me how to write code for effectively shuffling the playing cards? Password protect folder without disk images? Is this possible? I know you can protect a .dmg file, but is there a more convenient solution, by using a third party application? How to remove app which is greyed out, can't be deleted, won't open and doesn't appear in apps list? I have this app with a greyed out icon which I'm trying to delete.    I tap and hold, and it asks me if I want to delete it and its data. I confirm and nothing happens.  I try to open it and nothing happens.  I go to Settings>General>Usage and it's not in the list.  I reboot the device and it's still here.  Is there another way to force deletion of this (ghost) app? Is it possible to skip releases during an upgrade? Possible Duplicate:          Is it possible to upgrade a 10.04 lucid installation to 11.04 Natty, without upgrading to 10.10 first? What about other versions? "Two are better than one" or "Two is better than one"? I just came across the phrase "Two are better than one", but I had always heard it in my head as "Two is better than one". This is partially due to the Boys Like Girls song. Which one of these is actually correct? $C^1[a,b]$ is closed in $C[a,b]$ Regex match entire words only I heard the following dialog in a British English movie:     Words go round quick. All the little tongues go clack, clack, clack.   What does this mean, and why was the word "quick" used instead of "quickly"? Closed form for $ \int_0^\infty {\frac{{{x^n}}}{{1 + {x^m}}}dx }$ I've been looking at  $$\int\limits_0^\infty  {\frac{{{x^n}}}{{1 + {x^m}}}dx }$$  It seems that it always evaluates in terms of $\sin X$ and $\pi$, where $X$ is to be determined. For example:  $$\displaystyle \int\limits_0^\infty  {\frac{{{x^1}}}{{1 + {x^3}}}dx = } \frac{\pi }{3}\frac{1}{{\sin \frac{\pi }{3}}} = \frac{{2\pi }}{{3\sqrt 3 }}$$  $$\int\limits_0^\infty  {\frac{{{x^1}}}{{1 + {x^4}}}dx = } \frac{\pi }{4}$$  $$\int\limits_0^\infty  {\frac{{{x^2}}}{{1 + {x^5}}}dx = } \frac{\pi }{5}\frac{1}{{\sin \frac{{2\pi }}{5}}}$$  So I guess there must be a closed form - the use of $\Gamma(x)\Gamma(1-x)$ first comess to my mind because of the $\dfrac{{\pi x}}{{\sin \pi x}}$ appearing. Note that the arguments are always the ratio of the exponents, like $\dfrac{1}{4}$, $\dfrac{1}{3}$ and $\dfrac{2}{5}$. Is there any way of finding it? I'll work on it and update with any ideas.    UPDATE:  The integral reduces to finding   $$\int\limits_{ - \infty }^\infty  {\frac{{{e^{a t}}}}{{{e^t} + 1}}dt} $$  With $a =\dfrac{n+1}{m}$ which converges only if   $$0 &lt; a &lt; 1$$  Using series I find the solution is     $$\sum\limits_{k =  - \infty }^\infty  {\frac{{{{\left( { - 1} \right)}^k}}}{{a + k}}} $$ update-alternatives --install says it needs link name path priority? I typed:  sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/ jdk1.8.0/bin/java" 1   It's says alternatives --install needs link name path priority Why does the question's closed status disappear when clicking to load a new edit? Proof of $\sin nx=2^{n-1}\prod_{k=0}^{n-1} \sin\left( x + \frac{k\pi}{n} \right)$ I have seen this identity on Wolfram mathworld and in a comment to another similar trigonometric proof:    I can't seem to find a proof to this identity online anywhere. What method is used to prove this? How do I delete my commands quickly? I use terminal for almost all tasks. Let's say I have entered a huge command like this:  sudo a-huge-command   What is the easiest way to delete the whole command with a single shortcut, rather than keep on hitting backspace key?  I'm a Ubuntu newbie looking to use Ubuntu in a professional way. Story about space explorers who communicate but then decide they must destroy each other I'm looking for a sci-fi story or novel from many years ago where a deep space explorer encounters an alien explorer. The explorers learn to communicate; but on parting, each decides to destroy the other in order to protect his own world. Does a log transform always bring a distribution closer to normal? I have a highly right skewed data set with a large range of values (from 1 ~ 10^6) (can't share the actual data for work related reasons).   When I plot the log of the data instead, the distribution looks a lot more like a normal distribution.   Have I stumbled on a meaningful insight in the data set, or is just a general property of the log transform that it brings the distribution closer to normal? Calculate probability (area) under the overlapping area of two normal distributions When I go to , my tablet is listed, but not my phone. I had signed up just as soon as ADM was available, and at that time both devices were listed. Now, for the last several days, I can only see my tablet. (For what it's worth, both devices appear in the "My Devices" section of the Google Play Store.)  I have done the following while troubleshooting:   Ensured that the Android Device Manager settings in Google Settings are both on. I have even toggled them off and back on again Ensured that Location Services are on Ensured that all sync services for my account are toggled on and work Have connected to the Play Store several different times Ensured Google Play Services is at the latest version Made sure I'm using the right account. (In fact, I removed the other secondary accounts from the phone) Power-cycled the phone several different times   I could understand if ADM couldn't find the phone due to it being off, out of range, poor signal, etc., but ADM would at least display the phone and tell me it couldn't find it.  So, any suggestions to get my phone to show up on Android Device Manager?  I would like this to be working before something happens to the phone. ( and all that.)  Although it shouldn't make any difference:   Tablet: Nexus 7 (2012) with Android 4.3 Phone: Verizon Galaxy Nexus with Android 4.2.2   Addendum:  There's apparently some (relatively new) advice on the :   Open  Google Settings from your device's apps menu. Touch Android Device Manager. Uncheck Allow remote factory reset. Go to your device's main Settings menu, then touch Apps > All > Google Play services. Touch Clear Data. Note that this action doesn't remove personal data. Go back to Google Settings and select Allow remote factory reset. Restart your device.   I have followed these steps, but it doesn't appear to have worked. What is the best way to unit test a method that calls into multiple methods, for example:  modify(string value) {     if(value.Length &gt; 5)  replaceit(value);      else changeit(value); }   This pseudo code has a modify method that (currently) calls either replaceit() or changeit(). I have already wrote tests for replaceit and changeit, so writing a new test for modify will be 99% the same set of code.  I need to test it thought because it may change in the future.    So do I copy paste the existing test code?  Move the test code to a common function?  Any other ideas?  I'm not sure of the best practice here.