Results 1 to 2 of 2

Thread: Hello

  1. #1
    narmada132 is offline Member
    Join Date
    May 2012
    Posts
    1
    Rep Power
    0

    Post Hello

    Hello everyone,

    URL queryUrl;
    AnalyticsService analyticsService = new AnalyticsService("gaExportAPI_acctSample_v2.0");
    List<Profile> listOfProfile = new ArrayList<Profile>();
    Profile analyticsProfile= new Profile();
    analyticsService.setAuthSubToken(accessToken, null);
    // Make request to the API.
    try {
    queryUrl = new URL("https://www.google.com/analytics/feeds/accounts/default?max-results=200");
    AccountFeed accountFeed = analyticsService.getFeed(queryUrl, AccountFeed.class);
    for(AccountEntry accountEntry : accountFeed.getEntries()){
    analyticsProfile.setDisplayName(accountEntry.getTi tle().getPlainText());
    analyticsProfile.setProfile(accountEntry.getProper ty("ga:profileId"));
    System.out.println(analyticsProfile);
    listOfProfile.add(analyticsProfile);
    System.out.println(listOfProfile);
    }
    } catch (IOException e) {
    e.printStackTrace();
    } catch (ServiceException e) {
    e.printStackTrace();
    } catch (UnsupportedOperationException e) {
    e.printStackTrace();
    }

    return listOfProfile;

    }


    Here the above code is for getting some feed from the queryUrl.
    Here I have to get the entries in the accountFeed, for that i use accountEntry.
    But problem here im encountered with is whatever the entries in the accountEntry i've to iterate it and get into my List<Profile>, where while iterating whatever the element is iterated it should appended to the end of the list but here after first iteration whatever analyticProfile object is having is added to list but at the second iteration the analyticProfile is appended to the list but it is added twice eliminating the first iterated value of analyticProfile into the list and so on which is resulting in duplicates and able to get the list of elements with a values in last iterated object in the entries.

    I've tried to sort out the problem a lot but could not understand where exactly the problem is......

    Plz do the needful....it is an urgent code which i need to sort out.

    I request anybody who could help me on this as soon as possible.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Hello

    Moved from Suggestions and Feedback. The page for that section has a by-line
    Something you do or don't like? Let us know. This is also the place for questions regarding this forum.
    What made you think it was the appropriate section to post your question?

    Please go through the following:
    Forum Rules
    Guide For New Members
    BB Code List - Java Programming Forum

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •