powered by Jive Software

Asmack block user Null pointer

Hi guys,

I’m trying to develop messenger using asmack that have feature block / blacklist user

but i’m getting trouble using it.

My code :

public void blockUser(String userName)


String listName = “newList”;

List privacyItems = new Vector();

PrivacyItem item=new PrivacyItem(PrivacyItem.Type.jid.toString(), false, 1);



PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(mConnection);





catch(Exception e)


Log.e("ERROR: “,” "+e.toString());




I’m getting Null at PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(mConnection);

eventhough my mconnection not null…

the impact is it will enter exception and give NULL pointer message.

any suggestion?


Post the stacktrace.

What you are saying doesn’t make sense as you cannot get a NullPointerException on the line you have indicated (You are acessing a static method, so you cannot get a null object reference).

what i mean is at PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(mConnection); it get null values and the impact is when it enter the try catch is give me exception null pointer

Did you read aSmack’s README and initialized the static code like it tells you to do?

Solve by myself:

we must add XMPPClientConnection.getinstance().mconnection =null;

public void logOut()


if (XMPPClientConnection.getInstance().mConnection.isConnected())


Presence presence = new Presence(Presence.Type.unavailable);




XMPPClientConnection.getinstance().mconnection =null;


1 Like

HI calvin, I also get same error. Can you please tell me where you put this **XMPPClientConnection.getinstance().mconnection =null; ? ** and How it effects

PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(mConnection);

and what is this " XMPPClientConnection "

Kindly Help me,

You put it when you logout.:).

HI calvin,i got same error,but i can not use “XMPPClientConnection”,i use asmack-android-17-0.8.2 jar which has not class “XMPPClientConnection”,Kindly Help me