简体   繁体   中英

Flurry not sending events to server till application restart

I have implemented Flurry in my Android app.It sends events to the flurry server but only when the application is started second time. For eg: if user used the app on 1st September and again used it on 1st October then the stats of 1st September will be sent on 1st October,but i want events to be available after the app closes or in the real-time.

Here is My code:

package com.example.flurry;

import com.flurry.android.FlurryAgent;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;


public class Flurry extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_flurry);

        FlurryAgent.setLogEnabled(true);

        FlurryAgent.init(getBaseContext(), "FS3C2XNX8HRPD6GDJ7C2");

        Button check = (Button) findViewById(R.id.button1);
        Button stop = (Button) findViewById(R.id.button2);

        check.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                FlurryAgent.logEvent("check button pressed");

                // Perform action on click
            }
        });

        stop.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                FlurryAgent.logEvent("stop button pressed");


            }
        });


    }



    @Override
    public void onStart()
    {
       super.onStart();
       FlurryAgent.setLogEnabled(true);
       FlurryAgent.setLogEvents(true);
       FlurryAgent.setLogLevel(Log.VERBOSE);
       FlurryAgent.onStartSession(getBaseContext(), "FS3C2***************");
       // your code
    }

    @Override
    public void onStop()
    {
       super.onStop();
       FlurryAgent.onEndSession(this);
       // your code
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.flurry, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

When I restart the app in logcat following line comes:

09-02 10:28:31.817: W/FlurryAgent(5684): Analytics report sent.

How can I send event data to the server in real-time or at application exit.

Remove the onStop and onStart functions as these are deprecated in the latest flurry SDK and don't directly close the app.press the home button before closing the application. It will work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM