" r.activityInfo"返回"错误:找不到符号变量activityInfo"在编译
公共类MainActivity扩展了ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.d("LP1", "Created");
super.onCreate(savedInstanceState);
final Intent mainIntent = new Intent(Intent.ACTION_VIEW, android.net.Uri.parse("http://abc"));
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List<ResolveInfo> browsList = this.getPackageManager().queryIntentActivities( mainIntent, 0);
Iterator itr = browsList.iterator();
while(itr.hasNext()) {
Object r = itr.next();
ActivityInfo s = r.activityInfo;
}
... }
答案 0 :(得分:2)
您声明Object r
,但Object
类没有名为activityInfo
的成员。
要解决此问题,请使用增强的for循环:
for (ResolveInfo r : browsList) {
ActivityInfo s = r.activityInfo;
}
答案 1 :(得分:0)
您可以为每个周期添加演员表或使用。
while(itr.hasNext()) {
ResolveInfo r = (ResolveInfo)itr.next();
ActivityInfo s = r.activityInfo;
}