Getting context for Glide, within a fragment, results in error
<p>In this method, I'm attempting to use a framework to retrieve an image from a URL and store it as a bitmap. However, if I attempt to use it, I get a nullpointer exception.</p>

<p>"java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.app.Activity.isDestroyed()' on a null object reference"</p>

<p>I'm assuming it's something to do with using getActivity() for the context in Glide.with(). This method (below) is within a fragment.</p>

<pre><code>private void generateMarker(final GeoLocation location, final GoogleMap globalMap, String userName, String key){
    DownloadImage downloadImage = new DownloadImage();

final String url = "https://graph.facebook.com/" + key + "/picture?type=large";

marker = new MarkerOptions().position(
        new LatLng(location.latitude, location.longitude)).title(userName);

//downloadImage.execute(url);
//downloadImage.setOnDownloadImageListener(this);

Bitmap mBmap = null;
try {
    mBmap = Glide.with(getActivity())
            .load(url)
            .asBitmap()
            .into(100, 100)
            .get();
} catch (Exception e){
    System.out.println(e);
}

//Doing something with mBmap that results in null
</code></pre>

<p>}</p>

<p><strong>My Log cat</strong></p>

<pre><code> E/UncaughtException: java.lang.NullPointerException: null reference
                                                                at maps.w.d.a(Unknown Source)
                                                                at maps.ad.f$a.&lt;init&gt;(Unknown Source)
                                                                at maps.ad.f.a(Unknown Source)
                                                                at maps.ad.S.&lt;init&gt;(Unknown Source)
                                                                at maps.ad.t.a(Unknown Source)
                                                                at ua.onTransact(:com.google.android.gms.DynamiteModulesB:167)
                                                                at android.os.Binder.transact(Binder.java:387)
                                                                at com.google.android.gms.maps.internal.IGoogleMapDelegate$zza$zza.addMarker(Unknown Source)
                                                                at com.google.android.gms.maps.GoogleMap.addMarker(Unknown Source)
                                                                at com.test.project.PostFragment.generateMarker(PostFragment.java:255)
                                                                at com.test.project.PostFragment.access$300(PostFragment.java:51)
                                                                at com.test.project.PostFragment$3.onDataChange(PostFragment.java:224)
                                                                at android.os.Handler.handleCallback(Handler.java:739)
                                                                at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                at android.os.Looper.loop(Looper.java:158)
                                                                at android.app.ActivityThread.main(ActivityThread.java:7224)
                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
</code></pre>