How can I turn off/on 3G/4G/Data programmatically on Android 5.0? -


why code not work on android 5.0 ?

i testing on android 4.3, working on android 5.0 not working.

please me.

private void setmobiledataenabled(context context, boolean enabled) throws classnotfoundexception, nosuchfieldexception, illegalaccessexception, nosuchmethodexception, invocationtargetexception {  	    final connectivitymanager conman = (connectivitymanager)  context.getsystemservice(context.connectivity_service);  	    final class<?> conmanclass = class.forname(conman.getclass().getname());  	    final java.lang.reflect.field connectivitymanagerfield = conmanclass.getdeclaredfield("mservice");  	    connectivitymanagerfield.setaccessible(true);  	    final object connectivitymanager = connectivitymanagerfield.get(conman);  	    final class<?> connectivitymanagerclass =  class.forname(connectivitymanager.getclass().getname());  	    final method setmobiledataenabledmethod = connectivitymanagerclass.getdeclaredmethod("setmobiledataenabled", boolean.type);  	    setmobiledataenabledmethod.setaccessible(true);    	    setmobiledataenabledmethod.invoke(connectivitymanager, enabled);  	}

google has called off api data on/off pragmatically. can check issue filed on link.

if want know more details long answer on link detailed discussion there

and if find helpful accept answer


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -