I am creating a feedback app where the user rates a service from 1-5 and I display the average of all the user's ratings (till date) on the next page. The average rating is coming out to be fine but I am not able to fetch the total number of users from snapshot that have rated on the app till now. Here is the code - public class Score extends AppCompatActivity {      TextView avgScore;     TextView totalUsers;     double userCount;     DatabaseReference dbRef;       @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         requestWindowFeature(Window.FEATURE_NO_TITLE); //will hide the title         getSupportActionBar().hide(); // hide the title bar         this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,                 WindowManager.LayoutParams.FLAG_FULLSCREEN); //enable full screen         setContentView(R.layout.score);         avgScore = findViewById(R.id.textView2);         dbRef = FirebaseDatabase.getInstance().getReference().child(&quot;Users&quot;);         scoreRealTime();     }      public void scoreRealTime() {         dbRef.addValueEventListener(new ValueEventListener() {             @Override             public void onDataChange(@NonNull DataSnapshot snapshot) {                 double total = 0;                 for (DataSnapshot ds : snapshot.getChildren()){                     UserHelper helper = ds.getValue(UserHelper.class);                     double values = Double.parseDouble(String.valueOf(helper.rating)); //                  double values = Double.parseDouble(ds.child(&quot;rating&quot;).getValue().toString());                     total = total + values;                     userCount = snapshot.getChildrenCount();                 }                 double average = (double) total / snapshot.getChildrenCount();                 avgScore.setText(String.format(&quot;%.2f&quot;, average));                 //System.out.println(userCount);                 totalUsers.setText((int) userCount); //error occurs here             }              @Override             public void onCancelled(@NonNull DatabaseError error) {             }         });     } }  This is the error log - E/AndroidRuntime: FATAL EXCEPTION: main     Process: com.example.feedback, PID: 26338     java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(int)' on a null object reference         at com.example.feedback.Score$1.onDataChange(Score.java:60)         at com.google.firebase.database.core.ValueEventRegistration.fireEvent(ValueEventRegistration.java:75)         at com.google.firebase.database.core.view.DataEvent.fire(DataEvent.java:63)         at com.google.firebase.database.core.view.EventRaiser$1.run(EventRaiser.java:55)         at android.os.Handler.handleCallback(Handler.java:883)         at android.os.Handler.dispatchMessage(Handler.java:100)         at android.os.Looper.loop(Looper.java:214)         at android.app.ActivityThread.main(ActivityThread.java:7356)         at java.lang.reflect.Method.invoke(Native Method)         at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)  EDIT: Also, it would be really great if you could explain why the NullPointerException is occurring here or occurs in general. Thanks.
129
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?
47942
With reference to the question , when reviewing in SO, we have to refresh the page every now and then to view the newly added entries to the review queue.  However, votes and reputation are updated on the display as soon as a vote is cast, and as soon as reputation changes. Is it possible to integrate this kind of feature to see the number of pending entries in the review queues page.  This request is probably not a duplicate of , where the feature is requested for a counter in front of the title of the page. But, my question adresses the .
66234
I want to see who has the highest score in a specific tag (for example c#) in my country. Is there any query or script for that? I've found , but it doesn't work. Can any one take a look at it and see what's its problem? I also have found  which does similar, however gets users which only have a tag badge.
72615
I have to calculate the sum of related child object(contact) on field (Score1__c and Score2__c) to parent object Account object field(AccountScore1__c and AccountScore2__c)  my code is working on insert update undelete but not working with ****delete**** event  trigger ContactScoreRollup on Contact (after insert,after update,after undelete,Before Delete) {     Set&lt;Id&gt; accountIds = new Set&lt;Id&gt;();     List&lt;Account&gt; accountsToUpdate = new List&lt;Account&gt;();     List&lt;Account&gt; accountsToUpdate1 = new List&lt;Account&gt;();     if(trigger.isinsert || trigger.isundelete || trigger.isupdate){         for(Contact con :Trigger.new){             accountIds.add(con.AccountId);         }     }     if(Trigger.isdelete || Trigger.isupdate){         for(contact con : Trigger.old){             accountids.add(con.Accountid);         }         accountIds.remove(null);     }      for(AggregateResult ar :[SELECT AccountId,SUM(Score1__c) sumammount1 FROM Contact  where AccountId in: accountIds  GROUP BY AccountId]){          accountsToUpdate.add(new Account(Id = (Id)ar.get('AccountId'),AccountScore1__c= (Decimal)ar.get('sumammount1') ));     }      for(AggregateResult arr :[SELECT AccountId,SUM(Score2__c) sumammount2 FROM Contact  where AccountId in: accountIds  GROUP BY AccountId]){          accountsToUpdate1.add(new Account(Id = (Id)arr.get('AccountId'),Account_Score2__c= (Decimal)arr.get('sumammount2') ));     }     update accountsToUpdate;     update accountsToUpdate1; }
68495
I am getting this error:     SObject row was retrieved via SOQL without querying the requested   field: Contact.Account   Controller:  public class WrapperAccountCtrl {      public List&lt;Account&gt; acclist{get;set;}     public List&lt;Contact&gt; conlist{get;set;}      public List&lt;MyWrapper&gt; wap{get;set;}      public WrapperAccountCtrl()      {         acclist=[Select id,name from Account];          conlist=[Select id,name,AccountID  from contact where AccountID IN:acclist];          system.debug('Size----'+conlist.size());           wap=new List&lt;MyWrapper&gt;();           for(integer i=0;i&lt;acclist.size();i++)          {              wap.add(new MyWrapper(conlist,acclist[i]));          }     }      public class MyWrapper     {          public Account accn{get;set;}          public List&lt;Contact&gt;conrec{get;set;}          public MyWrapper(List&lt;Contact&gt; con,Account acc)         {             accn=acc;             conrec=con;             }     } }   VF Page:  &lt;apex:page controller="WrapperAccountCtrl" sidebar="false"&gt;       &lt;apex:form &gt;          &lt;apex:pageBlock &gt;              &lt;apex:pageBlockTable value="{!conlist}" var="c"&gt;                  &lt;apex:column value="{!c.account.Name}"/&gt;              &lt;/apex:pageBlockTable&gt;          &lt;/apex:pageBlock&gt;      &lt;/apex:form&gt;  &lt;/apex:page&gt;
77258
Once you already have a gold badge for a queue, the number of total reviews is hard to keep track of where you're at. I'd like to see how many reviews I've done so far today in the queue. For example, if I've already done 16 out of my 20 possible, show that.   I don't care whether it's a bar graph, just text, tally marks, etc.  It'd be nice to show this info, so it can maybe motivate people to complete all their reviews for the day, and give the user a status of where they are at for the day. I suggest implementing this in all queues, for all users, whether gold badge or not in the queue.
67251
Trying to , I'm getting questions with more views than asked for.  For example, I tried to search for views:1..5 on CrossValidated, but I'm getting results with more views:    But the  actually has 117 views at the time of writing.
60303
I searched everywhere and while there are guides none say what to do if a step wont work, so this isn't a duplicate as far as I know. If it is I'll take this down but PLEASE read the full question first.  I used .  So I do sudo pm-hibernate and then my screen goes to the hibernate screen say:     snap-shoting   snapshot done   writing(or something like that)____0%   and then hangs there forever. My swap is seen and is 9GB, I have 6GB RAM. It is a dual boot with Windows 7.
22206
Another part of my daily  on SE sites.  When viewing a question and it's time to move on, I'll often simply click one of the tags in the question to bring me back to a list of questions with that tag.  This doesn't work in the Android app.  Obligitory screenshot.  I tried to draw a finger that looked like it was tapping a tag, but it ended up looking like, well...  something else, let's say.
75712
Accessing the full review history is a privilege for 10 k users but, statistics for individual reviews can be viewed by everybody ( ).  These review summaries can be somewhat useful for different aspects, such as understanding what happened to a review item that you initiated, e.g., if your close vote remained the only one on a question, you can only guess by the elapsed time whether nobody else has reviewed it or whether the review is finished with everybody disagreeing. Or you can see who performed a disputed review decision and discuss it.  My question now is: Is there any way to acess these review summaries or obtain the review ID – which would allow to find these summaries – for a particular review task?  I am aware that the above information, in particular the reviewer identity, can be abused and it may therefore be undesirable that everybody can find this information. But then, at least on small sites, it’s quite possible to obtain the review ID from guessing. Also, I can access the review summary for every review that I participated in or even skipped from my review history and the review summary for every successful edit from the edit history.
110938
I very recently earned the below badge. But I am sorry, I do not understand it.    It says      Earned at least 100 total score for at least 20 answers in the java tag.   But I have answered 140 questions under Java tag and pretty sure would have earned more than 100 points. Then why did I receive it so late. Currently I have 3.3K points on SO.  Secondly if so, I have answered about 41 questions under Scala tag, then why didn't I receive this badge for Scala?
97327
I am using ArcGIS 9.3 and python 2.5. My code is shown at the bottom of this post.  I have a raster containing fire intensity information at 200m cell resolution. I run the script and the first count cell part returns the size of the fire. This works fine.  I then clip the raster using a polygon representing a forested catchment. The new raster represents the area of the catchment that is burnt. When I try to use the same code to count the number of cells of the new raster, it always gives me an answer of zero, even if there is definitely a raster created by the clip tool.  I have tried every combination of every tool I can think of.  my code...      fire = str(ignitionID) + "_" + str(weatherID) + "_Intensity.asc"     print "fire: " + fire      # ---------------------------------------------------------------------------     # this section calculates the size of the fire for model calibration purposes     # ---------------------------------------------------------------------------      # Process: Build Raster Attribute Table...     the_fire = input_fires + fire     shutil.copy(the_fire, "C:\\FIRESTORM\\Workspace") # copy the fire to workspace     the_fire = "C:\\FIRESTORM\\Workspace\\" + fire      try:       gp.BuildRasterAttributeTable_management(the_fire, "NONE")       resultf = gp.GetCount_management(the_fire)  # count num of rows in raster       countf = int(resultf.GetOutput(0))       fire_area = countf * 4  # each cell has an area of 4 ha       print "the fire area = " + str(fire_area) + " ha"      except:  # the attribute table cannot be created coz the fire is too large        fire_area = 300000 # default value for large fires 300000 ha       print "the fire area EXCEEDS 262,140 ha"      # -----------------------------------------------------------------------------     # this section calculates the area of the catchments that are burnt by the fire     # -----------------------------------------------------------------------------      # Local variables...     catch_extent = input_catch + "WS_Catchment_region.shp"  # catchment boundary     fire_raster = "C:\\FIRESTORM\\Workspace\\fire_raster"     fire_ascii = the_fire     Output_raster = "C:\\FIRESTORM\\Workspace\\Extract_ASCI1"     Output_ASCII = "C:\\FIRESTORM\\Workspace\\rastert_extract1.asc"     catch_burn_area = 0  # reset catchment burn area      # Process: ASCII to Raster...     gp.ASCIIToRaster_conversion(fire_ascii, fire_raster, "INTEGER")      # Process: Define Projection... based on projection of catch_extent     desc = gp.Describe(catch_extent)     spatialRef = desc.SpatialReference     gp.DefineProjection_management(fire_raster, spatialRef)      # Process: Extract by Mask...     gp.ExtractByMask_sa(fire_raster, catch_extent, Output_raster)      # Convert raster to ascii     gp.RasterToASCII_conversion(Output_raster, Output_ASCII)      # Process: Build Raster Attribute Table...     gp.BuildRasterAttributeTable_management(Output_ASCII, "OVERWRITE")      # count number of rows in raster     resulti = gp.GetCount_management(Output_ASCII)     counti = int(resulti.GetOutput(0))     catch_burn_area = counti * 4  # each cell has an area of 4 ha      print "catchment area burnt = " + str(catch_burn_area) + " ha"
11494
App version 1.0.27  If you the notification pane and click on the loading icon while it's spinning, the app will cause the app to crash.  03-26 22:51:08.331 E/AndroidRuntime(5927): FATAL EXCEPTION: main 03-26 22:51:08.331 E/AndroidRuntime(5927): java.lang.ArrayIndexOutOfBoundsException: length=0; index=-1 03-26 22:51:08.331 E/AndroidRuntime(5927): at java.util.ArrayList.get(ArrayList.java:310) 03-26 22:51:08.331 E/AndroidRuntime(5927): at com.stackexchange.marvin.ui.BaseActivity$3.onItemClick(BaseActivity.java:266) 03-26 22:51:08.331 E/AndroidRuntime(5927): at android.widget.AdapterView.performItemClick(AdapterView.java:298) 03-26 22:51:08.331 E/AndroidRuntime(5927): at android.widget.AbsListView.performItemClick(AbsListView.java:1100) 03-26 22:51:08.331 E/AndroidRuntime(5927): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2788) 03-26 22:51:08.331 E/AndroidRuntime(5927): at android.widget.AbsListView$1.run(AbsListView.java:3463) 03-26 22:51:08.331 E/AndroidRuntime(5927): at android.os.Handler.handleCallback(Handler.java:730) 03-26 22:51:08.331 E/AndroidRuntime(5927): at android.os.Handler.dispatchMessage(Handler.java:92) 03-26 22:51:08.331 E/AndroidRuntime(5927): at android.os.Looper.loop(Looper.java:137) 03-26 22:51:08.331 E/AndroidRuntime(5927): at android.app.ActivityThread.main(ActivityThread.java:5103) 03-26 22:51:08.331 E/AndroidRuntime(5927): at java.lang.reflect.Method.invokeNative(Native Method) 03-26 22:51:08.331 E/AndroidRuntime(5927): at java.lang.reflect.Method.invoke(Method.java:525) 03-26 22:51:08.331 E/AndroidRuntime(5927): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 03-26 22:51:08.331 E/AndroidRuntime(5927): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 03-26 22:51:08.331 E/AndroidRuntime(5927): at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:126) 03-26 22:51:08.331 E/AndroidRuntime(5927): at dalvik.system.NativeStart.main(Native Method)   (Think I should calm down on finding bugs for a little while? :P)
50953
I'm a tad confused about the number that appears next to the tag score and tag in my profile. It says I'm at 202 (which would be eligible for the badge), but when I hover over it, I see the following information:    Unless math has changed recently, 31 and 158 do not add up to 202. So where did this number even come from? The only thing I can think of is that deleted posts are being included in that count, but why? Why would my questions even be included in that count?  Considering that the tag score at the left only includes your score from answers, why does the count at the right not also only include answers? Consistency here is out of whack. I like being able to hover over it to see the full details, but the number there should be 158, because my score of 1k is from those 158 answers, not from the questions or the deleted posts (I presume).  Note: This is not a caching issue since I have had no reputation changes on my account since the tag score recalculations at 03:00 UTC, at the time of taking that screenshot.
123622
How how do I query recent account views and group by LastViewedDate    SELECT Id, Name                 FROM Account                ORDER BY Name DESC limit 10 FOR VIEW   I used to have it like this, but my test case is keep failing  SELECT SELECT Id, Name, LastModifiedDate                         FROM account                         WHERE LastModifiedDate !=null ORDER BY LastViewedDate DESC limit 10  static testmethod void testOppExt_TestMethod(){        Opportunity testOpp = new Opportunity(Name = 'TestOpp', StageName='Test', CloseDate = Date.today());       insert testOpp;        Account testAcc = new Account(Name = 'Test Account');       insert testAcc;        Contact con = new Contact(LastName='Test',AccountId=testAcc.id);       insert con;        Test.startTest();       OppExt testCon = new OppExt();       Contact conn = testCon.contact;       Account  Accn = testCon.acc;       Test.stopTest();     }   Error Message   Component Errors API Name Type Line Column Error Message 0 0 , Details: Average test coverage across all Apex Classes and Triggers is 0%, at least 75% test coverage is required. 0 0 SiteRegisterControllerTest.null(), Details: line -1, column -1: Previous load of class failed: oppext null 0 0 SiteLoginControllerTest.null(), Details: line -1, column -1: Previous load of class failed: oppext null 0 0 SiteRegisterController.null(), Details: line -1, column -1: Previous load of class failed: oppext null 0 0 testnewOpportunityController.null(), Details: line -1, column -1: Previous load of class failed: oppext null 0 0 SiteLoginController.null(), Details: line -1, column -1: Previous load of class failed: oppext null 0 0 testOppExt.null(), Details: line -1, column -1: Previous load of class failed: oppext null 0 0 OppExt.null(), Details: line 32, column 17: No such column 'LastViewedDate' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. null
48562
So when we view reputation, there is graph view. However, it seems to be off by a day. Here's what I mean:   I'm sure 70 + 20 + 15 is not 15. Its 105, which is what we see below:   And 40 + 10 is NOT 105, unless you did  :)     Anyways 40 + 10 is 50:   So yeah. Did you do what that post on codegolf says? Devs better fix that :)
77514
I'm trying to get the count of child of a parent row. The sql query I'm using as follow only pulls the immediate count, how can I get total count as childs can have more childs.  select  c.id, c.base32_id, c.author, c.message, c.title, c.type, c.datetime, (select count(*) from comment where parent_id= c.id ) as ChildCount from comment c where c.parent_id is null order by id asc limit 25