java - How to disable all the widgets in android device? -
i trying disable widgets device through application.i using following list of widgets not info widgets,lets have 26 widgets in phone gets 15 items in list gets disabled.
private static void disableallwidgets(context context) { appwidgetmanager manager = appwidgetmanager.getinstance(context); list<appwidgetproviderinfo> infolist = manager.getinstalledproviders(); (appwidgetproviderinfo info : infolist) { string providerinfo = "" + info.provider; int startindex = providerinfo.indexof('{'); int endindex = providerinfo.indexof('}'); string[] parts = (providerinfo.substring(startindex + 1, endindex)).split("/"); string packagename = parts[0]; string widgetprovidername = parts[1]; try { mpackagemanager = (packagemanager) context.getpackagemanager(); try { mpackagemanager.setcomponentenabledsetting(new componentname(packagename, widgetprovidername), packagemanager.component_enabled_state_enabled, packagemanager.dont_kill_app); } catch (exception e) { e.printstacktrace(); } mpackagemanager.setcomponentenabledsetting(new componentname(packagename, widgetprovidername), packagemanager.component_enabled_state_disabled, 0); } catch (exception ex) { ex.printstacktrace(); } } }
now question how can disable rest widgets not there in list since wanted disable widgets.
Comments
Post a Comment