Search code examples
androidandroid-widgetandroid-appwidgetappwidgetprovider

Get the currently active widget


I have got all the widget app list.My problem is that I am not able to know that which widget is currently active in the phone. I am getting the list of widget apps by this code,

AppWidgetManager manager1=AppWidgetManager.getInstance(ctx);
        List<AppWidgetProviderInfo>infoList=manager1.getInstalledProviders();
        for(AppWidgetProviderInfo info:infoList)
        {
           String component = ""+info.provider;
           Log.i("Widget", ""+component);

        }

ctx is the object of Context.

I am able to get the name of currently active package name of Applications but in case of Widgets, I am not.


Solution

  • I have not tried this but u may Try using getRunningServices As These widgets communicates with their apps with internal broadcast receivers so u can not intercept that