Okay so I am using this GPS location from  and I keep getting Null Object reference and not sure why.Here is my code:   boolean permissionGranted = ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED;      if(permissionGranted)     {         if (GPS.sharedInstance(AppDashboard.this).canGetLocation() &amp;&amp; GPS.sharedInstance(this).isPermissionEnabled()) {             double lat = GPS.sharedInstance(AppDashboard.this).getLatitude();             double lon = GPS.sharedInstance(AppDashboard.this).getLongitude();             Log.e(TAG, "Location: " + lat + "/"+ lon);         }         else         {             Log.e(TAG, "Can't get GPS locations");         }     } else {         ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 200);     }   My Manifest:  &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt; &lt;uses-feature android:name="android.hardware.location.gps" /&gt;   My Logcat:  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'double android.location.Location.getLatitude()' on a null object reference at com.gpsApp.utility.GPS.getLatitude(GPS.java:113)   And GPS Class 113  public double getLatitude() {     if (_locationManager != null) {         _latitude = _location.getLatitude();     }      return _latitude; }
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?
Do I have to worry about copyright issues for code posted on Stack Overflow? I was wondering about the copyright of code snippets from answers. Let's say you ask a question and the solution consists of ten lines of code, which are given in an answer. Are there any restrictions about the use of that code?   It seems that the content of this page is under the . So does one have to attribute the author if code is used in an open source project? Can it be legally used in closed source projects at all?  I guess ten lines of code are not really problematic, but is there a critical number of lines? How to calculate the distribution of the minimum of multiple exponential variables? $X_1$, $X_2$, $X_3$ are independent random variables, each with an exponential distribution, but with means of $2.0, 5.0, 10.0$ respectively. Let $Y$= the smallest or minimum value of these three random variables. Derive and identify the distribution of $Y$. (The distribution function may be useful).    How do I solve this question? Do I plug in each mean to the exponential distribution? I would appreciate it if someone could explain this to me, thanks. What is the use of the square brackets [] in sql statements? Should a "thank you" comment, for instance Thanks for your answer, be flagged as non-constructive?  If a "thank you" comment is flagged as non-constructive what would the moderator reaction to this flag be? Would it be marked as helpful, or not? Identifying Unused Stored Procedures This next year, I am helping an effort to clean several SQL Server environments.    We have about 10,000 stored procedures and estimate that only about 1000 of them are used on a regular basis, and another 200 or so are used on a rare occasion, meaning we have a lot of work to do.    Since we have multiple departments and teams that can access these databases and procedures, we are not always the ones calling the procedures, meaning that we must determine what procedures are being called.  On top of that, we want to determine this over a few months, not in a few days (which eliminates some possibilities).  One approach to this is to use the SQL Server Profiler and track what procedures are being called and compare them to the list of what procedures we have, while marking whether the procedures are used or not.  From then, we could move the procedures to a different schema in case a department comes screaming.  Is using the Profiler the most effective approach here?  And/Or have any of you done something similar and found another way/better way to do this? Why did they make another prequel? Star Trek: Discovery, the first new Star Trek television series in 12 years, debuted last week.  As with a number of recent Star Trek efforts, this is a prequel to the Original Series, occurring roughly one decade prior chronologically.    The Original Series, the Next Generation, Deep Space Nine, and Voyager occur in a chronological sequence that, generally speaking, moves forward (although TNG, DS9, and Voyager overlap to various degrees).  The linear trajectory of Star Trek productions took a sudden shift with the television series Enterprise, which was set just over 100 years before TOS. This was followed by J.J. Abrams' 2009 film Star Trek, which created a new timeline and which followed the characters from TOS, but at a time that is also chronologically one decade before TOS.  Given that the last few interpretations of Star Trek were prequels in one sense or another, I was disappointed that Discovery was yet another prequel.  I'd like to know why the showrunners decided to take this direction.  I haven't been able to find any statements about the rationale.    That being said, I find it interesting that Star Trek (2009) was set in 2255-2258 and Discovery is currently set in 2256, even though they are ostensibly in different timelines &mdash; the former in the reboot timeline and the latter supposedly in the original timeline.  Also, one of the showrunners for Discovery, Alex Kurtzman, was one of the principal members of the creative team behind the Abrams films.  Why did the creative staff behind Discovery decide to make another prequel?  Does it have anything to do with the fact that Star Trek (2009) and Discovery are set in roughly the same years? How to remove uninstalled wine app icons from unity dash? I installed  (for Windows) using wine but turns out LAN Messenger is also available for linux as well. So..   I uninstalled LAN Messenger from wine. I also removed wine. deleted the .wine directory. after that sudo apt-get autoremove and sudo apt-get autoclean. then I installed LAN Messenger using dpkg -i pkgname.deb and it installed successfully.   The problem is that now I get this in dash:   Any Help is highly appreciated.  [NOTE] I am using ubuntu 12.10 This question is a result of having too much free time years ago during military service. One of the many pastimes was playing tic-tac-toe in varying grid sizes and dimensions, and it lead me to a conjecture. Now, after several years of mathematical training at a university, I am still unable to settle the conjecture, so I present it to you.  The classical tic-tac-toe game is played on a $3\times3$ grid and two players take turns to put their mark somewhere in the grid. The first one to get three collinear marks wins. Collinear includes horizontal, vertical and diagonal lines. Experience shows that the game always ends in a draw if both players play wisely.  Let us write the grid size $3\times3$ as $3^2$. We can change the edge length by playing on any $a^2$ grid (where each player tries to get $a$ marks in a row on the $a\times a$ grid). We can also change dimension by playing on any $a^d$ grid, for example $3^3=3\times3\times3$. I want to understand something about this game for general $a$ and $d$. Let me repeat: The goal is to make $a$ collinear marks.  I assume both players play in an optimal way. It is quite easy to see that the first player wins on a $2^d$ grid for any $d\geq2$ but the game is a tie on $2^1$. The game is a tie also on $3^1$ and $3^2$, but my experience suggests that the first player wins on $3^3$ but the game ties on $4^d$ for $d\leq3$. It seems quite credible that if there is a winning strategy on $a^d$, there is one also on $a^{d'}$ for any $d'\geq d$, since more dimensions to move in gives more room for winning rows.  to a related question tells that for any $a$ there is $d$ so that there is a winning strategy on $a^d$.  This brings me to the conjecture:     There is a winning strategy for tic-tac-toe on an $a^d$ grid if and only if $d\geq a$. (Refuted by TonyK's answer below.)   Is there a characterization of the cases where a winning strategy exists? It turns out not to be as simple as I thought.  To fix notation, let $$ \delta(a)=\min\{d;\text{first player wins on }a^d\} $$ and $$ \alpha(d)=\max\{a;\text{first player wins on }a^d\}. $$ The main question is:     Is there an explicit expression for either of these functions?   Or decent bounds?   Partial answers are also welcome.   Note that the second player never wins, as was discussed in .    A remark for the algebraically-minded: We can also allow the lines of marks to continue at the opposite face when they exit the grid; this amounts to giving the grid a torus-like structure. Now there are no special points, unlike in the usual case with boundaries. Collinear points on a toric grid of size $a^d$ corresponds to a line (maximal collinear set) in the module $(\mathbb Z/a\mathbb Z)^d$. (If $a$ is odd, then $a$ collinear points in the mentioned module add up to zero, but the converse does not always hold: the nine points in $(\mathbb Z/9\mathbb Z)^3$ with multiples of three as all coordinates add up to zero but are not collinear.) This approach might be more useful when $a$ is a prime and the module becomes a vector space. Anyway, if this version of the game seems more manageable, I'm happy with answers about it as well (although the conjecture as stated is not true in this setting; the first player wins on $3^2$). Why we won't extract heat from air temperature? Best Way To Store Multiple Flags In Database I have a web-based application that notifies users of activity on the site via email. Users can choose which kinds of notifcations they want to receive. So far there are about 10 different options (each one is a true/false).  I'm currently storing this in one varchar field as a 0 or 1 separated by commas. For example: 1,0,0,0,1,1,1,1,0,0  This works but it's difficult to add new notification flags and keep track of which flag belongs to which notification. Is there an accepted standard for doing this? I was thinking of adding another table with a column for each notification type. Then I can add new columns if I need, but I'm not sure how efficient this is.  Thanks in advance! I think it would make sense to split up the flag "This is not an answer" into three flag choices:   This should be a comment This should be an edit This should be a new question   If we had that, it would make it easier (and therefore more efficient) for mods to figure out what to do with answers flagged thusly. The PHB is a bit unclear when it comes to readied spells in combat. If I lose my concentration do I lose the spell slot? What about if the trigger never occurs, do I get the spell slot back? Springer llncs TOC not working I can't get the TOC to work. I remember it worked before, but there was something I did (unfortunately I can't remember what it was), and after that the TOC just stopped working.  Here is a part from my document:  \documentclass[deutsch]{llncs}  \usepackage{graphicx} \usepackage[labelformat=empty]{caption} \usepackage{subcaption} \captionsetup{compatibility=false}  \bibliographystyle{unsrt}  \pagestyle{headings} \begin{document}  \sffamily  \begin{titlepage}     %Some stuff here \end{titlepage}  \thispagestyle{headings} \tableofcontents \newpage %more stuff here blablabla \section{test} \subsection{test2} \end{document} I have my own AppleID ("Bob") but I don't use this email addy "Bob" anymore. I want to add my current, daily used email addy ("Jim") to my ID, or better yet, make it my only AppleID and delete "Bob". BUT... I already used "Jim" for an AppleID for an older friend who had no email address, so set it up for him on mine, "Jim".  My older friend now has an email address ("Ivan") so can I   add "Ivan" to his AppleID, make it the primary email address, and then delete "Jim" from it? Or... delete his AppleID and create a new one for him "Ivan" knowing he would lose his minor purchases   And most importantly, this would all be pointless unless: - will deleting/removing "Jim" as linked to my friend's AppleID then make "Jim" available for me and no longer registered to another account? html - how to remove right margin completely? One of my friends argues that princessship is the only word which has 3 identical letter comes together (s) ,but I think there is no word such as princessship.  Can anyone tell me whether this is a real word, and if there are any more English words which have 3 letters consecutively? Why is the gradient of implicit surface the normal vector (i.e. parallel to the normal line)? If we have an implicit surface $g(x, y, z)=...$, the gradient is a normal vector. But why? Do I have to start with tangent vectors and then show the gradient is perpendicular? Not sure how to approach this. Programmatically selecting non adjacent Cells How to make a jquery click event fire only on first click Regarding the recalc in question rep increase what happens due to the cap?