Get active widget

I have a list of widget apps. My problem is that I can’t find out which widget is currently active on the phone. I get a list of widget applications for 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 a context object.

I can get the name of the active name of the application package, but in the case of widgets, I am not.

+4
source share
2 answers

I have not tried this, but you can try using getRunningServices since these widgets interact with their applications with internal broadcast receivers, so you cannot intercept this

+1
source
ActivityManager actvityManager = (ActivityManager)
this.getSystemService( ACTIVITY_SERVICE );
List<RunningAppProcessInfo> procInfos = actvityManager.getRunningAppProcesses();

: http://www.dreamincode.net/forums/topic/138412-android-20-list-of-running-applications/

+2

All Articles