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.
Swipe up from the bottom, hold, then let go. If you're on Android Go with 3-button navigation, tap Recent apps .
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.
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.
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With