I am doing one application in android for that I need to access com.android.internal.telephony APIs. Now I am able to access those APIs but problem is wherever I call the
Obviously getConnections() returns null here and you cannot get the size of the null-object.
Here's how to fix it:
if (l == null || l.size() == 0)
{
return null;
}
So, if for some unknown reason, there is no Connection-List or the list is empty, null will be returned. Using the operator || will do the same as
if (l == null)
{
return null;
}
else if ( l.size() == 0)
{
return null;
}