How to track and analyze an Android app?

I want to know which users are using my application.

I think I need a device identifier, network type, network provider name and its ip address. is there any framework for this? And, of course, I will ask the user to enable it before I can do it, and leave the option to disable it when the user wants to disable it.

+5
source share
4 answers

You can use a service such as Flurry or Google Analytics to collect some of this data (not sure about the device’s identifier or IP address), but as others have said, you may want to make this “choice” using the application preference due to privacy issues.

+3
source

You can do this relatively easily by reading this information in your application programmatically, and then send it to you via SMS, email, or simply upload it to the server.

However, I do not think that users will be very lucky that you do this. At least you should let them know.

For identifier you can use this:

http://developer.android.com/reference/android/telephony/TelephonyManager.html#getDeviceId%28%29

IP-, :

public String getLocalIpAddress() {
    try {
        for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
            NetworkInterface intf = en.nextElement();
            for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
                InetAddress inetAddress = enumIpAddr.nextElement();
                if (!inetAddress.isLoopbackAddress()) {
                    return inetAddress.getHostAddress().toString();
                }
            }
        }
    } catch (SocketException ex) {
        Log.e(LOG_TAG, ex.toString());
    }
    return null;
}

( , Wi-Fi ), :

ConnectivityManager conMan = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

//mobile
State mobile = conMan.getNetworkInfo(0).getState();

//wifi
State wifi = conMan.getNetworkInfo(1).getState();

:

if (mobile == NetworkInfo.State.CONNECTED || mobile == NetworkInfo.State.CONNECTING) {
    //mobile
} else if (wifi == NetworkInfo.State.CONNECTED || wifi == NetworkInfo.State.CONNECTING) {
    //wifi
}
+2

, , . -, , . , ?

Localytics - : , SDK , , 10 .

[ : ]

+1

Google SDK . : http://code.google.com/mobile/analytics/docs/android/

:

Google Analytics SDK , Google Analytics.

-. Analytics , , SDK .

SDK :

- -, , . , . HTML-, , ( ) . Analytics, Content, HTML .

. , Google Analytics. , . , play/stop/pause . Google Analytics . , .

0

All Articles