I have integrated Flurry SDK successfully in Eclipse. Earlier it used to reflect properly in DASHBOARD, but now its not reflecting the "Active Users" in DASHBOARD.
Here are some codes which I've used :
#Override
public void onCreate(Bundle savedInstanceState)
{
// flurry inint
FlurryAgent.init(this, Constants.MY_FLURRY_APIKEY);
}
//For Flurry Integration
#Override
public void onStart()
{
super.onStart();
FlurryAgent.onStartSession(this, Constants.MY_FLURRY_APIKEY);
FlurryAgent.logEvent("Dialer");
}
// #Override
public void onStop()
{
super.onStop();
FlurryAgent.onEndSession(this);
}
Any help will be appreciated. Thanks in advance.Here you can see Active User is not reflecting.
public class QueryFilesSharedWithMeActivity extends BaseDemoActivity {
private ListView mResultsListView;
private ResultsAdapter mResultsAdapter;
#Override
protected void onCreate(Bundle b) {
super.onCreate(b);
setContentView(R.layout.activity_listfiles);
mResultsListView = (ListView) findViewById(R.id.listViewResults);
mResultsAdapter = new ResultsAdapter(this);
mResultsListView.setAdapter(mResultsAdapter);
}
/**
* Clears the result buffer to avoid memory leaks as soon as the activity is no longer
* visible by the user.
*/
#Override
protected void onStop() {
super.onStop();
mResultsAdapter.clear();
}
#Override
public void onConnected(Bundle connectionHint) {
super.onConnected(connectionHint);
Query query = new Query.Builder()
.addFilter(Filters.sharedWithMe())
.build();
Drive.DriveApi.query(getGoogleApiClient(), query)
.setResultCallback(metadataCallback);
showMessage("Connecting ...");
}
final private ResultCallback<DriveApi.MetadataBufferResult> metadataCallback =
new ResultCallback<DriveApi.MetadataBufferResult>() {
#Override
public void onResult(DriveApi.MetadataBufferResult result) {
showMessage("onResult ...");
if (!result.getStatus().isSuccess()) {
showMessage("Problem while retrieving results");
return;
}
mResultsAdapter.clear();
mResultsAdapter.append(result.getMetadataBuffer());
showMessage("Count = "+mResultsAdapter.getCount());
}
};
}
I am not able to query the files and folders that already shared with me by using the above code. Whenever i am trying to query sharedWithMe() i am getting the mResultAdapter array count '0'. please help me to solve this issue.
The Android API uses Drive.File scope, which means your app has access to files that have been created by, or explicitly opened with your app. Other files will not show up in search results.
Cheryl is right, you have to use Google APIs Java Client as said also here:
Note: The Google Drive Android API currently only supports drive.file and drive.appfolder authorization scopes. If your application requires additional permissions or features not yet available in the Drive Android API, you must use the Google APIs Java Client.
source: https://developers.google.com/drive/android/auth#connecting_and_authorizing_the_google_drive_android_api
I'm using latest Google Play services v4323030, downloaded BaseUtility library from GIT as written in google developer documentation.
In project using only GameHelper and GameHelperUtils classes without BaseGameActivity.
Initializing GameHelper in OnCreate method:
mHandler.postDelayed(new Runnable()
{
#Override
public void run()
{
if (!isGameCenterDisabled())
{
gameHelper = new GameHelper(Cocos2dxActivity.this,GameHelper.CLIENT_ALL);
GameHelperListener listener = new GameHelper.GameHelperListener() {
#Override
public void onSignInSucceeded() {
// handle sign-in succeess
}
#Override
public void onSignInFailed() {
// handle sign-in failure (e.g. show Sign In button)
}
};
gameHelper.setup(listener);
gameHelper.onStart(Cocos2dxActivity.this);
}
}
}, 3000);
Game is started and then it crashing:
Interface method not part of interface class
Could not find method com.google.android.gms.common.api.GoogleApiClient.isConnected, referenced from method com.google.example.games.basegameutils.GameHelper.getRequests
unable to resolve interface method 12116: Lcom/google/android/gms/common/api/GoogleApiClient;.isConnected ()Z
Cannot understand where can be trouble, why this methods is not visible...
Found out that during previous google play services update something gonna wrong, deleted and reinstalled then found out that current version is 4323000, modified manifest file to pick this version and everything looks works now.
I'm developing an application in which i have integrated google plus. So far Its working fine, I am able to retrieve the user profile.
But now i want to do the following:
1)I have two activity signInActivity and shareActivity.
2)If user is already signin using signInActivity then it should not ask for signin again in
shareActivity and should directly share the content.
3)If user is not signedin in the signInActivity and try to share data using shareActivitythen app should signin the user and then only share the data. In this case if user goes back to the signInActivity then app should show that "you have already signedin"
In short i want user signin to be Central within application so that if it is alrady signedin it should be accessible from any activity.
I have heard about the access token but i dont know how to use it and document says that it expires in an hour which is not what i want.
How can i make central google plus signin? is it possible? or i need to authenticate user in each activity?
Managing a separate instance of GoogleApiClient in each activity will not result in the user being asked to sign in multiple times.
Google+ Sign-in (ie. GoogleApiClient) provides an interface to the Google accounts on the device and the Google Play services core service - it doesn't have state per GoogleApiClient instance. So once a device account has been authenticated for your app, new instances of GoogleApiClient will access the same state. GoogleApiClient is specifically designed to be a lightweight way to access the central state managed by Google Play services.
You're in luck regarding access tokens! Google Play services takes care of all token management for you. So although access tokens only last for one hour, as you say, if you try to use your PlusClient to access a Google API and your access token has expired, Google Play services will transparently request a new access token for you and complete the call.
Take a look at the first part of this Google I/O talk for more details:
http://www.youtube.com/watch?v=_KBHf1EODuk
0. TL;DR
For the impatient coder, a working version of the following implementation can be found on GitHub. This is the same answer written on another Stack Overflow post.
After rewriting the login activity code several times in many different apps, the easy (and not so elegant) solution was create the Google API client as a Application class object. But, since the connection state affect the UX flow, I never was happy about with this approach.
Reducing our problem only to the connection concept, we may consider that:
It hides the Google API client.
It has finite states.
It is a (rather) unique.
The current state affect the behavior of the app.
1. Proxy Pattern
Since the Connection encapsulates the GoogleApiClient, it will implement the ConnectionCallbacks and OnConnectionFailedListener:
#Override
public void onConnected(Bundle hint) {
changeState(State.OPENED);
}
#Override
public void onConnectionSuspended(int cause) {
changeState(State.CLOSED);
connect();
}
#Override
public void onConnectionFailed(ConnectionResult result) {
if (currentState.equals(State.CLOSED) && result.hasResolution()) {
changeState(State.CREATED);
connectionResult = result;
} else {
connect();
}
}
Activities can communicate to the Connection class through the methods connect, disconnect, and revoke, but their behaviors are decided by the current state. The following methods are required by the state machine:
protected void onSignIn() {
if (!googleApiClient.isConnected() && !googleApiClient.isConnecting()) {
googleApiClient.connect();
}
}
protected void onSignOut() {
if (googleApiClient.isConnected()) {
Plus.AccountApi.clearDefaultAccount(googleApiClient);
googleApiClient.disconnect();
googleApiClient.connect();
changeState(State.CLOSED);
}
}
protected void onSignUp() {
Activity activity = activityWeakReference.get();
try {
changeState(State.OPENING);
connectionResult.startResolutionForResult(activity, REQUEST_CODE);
} catch (IntentSender.SendIntentException e) {
changeState(State.CREATED);
googleApiClient.connect();
}
}
protected void onRevoke() {
Plus.AccountApi.clearDefaultAccount(googleApiClient);
Plus.AccountApi.revokeAccessAndDisconnect(googleApiClient);
googleApiClient = googleApiClientBuilder.build();
googleApiClient.connect();
changeState(State.CLOSED);
}
2. State Pattern
This is a behavioral pattern the allow an object to alter its behavior when its internal state changes. The GoF Design Patterns book describes how a TCP connection can be represent by this pattern (which is also our case).
A state from a state machine should be a singleton, and the easiest away of doing it in Java was to create Enum named State as follows:
public enum State {
CREATED {
#Override
void connect(Connection connection) {
connection.onSignUp();
}
#Override
void disconnect(Connection connection) {
connection.onSignOut();
}
},
OPENING {},
OPENED {
#Override
void disconnect(Connection connection) {
connection.onSignOut();
}
#Override
void revoke(Connection connection) {
connection.onRevoke();
}
},
CLOSED {
#Override
void connect(Connection connection) {
connection.onSignIn();
}
};
void connect(Connection connection) {}
void disconnect(Connection connection) {}
void revoke(Connection connection) {}
The Connection class holds the context, i.e. the current state, which defines how the Connection methods connect, disconnect, and revoke will behave:
public void connect() {
currentState.connect(this);
}
public void disconnect() {
currentState.disconnect(this);
}
public void revoke() {
currentState.revoke(this);
}
private void changeState(State state) {
currentState = state;
setChanged();
notifyObservers(state);
}
3. Singleton Pattern
Since there is not need to recreate this class repeatedly, we provide it as a singleton:
public static Connection getInstance(Activity activity) {
if (null == sConnection) {
sConnection = new Connection(activity);
}
return sConnection;
}
public void onActivityResult(int result) {
if (result == Activity.RESULT_OK) {
changeState(State.CREATED);
} else {
changeState(State.CLOSED);
}
onSignIn();
}
private Connection(Activity activity) {
activityWeakReference = new WeakReference<>(activity);
googleApiClientBuilder = new GoogleApiClient
.Builder(activity)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API, Plus.PlusOptions.builder().build())
.addScope(new Scope("email"));
googleApiClient = googleApiClientBuilder.build();
currentState = State.CLOSED;
}
4. Observable Pattern
The Connection class extends Java Observable, so 1 or more activities can observe the state changes:
#Override
protected void onCreate(Bundle bundle) {
connection = Connection.getInstance(this);
connection.addObserver(this);
}
#Override
protected void onStart() {
connection.connect();
}
#Override
protected void onDestroy() {
connection.deleteObserver(this);
connection.disconnect();
}
#Override
protected void onActivityResult(int request, int result, Intent data) {
if (Connection.REQUEST_CODE == request) {
connection.onActivityResult(result);
}
}
#Override
public void update(Observable observable, Object data) {
if (observable != connection) {
return;
}
// Your presentation logic goes here...
}
For anyone reading this question you can also check this answer by Ian Barber and also the one below, answered by Lee, that explains three broad ways of working with Google plus login and multiple activies which I found very useful actually.
I had integrated GA in My app but still not able to get any data on GA dashboard.can anyone explain how to do it. dont add any link i had already checked all the sites regarding this.
public void onCreate(Bundle savedInstanceState)
{
tracker=GoogleAnalyticsTracker.getInstance();
tracker.startNewSession("id",this);
tracker.trackPageView("page");
boolean isTracker = tracker.dispatch();
Log.v(TAG, "isTracker "+isTracker);
}
#Override
protected void onDestroy()
{
super.onDestroy();
tracker.stopSession();
Log.v("newslistView","onDestory()");
}
Thank You.