Android Open Source - countly-sdk-android Countly Activity






From Project

Back to project page countly-sdk-android.

License

The source code is released under:

Copyright (c) 2012, 2013 Countly Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Soft...

If you think the Android project countly-sdk-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package ly.count.android.example;
/*from   www.  j a va  2s  .c o  m*/
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import java.util.HashMap;

import ly.count.android.api.Countly;
import ly.count.android.api.DeviceId;

public class CountlyActivity extends Activity {
  
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

    /** You should use cloud.count.ly instead of YOUR_SERVER for the line below if you are using Countly Cloud service */
        Countly.sharedInstance().init(this, "https://YOUR_SERVER", "YOUR_APP_KEY");
    
    /*********
     * Providing user data
     *********/
    setUserData();

        Countly.sharedInstance().recordEvent("test", 1);

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Countly.sharedInstance().recordEvent("test2", 1, 2);
            }
        }, 5000);

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Countly.sharedInstance().recordEvent("test3");
            }
        }, 10000);
    }
    
    @Override
    public void onStart()
    {
      super.onStart();
        Countly.sharedInstance().onStart();
    }

    @Override
    public void onStop()
    {
        Countly.sharedInstance().onStop();
      super.onStop();
    }
  
  public void setUserData(){
    HashMap<String, String> data = new HashMap<String, String>();
    data.put("name", "Firstname Lastname");
    data.put("username", "nickname");
    data.put("email", "test@test.com");
    data.put("organization", "Tester");
    data.put("phone", "+123456789");
    data.put("gender", "M");
    //provide url to picture
    //data.put("picture", "http://example.com/pictures/profile_pic.png");
    //or locally from device
    //data.put("picturePath", "/mnt/sdcard/portrait.jpg");
    data.put("byear", "1987");
    
    //providing any custom key values to store with user
    HashMap<String, String> custom = new HashMap<String, String>();
    custom.put("country", "Turkey");
    custom.put("city", "Istanbul");
    custom.put("address", "My house 11");
    Countly.sharedInstance().setUserData(data, custom);
  }
}




Java Source Code List

ly.count.android.api.AdvertisingIdAdapter.java
ly.count.android.api.ConnectionProcessor.java
ly.count.android.api.ConnectionQueue.java
ly.count.android.api.CountlyStore.java
ly.count.android.api.Countly.java
ly.count.android.api.DeviceId.java
ly.count.android.api.DeviceInfo.java
ly.count.android.api.EventQueue.java
ly.count.android.api.Event.java
ly.count.android.api.OpenUDIDAdapter.java
ly.count.android.api.UserData.java
ly.count.android.example.CountlyActivity.java
org.OpenUDID.OpenUDID_manager.java
org.OpenUDID.OpenUDID_service.java