I have a project in which am using volley library.
I have a `MyApplication` class :

```
public class MyApplication extends Application {
    public static final String TAG = MyApplication.class
            .getSimpleName();

    private RequestQueue mRequestQueue;

    private static MyApplication mInstance;

    @Override
    public void onCreate() {
        super.onCreate();
        mInstance = this;
    }

    public static synchronized MyApplication getInstance() {
        return mInstance;
    }

    public RequestQueue getRequestQueue() {
        if (mRequestQueue == null) {
            mRequestQueue = Volley.newRequestQueue(getApplicationContext());
        }

        return mRequestQueue;
    }

    public <T> void addToRequestQueue(Request<T> req, String tag) {
        req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
        getRequestQueue().add(req);
    }

    public <T> void addToRequestQueue(Request<T> req) {
        req.setTag(TAG);
        getRequestQueue().add(req);
    }

    public void cancelPendingRequests(Object tag) {
        if (mRequestQueue != null) {
            mRequestQueue.cancelAll(tag);
        }
    }
}

```

Now to use that in my project, am adding the class name in my `Manifest` file.

```
<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        android:name=".MyApplication"
        >

```

Everything is working fine.

Coming to main question,am also making a library in which I need to use volley.
In my library, I again created a `MyApplication` class and in the manifest I added the application name. I also added the Internet permission in the manifest.

But when am calling the function in my it's giving me null reference error.

```
Attempt to invoke virtual method 'com.android.volley.Request com.android.volley.RequestQueue.add(com.android.volley.Request)' on a null object reference

```

**My questions:**

a) We can use volley's in our libraries. right?

b) If yes, why it's showing me error? If NO, then how do I interact with the server?

Since I plan to make a maven repo, I can't do changes in main project file.

I tried changing the application name in project's Manifest to librarie's `MyApplication` class. In that case it was able to connect to the server.

But what if user has already changed the application name for their custom class, how do I achieve my goal in that case?

I also tried singleton class, it's also showing me same error.

Thanks