My profileActivity wont start due to getting a NullPointer exception, I assume the problem is with   FirebaseUser user = firebaseAuth.getCurrentUser(); textViewUserEmail.setText("Welcome " + user.getEmail());`   and that email is Null but I cant understand why. Here is my code:  import com.google.firebase.auth.FirebaseAuth;   inside onCreate:  textViewUserEmail = (TextView) findViewById(R.id.textViewUserEmail);  firebaseAuth = FirebaseAuth.getInstance();  if (firebaseAuth.getCurrentUser() == null) {     finish();     startActivity(new Intent(this, Home.class)); }  FirebaseUser user = firebaseAuth.getCurrentUser(); textViewUserEmail.setText("Welcome " + user.getEmail());   Here is the log error:  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.liamthedeveloper.foodiez/com.liamthedeveloper.foodiez.ProfileActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.firebase.auth.FirebaseUser.getEmail()' on a null object reference                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988)                                                    at android.app.ActivityThread.-wrap14(ActivityThread.java)                                                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631)                                                    at android.os.Handler.dispatchMessage(Handler.java:102)                                                    at android.os.Looper.loop(Looper.java:154)                                                    at android.app.ActivityThread.main(ActivityThread.java:6682)                                                    at java.lang.reflect.Method.invoke(Native Method)                                                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)                                                 Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.firebase.auth.FirebaseUser.getEmail()' on a null object reference                                                    at com.liamthedeveloper.foodiez.ProfileActivity.onCreate(ProfileActivity.java:66)                                                    at android.app.Activity.performCreate(Activity.java:6942)                                                    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)                                                    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2880)                                                    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988)                                                     at android.app.ActivityThread.-wrap14(ActivityThread.java)                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631)                                                     at android.os.Handler.dispatchMessage(Handler.java:102)                                                     at android.os.Looper.loop(Looper.java:154)                                                     at android.app.ActivityThread.main(ActivityThread.java:6682)                                                     at java.lang.reflect.Method.invoke(Native Method)                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
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?
A subgroup of a cyclic group is cyclic - Understanding Proof I'm having some trouble understanding the proof of the following theorem  A subgroup of a cyclic group is cyclic  I will list each step of the proof in my textbook and indicate the places that I'm confused and hopefully somewhere out there can clear some things up for me.  Proof Let  G be a cyclic group generated by &quot;$a$&quot; and let H be a subgroup of G. If $H = {\{e\}}$, then $H \text{ = &lt;e&gt;}$ is cyclic. If $H \neq \space {\{e\}}$, then $a^n \in H$ for some $n \in \mathbb{Z}^{+}$. Let $m$ be the smallest integer in $\mathbb{Z}^{+}$ such that $a^m \in H$. We claim that $c = a^m$ generates H; that is, $$H \space = \space &lt;a^m&gt; \space = \space &lt;c&gt;.$$ We must show that every $b \in H$ is a power of c. Since $b \in H$ and $H \leq G$, we have $b = a^n$ for some $n$. Find $q$ and $r$ such that $$ n = mq + r \space \space \space \space for \space \space \space 0 \leq r &lt; m,$$  Alright this is the first part in the proof where I start to get confused. Where does the division algorithm come from and why are we using it? The proof continues as follows:  $$a^n = a^{mq + r} = (a^m)^q \cdot a^r,$$ so $$ a^r = (a^m)^{-q} \cdot a^n.$$ Now since $a^n \in H$, $a^m \in H$, and $H$ is a group, both $(a^m)^{-q}$ and $a^n$ are in $H$. Thus $$(a^m)^{-q} \cdot a^n \in H; \space \space \space \text{that is,} \space \space a^r \in H.$$  This is another point at which I’m a little confused. What exactly about $a^n$ and $a^m$ being elements of $H$ allows us to accept that $(a^m)^{-q}$ and $a^{n}$ are in $H$? The proof continues:  Since $m$ was the smallest positive integer such that $a^m \in H$ and $0$ $\leq r$ $&lt; m$, we must have $r = 0$. Thus $n = qm$ and $$b \space = \space a^n \space = \space (a^m)^q \space = \space c^q,$$ so b is a power of c.  This final step is confusing as well, but I think its just because of the previous parts I was confused about. Any help in understanding this proof would be greatly appreciated I had to backup a PostGIS model in a geopackage and I wonder how to load a non-spatial table, aka a table with NO geometry_column. The mediation package in R returns results in which:   Average Direct Effect (ADE) (the unmediated effect) is not statistically significant The Average Causal Mediated Effect (ACME) (the effect of the mediator alone) is positive and statistically significant The Total Effect (ADE+ACME) is larger than the ADE and ACME alone, positive and statistically significant   Does this indicate that the variable being mediated can only act through the mediator DV? I'm not quite certain as to how this would be interpreted.  Thank you for any help. PSTricks error "Undefined control sequence  \c@lor@to@ps" How variance is defined? The variance of a random variable $X$ is defined as $E[(x-\mu )^2]$. Why can't it be defined as $E[|x-\mu |]$. i.e., What is the basic idea behind this definition. Thank you. I have the following validation rule:  AND(  $Profile.Name &lt;&gt; 'System Administrator',  OR(  ISPICKVAL(PRIORVALUE(Level__c), "Archived"),  ISPICKVAL(PRIORVALUE(Level__c), "Closed")  )  )   This validation rule is on the opportunity object, and what I want to achieve is, if the picklist Level__c is either set to Archived or Closed, the opportunity record can only be edited by the System Administrator.  For some reason though, the validation rule also triggers, when I want to set the Level__c to Archived or Closed. But this is not what I want.   Any idea what's wrong with the validation rule? I want to clear the inputtext used to search, and clear all search results using a commandbutton. I tried the following on the 'Reset' button I added but it only clears the inputtext and the search results are not clearing.  &lt;apex:pageBlockSectionItem &gt;                     &lt;apex:outputPanel layout="block" Rendered="true"&gt;                     &lt;apex:inputText value="{!ReportSearchString}" /&gt;                     &lt;apex:commandButton value="Search" action="{!searchReports}" reRender="ReportSearchResults, "/&gt; &amp;nbsp;&amp;nbsp;                      &lt;apex:commandButton value="Back" action="{!BackToCreateFeedPage}"/&gt;&amp;nbsp;                     &lt;apex:commandButton value="Reset" onclick="this.form.reset();return false;"/&gt;                     &lt;/apex:outputPanel&gt;                 &lt;/apex:pageBlockSectionItem&gt;                             &lt;/apex:pageBlockSection&gt;                         &lt;apex:pageBlockSection id="ReportSearchResults"&gt;                 &lt;apex:outputText value="{!warningMessage}" rendered="{!!showTable}" /&gt;                 &lt;apex:pageBlockTable value="{!reportList}" var="item" rendered="{!showTable}"&gt;                     &lt;apex:column headerValue="Report Name" &gt;                         &lt;apex:commandLink value="{!item.Name}" action="{!BackToCreateFeedPage}"&gt;                             &lt;apex:param value="{!item.Id}" name="SelectedReport" assignTo="{!selectedReportId}" /&gt;                         &lt;/apex:commandLink&gt;   This is my search function, it works fine. I need to clear the results of this search on clicking 'Reset' button.   public void searchReports()     {         showTable = false;               reportList = new List&lt;Report&gt;();          reportSearchResult = new Map&lt;Id, Report&gt;();          selectedReport = new Report();         if((ReportSearchString != null &amp;&amp; ReportSearchString != '') &amp;&amp; ReportSearchString.length() &gt;= 3)         {             reportSearchResult = new Map&lt;Id, Report&gt;([Select Id, Name From Report Where Name Like :'%'+ReportSearchString+'%' limit 2000]);              warningMessage = 'No Result Found';         }         else         {             warningMessage = 'Search text should have atleast 3 characters';         }     } How to generate a random alpha-numeric string I've been looking for a simple Java algorithm to generate a pseudo-random alpha-numeric string.  In my situation it would be used as a unique session/key identifier that would "likely" be unique over 500K+ generation (my needs don't really require anything much more sophisticated).    Ideally, I would be able to specify a length depending on my uniqueness needs. For example, a generated string of length 12 might look something like "AEYGF7K0DM1X". Computing the Galois group of polynomials $x^n-a \in \mathbb{Q}[x]$ "Lunch" vs. "dinner" vs. "supper" — times and meanings? I've seen cases where a noon-time meal is referred to as dinner, and the evening meal is called supper. There's also lunch around noon followed by dinner in the evening. Is there a particular difference between dinner and supper, or a circumstance where lunch becomes dinner? I shall assume that the sun is at rest, so before the half mass disappear, the orbit of earth is an ellipse. Boundary Question in $\mathbb{R}^{2}$ (Manifolds) I live in Hong Kong, and the Play Store displays everything in the local Cantonese language. I have set everything I can (Android language, Account language, even the app locale via Xposed Module "App Settings") to English, but I still see all the categories in the store in Chinese. Can someone help me change those to English?  (Click image to enlarge) Format SQL in SQL Server Management Studio In Visual Studio &amp; other IDEs, you can easily auto format your code with a keyboard shortcut, through the menu, or automatically as you type.  I was wondering if there is yet a way to enable this standard feature in SQL Server Management Studio?  I'm working with some large-ish stored procs that are a mangled mess of poorly formatted SQL and it'd be nice if I could just go "Select All -> Format SQL" UITableView cells strangely disappearing Why is the covariant derivative of the metric tensor zero? In addition to the .tex and .dvi or .pdf files, TeX/LaTeX/ConTeXt produces and uses lots of other files. What do they do? Which ones are used to create the document and which ones are automatically created by the compiler. What files can I safely delete? When does Bleeding Attack effect apply? I've designed for a campaign a duo of rogues. My character is as , and his follower is a Knife Mistress. Couple of question about them. Our party is about to ambush several . My Sniper will hide near their camp, and shoot the weakest one when fight begins. His follower will then rush the troll and slice him in several pieces. My Sniper has the Bleeding attack feat:  Bleeding Attack (Ex) Benefit: A rogue with this ability can cause living opponents to  by hitting them with a sneak attack. This attack causes the target to take 1 additional point of damage each round for each die of the rogue's sneak attack (e.g., 4d6 equals 4 points of bleed). Bleeding creatures take that amount of damage every round at the start of each of their turns. The bleeding can be stopped by a DC 15 Heal check or the application of any effect that heals hit point damage.  Emphasis mine. Thus, a normal enemy would bleed every turn, until he get cleaned of the bleeding effect. However, troll have a special ability, which is  5 (acid/fire)  Regeneration (Ex) A creature with this ability is difficult to kill. Creatures with regeneration heal damage at a fixed rate, as with , but they cannot die as long as their regeneration is still functioning (although creatures with regeneration still fall unconscious when their hit points are below 0). Certain attack forms, typically fire and acid, cause a creature’s regeneration to stop functioning on the round following the attack. During this round, the creature does not heal any damage and can die normally. The creature's descriptive text describes the types of damage that cause the regeneration to cease functioning.  So, the troll will automatically get rid of the bleeding effect during his first turn. My question is: Does the bleeding effect apply before the regeneration, or get neglected, because the troll will heal during his turn? Am I right to assume that, Bleeding attack effect getting triggered at the beginning of the troll turn, it will deal him the damages before the wounds heals? Screen brightness isn't taking effect on a Lenovo Z570 My Lenovo Z570 has two GPU's, nVidia and Intell. Brightness control has no effect what so ever over the screen brightness, and because I've had some major issues in the past when I was trying to fiddle with nVidia drivers and settings, and I wanna be cautious now. I haven't find similar questions referring 14.04 LTS with similar configuration as mine.   I've read that it could be fixed by adding/changing content in xorg.conf but when I run  sudo gedit /etc/X11/xorg.conf   the file comes out to be absolutely empty. What do I need to do, what do I need to add to it and not get my laptop screwed with a black screen again? passthrough graphics card to virtualbox So I'm trying to get my laptops NVIDIA fx 880m to pass to a virtual box running window seven on a linux mint 17 install.  So far everything seems to be (maybe) heading in the right direction:  the device passed through happily, when I booted the virtual box it installed a bunch of new drivers, but when I try to install the NVIDIA driver on the guest it can't find the card. I looked under the device manager and there's no listing for the nvidia card under the pci bus, my guess would be that I need to disable it in the host so that it can be passed through to the guest (the virtual box manual said they can't be shared) but I'm not sure how to do so. Can anybody help with this? This question does not seem to me to be a duplicate of , because here the given solution was that it was not possible with a windows host, however in this case the host is linux