Vishwesh Singh
Vishwesh Singh

Reputation: 15

Cannot resolve symbol 'activityInfo'

The line with "r.activityInfo" returns "error: cannot find symbol variable activityInfo" on compiling

public class MainActivity extends 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;
    }

... }

Upvotes: 0

Views: 1506

Answers (2)

Ivan Lapshov
Ivan Lapshov

Reputation: 51

You can just add a cast or use for each cycle.

while(itr.hasNext()) {
        ResolveInfo r = (ResolveInfo)itr.next();
        ActivityInfo s = r.activityInfo;
    }

Upvotes: 0

Code-Apprentice
Code-Apprentice

Reputation: 83557

You declare Object r, but the Object class has not member named activityInfo.

To fix this, use an enhanced for loop:

for (ResolveInfo r : browsList) {
    ActivityInfo s = r.activityInfo;
}

Upvotes: 2

Related Questions