Context-detection API for Android developed as a university project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ThanksActivity.java 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package uk.co.md87.android.sensorlogger.activities;
  6. import android.app.Activity;
  7. import android.os.Bundle;
  8. import android.telephony.TelephonyManager;
  9. import android.widget.TextView;
  10. import com.flurry.android.FlurryAgent;
  11. import uk.co.md87.android.sensorlogger.R;
  12. /**
  13. *
  14. * @author chris
  15. */
  16. public class ThanksActivity extends Activity {
  17. /** {@inheritDoc} */
  18. @Override
  19. public void onCreate(final Bundle icicle) {
  20. super.onCreate(icicle);
  21. setContentView(R.layout.thanks);
  22. final String imei = ((TelephonyManager) getSystemService(TELEPHONY_SERVICE)).getDeviceId();
  23. final String code = "http://MD87.co.uk/android/p/" + getCode(imei);
  24. ((TextView) findViewById(R.id.thankslink)).setText(code);
  25. //Linkify.addLinks(((TextView) findViewById(R.id.viewcaption)), Linkify.WEB_URLS);
  26. }
  27. public String getCode(final String imei) {
  28. final String chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=_";
  29. final StringBuilder builder = new StringBuilder();
  30. long val = Long.decode(imei == null ? "0"
  31. : imei.matches("^[0-9]+$") ? imei : ("0x" + imei));
  32. while (val > 0) {
  33. final long bit = val % chars.length();
  34. val = val / chars.length();
  35. builder.insert(0, chars.charAt((int) bit));
  36. }
  37. while (builder.length() < 10) {
  38. builder.insert(0, "a");
  39. }
  40. return builder.toString();
  41. }
  42. /** {@inheritDoc} */
  43. @Override
  44. protected void onStart() {
  45. super.onStart();
  46. FlurryAgent.onStartSession(this, "TFBJJPQUQX3S1Q6IUHA6");
  47. }
  48. /** {@inheritDoc} */
  49. @Override
  50. protected void onStop() {
  51. super.onStop();
  52. FlurryAgent.onEndSession(this);
  53. }
  54. }