android - Enable/Disable internet not working for SONY Xperia (Any other way?) -



android - Enable/Disable internet not working for SONY Xperia (Any other way?) -

i developing 1 android app need enable/disable mobile net problematically.

the code have written works fine other companies devices except sony xperia z.

is there other way stop mobile net in sony?

my code enable/disable mobile data:

final class conmanclass = class.forname(conman.getclass().getname()); final field iconnectivitymanagerfield = conmanclass.getdeclaredfield("mservice"); iconnectivitymanagerfield.setaccessible(true); final object iconnectivitymanager = iconnectivitymanagerfield.get(conman); final class iconnectivitymanagerclass = class.forname(iconnectivitymanager.getclass().getname()); final method setmobiledataenabledmethod = iconnectivitymanagerclass.getdeclaredmethod("setmobiledataenabled", boolean.type); setmobiledataenabledmethod.setaccessible(true); setmobiledataenabledmethod.invoke(iconnectivitymanager, enabled);

to manage net on android device utilize code maybe help you:

connectivitymanager datamanager = (connectivitymanager)getsystemservice(context.connectivity_service); networkinfo networkinfo = datamanager.getactivenetworkinfo(); method datamtd = connectivitymanager.class.getdeclaredmethod("setmobiledataenabled", boolean.class); datamtd.setaccessible(true); datamtd.invoke(datamanager, true); // set right boolean value enable or disable net

i have created sample application manage wifi , net android if need more details

android android-internet

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -