Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to track and analysis android app? [closed]

I want to know what kind of users are using my app.

I think I need the device id, the network type, the network provider name and its ip address. is there any framework to do this thing? And of course I will ask user to enable it before I can do it and leave an option to disable it when user want to toggle it off.

like image 292
virsir Avatar asked May 25 '10 15:05

virsir


People also ask

How do I find recently closed apps on Android?

Swipe up from the bottom, hold, then let go. If you're on Android Go with 3-button navigation, tap Recent apps .

Can Android apps stop tracking?

For many people, this is the main reason to turn off app tracking on Android. If you want to turn off location tracking on Android apps, open the Settings app on your Android device and go to the Location option. You can turn location tracking off here.


2 Answers

You can use a service like Flurry or Google Analytics to gather some of this data (not sure about device ID or IP address), but as others have said, you might want to make this "opt-in" via an application preference due to privacy concerns.

like image 71
Erich Douglass Avatar answered Oct 07 '22 15:10

Erich Douglass


You could do this relatively easy by reading this information in your app programatically and then send it to you per sms, email, or just upload it to a server.

However, I don't think that the users will be very lucky that you're doing this. At least you have to inform them about that.

For a ID you could use this:

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

To get the IP you could use this code:

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;
}

To get the network type (I think your talking about wifi or mobile) you can use this code snippet:

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

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

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

and then use it like that:

if (mobile == NetworkInfo.State.CONNECTED || mobile == NetworkInfo.State.CONNECTING) {
    //mobile
} else if (wifi == NetworkInfo.State.CONNECTED || wifi == NetworkInfo.State.CONNECTING) {
    //wifi
}
like image 36
RoflcoptrException Avatar answered Oct 07 '22 14:10

RoflcoptrException