首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

取得activity方法

2012-09-28 
获得activity方法最近项目中需要动态获得activity,仔细研究了下,发现这样可以获得:?Launcher应用-Workspa

获得activity方法

最近项目中需要动态获得activity,仔细研究了下,发现这样可以获得:

?

Launcher应用->Workspace.java->updateShortcuts方法->

if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION &&
??????????????????????????? Intent.ACTION_MAIN.equals(intent.getAction()) && name != null) {

...................................

}后面,加入如下代码

?

else if(info.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT &&                            Intent.ACTION_MAIN.equals(intent.getAction()) && name != null){                        String[] str=name.flattenToShortString().split("/");                        Log.d("ResolveInfo","str[0]="+str[0]+",str[1]="+str[1]);                        String str1=str[0];                        String str2=str[0]+str[1];                           ComponentName com= new ComponentName(str1,str2);                            Intent ii=new Intent();                            ii.setComponent(com);                            List<ResolveInfo> list=pm.queryIntentActivities(ii, 0);                            if(list.size()>0){                            for(ResolveInfo r:list){                            String newtitle=r.loadLabel(pm).toString();                            Log.d("ResolveInfo","获得的activity标题="+newtitle);                            info.setTitle(newtitle);                            }                            }                    }
?

热点排行