Get Google Plus friends Android - android

I am working with google + getting friends. I can successfully log in and get my credentials. But when I use mPlusClient.loadPeople(this, "me");, the return of
#Override
public void onPeopleLoaded(ConnectionResult status, PersonBuffer personBuffer, String nextPageToken) {
switch (status.getErrorCode()) {
case ConnectionResult.SUCCESS:
try {
int count = personBuffer.getCount();
Log.e("", "count : " + count);
for (int i = 0; i < count; i++) {
Log.e("NAME", "" + personBuffer.get(i).getDisplayName());
}
} finally {
personBuffer.close();
}
break;
case ConnectionResult.SIGN_IN_REQUIRED:
mPlusClient.disconnect();
mPlusClient.connect();
break;
default:
Log.e("TAG", "Error when listing people: " + status);
break;
}
}
is only the details of the logged in user. Now what I what to achieve is to get the list of my friends. I tried using
mPlusClient.loadPeople(MainActivity.this, Person.Collection.Visible);
but it says "Collection cannot be resolved or is not a field".
Any help would be highly appreciated. Thank you.

Looks like you're after the PlusClient.loadVisiblePeople method.
You can see an example of the response using Web API explorer.

This link somehow helped me to feftch the members of my circle in google plus.
mPlusClient.loadVisiblePeople(this, null);
solved the problem. People.Collection.VISIBLE is not already working. I do not know why.

Related

How to add a skip-ad button to exoplayer with IMA extention using react-native-video

Update:
After much research I've asked this question instead. It gets to the core of the problem. Google IMA webview is not showing when used inside react native on android
We are using react-native-video to use the exoplayer on android to show video with adds. The problem is, the exoplayer doesn't show the skip-button when an ad is skippable. To solve this problem we need to know if an ad is skippable and show a custom skipp-button. That's where I'm stuck. I can't get access to this information without changing the sourcecode of the exoplayer ima-extention.
The preferred solution would be to change the ImaAdsLoader**.onAdEvent() to broadcast an event when the add is loaded that exposes the Ad that has been loaded. Then monitor the playback-progress and show/hide a custom skipp-button.
Is there a way to get the information without altering the code of the ima-extention?
#Override
public void onAdEvent(AdEvent adEvent) {
AdEventType adEventType = adEvent.getType();
boolean isLogAdEvent = adEventType == AdEventType.LOG;
if (DEBUG || isLogAdEvent) {
Log.w(TAG, "onAdEvent: " + adEventType);
if (isLogAdEvent) {
for (Map.Entry<String, String> entry : adEvent.getAdData().entrySet()) {
Log.w(TAG, " " + entry.getKey() + ": " + entry.getValue());
}
}
}
if (adsManager == null) {
Log.w(TAG, "Dropping ad event after release: " + adEvent);
return;
}
Ad ad = adEvent.getAd();
switch (adEvent.getType()) {
case LOADED:
//This line is what I need
eventListener.onAdLoaded(ad);
// The ad position is not always accurate when using preloading. See [Internal: b/62613240].
AdPodInfo adPodInfo = ad.getAdPodInfo();
int podIndex = adPodInfo.getPodIndex();
adGroupIndex = podIndex == -1 ? adPlaybackState.adGroupCount - 1 : podIndex;
int adPosition = adPodInfo.getAdPosition();
int adCountInAdGroup = adPodInfo.getTotalAds();
adsManager.start();
if (DEBUG) {
Log.d(TAG, "Loaded ad " + adPosition + " of " + adCountInAdGroup + " in ad group "
+ adGroupIndex);
}
adPlaybackState.setAdCount(adGroupIndex, adCountInAdGroup);
updateAdPlaybackState();
break;
case CONTENT_PAUSE_REQUESTED:
// After CONTENT_PAUSE_REQUESTED, IMA will playAd/pauseAd/stopAd to show one or more ads
// before sending CONTENT_RESUME_REQUESTED.
imaPausedContent = true;
pauseContentInternal();
break;
case STARTED:
if (ad.isSkippable()) {
focusSkipButton();
}
break;
case TAPPED:
if (eventListener != null) {
eventListener.onAdTapped();
}
break;
case CLICKED:
if (eventListener != null) {
eventListener.onAdClicked();
}
break;
case CONTENT_RESUME_REQUESTED:
imaPausedContent = false;
resumeContentInternal();
break;
case ALL_ADS_COMPLETED:
// Do nothing. The ads manager will be released when the source is released.
default:
break;
}
}

Read content of another app through my app

I have been searching the same problem for days. But unable to get any hint for that.
I need to create an app like voodoo app, which shows its custom layout only on specific pages of different apps like flipkart,etc.
Now, till this time, i have found options of using AccessebilityService and MediaProjection classes for the same. But i am stuck, how can i know programmatically, that Flipkart's Product Detail Page is visible so that i can display my app's custom view over it like Voodoo app does.
Any suggestions?
What you want to do is the following.
Using accessibility services track incoming events. Then you want to track TYPE_WINDOW_CONTENT_CHANGED events, and detect when the window content matches what you'd expect.
#Override
public void onAccessibilityEvent(AccessibilityEvent e) {
switch (e.getEventType()) {
case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: {
if (isFlipkartProdcutDetailPage(getRootInActiveWindow()) {
doStuff()
}
}
}
}
public boolean isFlipkartProductDetailPage(AccessibilityNodeInfo nodeInfo) {
//Use the node info tree to identify the proper content.
//For now we'll just log it to logcat.
Log.w("TAG", toStringHierarchy(nodeInfo, 0));
}
private String toStringHierarchy(AccessibilityNodeInfo info, int depth) {
if (info == null) return "";
String result = "|";
for (int i = 0; i < depth; i++) {
result += " ";
}
result += info.toString();
for (int i = 0; i < info.getChildCount(); i++) {
result += "\n" + toStringHierarchy(info.getChild(i), depth + 1);
}
return result;
}

ParseQuery simply not running, with no response, not logs written

Why does parse not appear to be doing anything with my query whatsoever. It's almost as if the entire block is ignored..
try {
Log.w("UpdateContacts", "Attempting an update");
List<ParseObject> result = friendshipAndUserQuery.find();
for (ParseObject friendship : result) {
Log.i("UpdateContacts", "Found friendship" + friendship.getObjectId());
UserObject friend = (UserObject) friendship.getParseObject("to");
Log.i("UpdateContacts", "Converted friendship to friend " + friend.getObjectId());
contacts.add(friend);
((MainActivity) mContext).notify("UpdateContacts", friend.getObjectId() + " / " + friend.getUsername(), true);
}
} catch (ParseException e) {
Log.e("ParseException", e.toString());
((MainActivity) mContext).notify("UpdateContacts", e.toString(), true);
}
I get the "attempting an update" Log, but nothing else. I can see from my Parse portal that the query has run, my android simply gets nothing back at all.. not an empty set, nothing. No logs were made..
Solved
Query referenced the incorrect table name (case sensitive) and Parse simply stops all related code, rather than spouting out an error..

Neither Fabric for Android nor twitter4j find tweets containing a specific user's mention

I'm trying to retrieve tweets that mention an specific user either using fabric for android or twitter4j, but I'm not getting anything.
-With Fabric for Android I'm doing it with "twitterApiClient.getSearchService().tweets" (logged in as a guest previously)
-With twitter4j, this is my code:
public List<Long> twList (String user){
List<Long> listTw = new ArrayList<>();
lastID = Long.MAX_VALUE;
int tamano = 0;
ArrayList<Status> tweets = new ArrayList<Status>();
String mention = "#"+user.trim();
query = new Query(user);
while (tweets.size() < numberOfTweets) {
tamano = tweets.size();
if (numberOfTweets - tweets.size() > 100) {
query.setCount(100);
} else {
query.setCount(numberOfTweets - tweets.size());
}
try {
QueryResult result = twitter.search(query);
tweets.addAll(result.getTweets());
Log.d("App", "Gathered " + tweets.size() + " tweets");
for (Status t : tweets) {
if (t.getId() < lastID) {
lastID = t.getId();
}
}
} catch (TwitterException te) {
Log.d("App", "Couldn't connect: " + te);
}
query.setMaxId(lastID - 1);
if (tamano == tweets.size()) break;
}
for (Status s: tweets){
if (s.getText().matches(mention)){
listTw.add(s.getId());
Log.d("App", s.getText());
}
}
tweets.clear();
return listTw;
}
When I look for the username on Twitter website, I get those tweets where it's mentioned.
Any idea?
When was the last time a Tweet including the username you're searching for, posted? The Search API (which is used by both Fabric and Twitter4j) only covers around 7 days of data. The website has the complete archive, but that is not available in the public Twitter API.

Error while saving ParseRelation

I'm having some issues while trying to save a ParseRelation. I've tried creating the ParseUser first (I thought that was the problem) but it continued to happen.
Situation: I have 2 tables, one is User (Parse.com default) and a second one called Teams. Inside the latter, there's a ParseRelation to User. After saveInBackground is triggered I check the DataBrowser and I can see that the team was in fact created but the players added not in the relation.
My code:
ParseObject newTeam = new ParseObject(Constants.TABLE_TEAMS);
newTeam.put(Constants.ATTRIB_TEAM_NAME, nombreEquipo);
// FIXME ParseRelation not being saved
ParseRelation<ParseUser> playersRelation = newTeam
.getRelation(Constants.ATTRIB_TEAM_PLAYERS);
// Get Users from ListView
for (int i = 0; i < invitedPlayers.size(); i++) {
ParseUser pu = (ParseUser) viewPlayerList.getItemAtPosition(i);
playersRelation.add(pu);
Log.d(LOG_TAG,
"Player being added: "
+ pu.get(Constants.ATTRIB_USER_NAME));
}
newTeam.put(Constants.ATTRIB_TEAM_PLAYERS, playersRelation);
newTeam.saveInBackground(new SaveCallback() {
#Override
public void done(ParseException e) {
if (e == null) {
// setResult(RESULT_OK);
Toast.makeText(getApplicationContext(), "Team created.",
Toast.LENGTH_SHORT).show();
finish();
} else {
Toast.makeText(getApplicationContext(),
"ParseException: " + e.getMessage(),
Toast.LENGTH_SHORT).show();
}
}
});
Any ideas ? I've read the docs and also checked a few samples but can't seem to find out what's the problem.
Edit: Using Parse.com v1.5.0 and Android 4.4.2

Categories

Resources