Raicky Derwent
Raicky Derwent

Reputation: 393

NetworkInfo Reflection

I'm trying to reflect a constructor of NetworkInfo described here.

So far i have

    NetworkInfo mNetworkInfo;
    Class<NetworkInfo> clazz = NetworkInfo.class;
    Constructor<NetworkInfo> con = clazz.getConstructor(int.class,int.class,String.class,String.class);
    mNetworkInfo = con.newInstance(n1,n2,s1,s2);

However i keep getting a NoSuchMethodException error. What am i doing wrong ?

Upvotes: 2

Views: 97

Answers (1)

Sotirios Delimanolis
Sotirios Delimanolis

Reputation: 279930

You are using the the getConstructor correctly. I think you just don't have compatible versions of android SDK.

The javadoc for NetworkInfo doesn't show any constructors.

Are you running your code on a device that is running version 4.2.2_r1?

Upvotes: 2

Related Questions