[英]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. ctx是Context的对象。
I am able to get the name of currently active package name of Applications but in case of Widgets, I am not. 我能够获得应用程序当前活动包名称的名称,但是对于Widgets,我不是。
ActivityManager actvityManager = (ActivityManager)
this.getSystemService( ACTIVITY_SERVICE );
List<RunningAppProcessInfo> procInfos = actvityManager.getRunningAppProcesses();
Example Here : http://www.dreamincode.net/forums/topic/138412-android-20-list-of-running-applications/ 示例: http : //www.dreamincode.net/forums/topic/138412-android-20-list-of-running-applications/
我没试过这个,但是你可以尝试使用getRunningServices As这些小部件与他们的应用程序通过内部广播接收器进行通信,所以你不能拦截那个
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.