Unable to start activity ComponentInfo, request Permission I'm trying to request permissions on Android but I have an error.  Unable to start activity ComponentInfo {[...]}:java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference     [...]   Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference   at android.content.ContextWrapper.getPackageManager(ContextWrapper.java:91)   at android.app.Activity.requestPermissions(Activity.java:4284)   at android.support.v4.app.ActivityCompat.requestPermissions(ActivityCompat.java:507)   at com.appwifi.Wifi.Wifi.setPermission(Wifi.java:118)   at com.appwifi.Wifi.Wifi.connect(Wifi.java:62)   at com.appwifi.Wifi.Wifi.&lt;init&gt;(Wifi.java:51)   at com.appwifi.Main.MainActivity.onCreate(MainActivity.java:32)     I think i have understood it's a NullPointerException but even with debugger i can't find what is null. Here is the code :  public class Wifi extends Activity {     public static final int WIFI_PERMISSION = 1;     [...]     private void setPermission() {         if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M             &amp;&amp; (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED             || ActivityCompat.checkSelfPermission(mContext, Manifest.permission.CHANGE_WIFI_STATE) != PackageManager.PERMISSION_GRANTED             || ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_WIFI_STATE) != PackageManager.PERMISSION_GRANTED)) {         ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_WIFI_STATE,Manifest.permission.CHANGE_WIFI_STATE,Manifest.permission.ACCESS_COARSE_LOCATION},WIFI_PERMISSION); // Error is on this line     } }   'this' can't be null, a new String and a static number too  I know there is some similar topic but each are very specific and i didn't find any solution. Can't understand please help me.
What is a NullPointerException, and how do I fix it? 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?
Splitting all lines in layer at vertices using QGIS Allow setuid on shell scripts The setuid permission bit tells Linux to run a program with the effective user id of the owner instead of the executor:  &gt; cat setuid-test.c  #include &lt;stdio.h&gt; #include &lt;unistd.h&gt;  int main(int argc, char** argv) {     printf("%d", geteuid());     return 0; }  &gt; gcc -o setuid-test setuid-test.c &gt; ./setuid-test  1000  &gt; sudo chown nobody ./setuid-test; sudo chmod +s ./setuid-test &gt; ./setuid-test  65534   However, this only applies to executables; shell scripts ignore the setuid bit:  &gt; cat setuid-test2  #!/bin/bash id -u  &gt; ./setuid-test2  1000  &gt; sudo chown nobody ./setuid-test2; sudo chmod +s ./setuid-test2 &gt; ./setuid-test2  1000     Wikipedia :     Due to the increased likelihood of security flaws, many operating systems ignore the setuid attribute when applied to executable shell scripts.   Assuming I'm willing to accept those risks, is there any way to tell Linux to treat the setuid bit the same on shell scripts as it does on executables?  If not, is there a common workaround for this problem? My current solution is to add a sudoers entry to allow ALL to run a given script as the user I want it run as, with NOPASSWD to avoid the password prompt. The main downsides to that is the need for a sudoers entry every time I want to do this, and the need for the caller to sudo some-script instead of just some-script \RequirePackage{filecontents} \begin{filecontents}{\jobname.bib} @article{Arter95,     Author = {David Arter},     Date-Added = {2013-08-11 17:38:06 +0000},     Date-Modified = {2013-09-01 15:13:22 +0000},     Journal = {Journal of Common Market Studies},     Number = {3},     Pages = {361-287},     Title = {The {EU} {Referendum} in {Finland} on 16 October 1994:              {A} Vote for the {West}, not for {Maastricht}},     Volume = {33},     Year = {1995}}  @article{Detlef95,     Author = {Jahn, Detlef; Storsved,Ann-sofie},     Date-Added = {2013-08-11 17:14:34 +0000},     Date-Modified = {2013-08-11 17:16:45 +0000},     Journal = {West European Politics},     Number = {4},     Pages = {18-37},     Title = {Legitimacy through referendum? The nearly successful domino‚Äêstrategy of the Eu‚Äêreferendums in Austria, Finland, Sweden and Norway},     Volume = {18},     Year = {1995}} \end{filecontents} \documentclass{article} \usepackage[ngerman]{babel} \usepackage{natbib} \bibpunct{(}{)}{;}{a}{}{,} \makeatletter \renewcommand\@biblabel[1]{} \makeatother  \begin{document}  \cite{Arter95}  \bibliography{\jobname} \bibliographystyle{plainnat}  \end{document}   Please help. I want the author's name displayed like this "Arter, D." instead of David Arter A diagram which is not the torus At page 17 of Munkres' Elements of Algebraic topology it says, referring to fig. 3.6, that "the diagram does not determine [the torus]. It does more than paste opposite edges together":   Is it so? I tried to glue them together, but end up with a normal torus. script custom previews in a menu I want to know how to create a menu with previews for an add-on. Until now I know that this is related with the bpy.utils.preview. I'm making an add-on that appends objects from a .blend file, I know how to append objects but what I want to do is to create a menu with previews of the objects /(similar to the matcaps menu - see below), select them and then press an &quot;import button&quot; to append the object. Here's some documentation about the module:    Also, as this is an add-on I don't know if I should have a def register() and a def unregister() inside this .py file as well as in the __init__.py file. Formula for expected value of continuous random variable without using density I'm learning C#, so I made a little C# program that says Hello, World!, then compiled it with mono-csc and ran it with mono:  $ mono-csc Hello.cs $ mono Hello.exe Hello, World!   I noticed that when I hit TAB in bash, Hello.exe was marked executable. Indeed, it runs by just a shell loading the filename!   Hello.exe is not an ELF file with a funny file extension:  $ readelf -a Hello.exe readelf: Error: Not an ELF file - it has the wrong magic bytes at the start $ xxd Hello.exe | head -n1 00000000: 4d5a 9000 0300 0000 0400 0000 ffff 0000  MZ..............   MZ means it's a Microsoft Windows statically linked executable. Drop it onto a Windows box, and it will (should) run.  I have wine installed, but wine, being a compatibility layer for Windows apps, takes about 5x as long to run Hello.exe as mono and executing it directly do, so it's not wine that runs it.  I'm assuming there's some mono kernel module installed with mono that intercepts the exec syscall/s, or catches binaries that begin with 4D 5A, but lsmod | grep mono and friends return an error.   What's going on here, and how does the kernel know that this executable is special?    Just for proof it's not my shell working magic, I used  (aka sh) to run it and it still runs natively.    Here's the program in full, since a commenter was curious:  using System;  class Hello {   /// &lt;summary&gt;   ///   The main entry point for the application   /// &lt;/summary&gt;   [STAThread]   public static void Main(string[] args) {     System.Console.Write("Hello, World!\n");   } } How to get the type of T from a member of a generic class or method Let's say I have a generic member in a class or method, like so: public class Foo&lt;T&gt; {     public List&lt;T&gt; Bar { get; set; }          public void Baz()     {         // get type of T     }    }  When I instantiate the class, the T becomes MyTypeObject1, so the class has a generic list property: List&lt;MyTypeObject1&gt;. The same applies to a generic method in a non-generic class: public class Foo {     public void Bar&lt;T&gt;()     {         var baz = new List&lt;T&gt;();                  // get type of T     } }  I would like to know what type of objects the list of my class contains. So what type of T does the list property called Bar or the local variable baz contain? I cannot do Bar[0].GetType(), because the list might contain zero elements. How can I do it? I asked about it on  and they told me to post it here.  Probably need to add the :active to the :hover meta class or something like that.  Example:      Hammer Time I started a Roth IRA a little while ago, contributing ~$5,000, and I'd like some guidelines on how I should diversify my investments.  Should I invest in stocks or bonds or mutual funds or ETF? What percent should I contribute to these investments?  Additionally, I'm 30 years old, how might my age factor into diversification?  I understand that this is a very subjective question but any suggestions are greatly appreciated. How to implement Bitcount using only Bitwise operators? P.d.f of the absolute value of a normally distributed variable I came across this question as an exercise, had a brief idea, but didn't know how to proceed.     Let $X \sim N(0, 1)$. What is the p.d.f of $|X|$ ?   I know the final p.d.f looks just like the right half of the original pdf, but extended vertically for a factor of 2.  Could someone please show mathematically what the p.d.f of variable |X| is going to be, and explain briefly? Thank you. Static posts page with home.php I have read the Rules of a competition. The text of the Rules include a sentence as follows:     As per stated in the Rules the entrants will be notified by May 30th 2010.   Does the sentence above mean that May 30th is included in the term of notification or not? Tense change: previous actions on something that's currently true This might be a completely wrong question, but this is bothering me since many days ago. Given the mass (Sun) curves the space around it, gravitation is the result of such curved space (Correct me if I am wrong, source: A Documentary film). Given any point on a circle with center same as center of the mass, curvature in the space should be equal (Intuition).   Planets rotate around the Sun because of the curve in the space they should follow a circular path and the distance between planet and Sun should be at a distance.  Given the fact that earth has a elliptical orbit around the sun, and the distance between Earth and Sun varies according to position of the earth. Why do we have a elliptical orbit not a circular orbit. How to add the name of the supervisor in a @thesis field? In the biblatex doc, it says ( Version 1.7, p.11):     thesis      A thesis written for an educational institution to satisfy the   requirements for a degree. Use the type field to specify the type of   thesis.      Required fields: author, title, type, institution, year/date      Optional fields: subtitle, titleaddon, language, note, location,   month, isbn, chapter, pages, pagetotal, addendum, pubstate, doi,   eprint, eprintclass, eprinttype, url, urldate   I would like to know if there is any "canonical" way to add the name of the supervisor(s) in a field of the .bib file (no .bbl manipulation please, I want my bibliography to be usable "as it" in several documents).  The expect result could be something like  :     Meand Myself. “A brilliant result, explained”. PhD thesis**, under the   joint supervision of Pr. Toto and Pr. Tata**. Université Paris 24,   Nov. 2013.   The "under the (joint) supervision" could be a string that would be declined in four ways:   under the supervision of  under the joint supervision of and the abridged forms A question of Euclidean domain Is it (if at all) possible in Blender 2.6+?   If not, will future versions of Blender support it?  I see some old posts ( and ) saying that it is not possible. However, I found  referring to operators under  that allowed me to add sensors and controllers from python.  bpy.ops.logic.sensor_add(type='ALWAYS', object=my_obj.name) bpy.ops.logic.controller_add(type='LOGIC_AND', object=my_obj.name)   However I am not able to find any way to link them from python. I tried following (but did not work):  new_controller = my_obj.controllers[-1] new_sensor = my_obj.sensors[-1]   It throws AttributeError saying that object has no attribute 'controllers' :-/ Why is the application of probability in  (QM) fundamentally different from its application in other areas? QM applies probability according to the same  as in other areas of physics, engineering, etc.  Why is there a difference?  Naively one would assume one of these possibilities:   It is not the same probability (theory?) It is a matter of interpretation (of the formalism?) Something else?   Many answers (which I am still studying) focus on the fact that the combined probability of two mutually-exclusive events in QM is not equal to the sum of the probabilities of each event (which holds classically by definition). This fact (appears to) makes the formulation of another probability (a quantum one) a necessity.   Yet this again breaks down to assumed independent, if this is not so, the "classic probability" is applicable (as indeed in other areas). This is one of the main points of the question.