Example usage for android.telephony TelephonyManager getDeviceId

List of usage examples for android.telephony TelephonyManager getDeviceId

Introduction

In this page you can find the example usage for android.telephony TelephonyManager getDeviceId.

Prototype

@Deprecated
@SuppressAutoDoc 
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
public String getDeviceId() 

Source Link

Document

Returns the unique device ID, for example, the IMEI for GSM and the MEID or ESN for CDMA phones.

Usage

From source file:com.andybotting.tramhunter.activity.StopDetailsActivity.java

/**
 * Upload statistics to our web server/*from  w  w w. ja  v  a  2 s .c o m*/
 */
private void uploadStats() {
    if (LOGV)
        Log.i(TAG, "Sending stop request statistics");

    // gather all of the device info
    try {
        TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        String device_uuid = tm.getDeviceId();
        String device_id = "00000000000000000000000000000000";
        if (device_uuid != null) {
            device_id = GenericUtil.MD5(device_uuid);
        }

        LocationManager mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
        Location location = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

        // post the data
        HttpClient client = new DefaultHttpClient();
        HttpPost post = new HttpPost("http://tramhunter.andybotting.com/stats/stop/send");
        post.setHeader("Content-Type", "application/x-www-form-urlencoded");

        List<NameValuePair> pairs = new ArrayList<NameValuePair>();
        pairs.add(new BasicNameValuePair("device_id", device_id));
        pairs.add(new BasicNameValuePair("guid", ttService.getGUID()));
        pairs.add(new BasicNameValuePair("ttid", String.valueOf(mStop.getTramTrackerID())));

        if (location != null) {
            pairs.add(new BasicNameValuePair("latitude", String.valueOf(location.getLatitude())));
            pairs.add(new BasicNameValuePair("longitude", String.valueOf(location.getLongitude())));
            pairs.add(new BasicNameValuePair("accuracy", String.valueOf(location.getAccuracy())));
        }

        try {
            post.setEntity(new UrlEncodedFormEntity(pairs));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

        try {
            HttpResponse response = client.execute(post);
            response.getStatusLine().getStatusCode();
        } catch (Exception e) {
            e.printStackTrace();
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:watch.oms.omswatch.application.OMSApplication.java

public String getDeviceId() {
    if (deviceID == null || deviceID.isEmpty()) {
        TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        deviceID = telephonyManager.getDeviceId();
        if (deviceID == null || deviceID.isEmpty())
            deviceID = "DEVICE_ID_NOT_FOUND";
        else if (deviceID.equals("000000000000000"))
            deviceID = "ANDROID_NO_IMEI";
    }/* w w  w. j  a  va  2s.  c  om*/
    return deviceID;
}

From source file:org.hfoss.posit.android.sync.Communicator.java

/**
 * Pull the remote find from the server using the guid provided.
 * //from  w  ww.j a  v a 2 s  .c o m
 * @param guid
 *            , a globally unique identifier
 * @return an associative list of attribute/value pairs
 */
public static ContentValues getRemoteFindById(Context context, String authKey, String guid) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    String server = prefs.getString(SERVER_PREF, "");

    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String imei = telephonyManager.getDeviceId();

    String url = server + "/api/getFind?guid=" + guid + "&authKey=" + authKey;
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("guid", guid));
    pairs.add(new BasicNameValuePair("imei", imei));

    String responseString = doHTTPPost(url, pairs);
    ContentValues cv = new ContentValues();

    Log.i(TAG, "getRemoteFindById = " + responseString);
    try {
        JSONObject jobj = new JSONObject(responseString);
        String findJson = jobj.getString("find");
        JSONObject find = new JSONObject(findJson);
        cv.put(Find.GUID, find.getString(Find.GUID));
        cv.put(Find.PROJECT_ID, find.getInt(Find.PROJECT_ID));
        cv.put(Find.NAME, find.getString(Find.NAME));
        cv.put(Find.DESCRIPTION, find.getString(Find.DESCRIPTION));
        // FIXME add add_time and modify_time for this
        cv.put(Find.TIME, find.getString("add_time"));
        cv.put(Find.TIME, find.getString("modify_time"));
        cv.put(Find.LATITUDE, find.getDouble(Find.LATITUDE));
        cv.put(Find.LONGITUDE, find.getDouble(Find.LONGITUDE));
        cv.put(Find.REVISION, find.getInt(Find.REVISION));

        // Does this find have an image?
        if (jobj.has("images")) {
            String imageIds = jobj.getString("images");
            Log.i(TAG, "imageIds = " + imageIds);

            //check to see if we actually have an image to fetch
            String imageId = parseImageIds(imageIds); //this returns at most one image id

            //we have an image to fetch!
            if (imageId != null) {
                if (getImageOnServer(imageId, context)) {
                    //success
                    Log.i(TAG, "Successfully retrieve image for " + find.getString(Find.GUID));
                } else {
                    //failed
                    Log.i(TAG, "Failed to retrieve image for " + find.getString(Find.GUID));
                }
            }
        }

        // Is this a extended find?
        if (jobj.has(Find.EXTENSION)) {
            String extradata = jobj.getString(Find.EXTENSION);
            Log.i(TAG, "extradata = " + extradata);
            if (!extradata.equals("null"))
                addExtraDataToContentValues(cv, extradata);
        }

        return cv;
    } catch (JSONException e) {
        Log.i(TAG, "JSONException " + e.getMessage());
        e.printStackTrace();
    } catch (Exception e) {
        Log.i(TAG, "Exception " + e.getMessage());
        e.printStackTrace();
    }
    return null;
}

From source file:org.hfoss.posit.android.sync.Communicator.java

public static boolean sendFind(Find find, Context context, String authToken) {
    String url = "";
    boolean success = false;

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    String server = prefs.getString(SERVER_PREF, "");

    if (find.getAction().equals(FindHistory.ACTION_CREATE))
        url = server + "/api/createFind?authKey=" + authToken;
    else if (find.getAction().equals(FindHistory.ACTION_UPDATE))
        url = server + "/api/updateFind?authKey=" + authToken;
    else {/*from  w  w  w . j  av  a2s.c om*/
        Log.e(TAG, "Find object does not contain an appropriate action: " + find);
        return false;
    }

    Log.i(TAG, "SendFind=" + find);

    List<NameValuePair> pairs = getNameValuePairs(find);

    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String imei = telephonyManager.getDeviceId();

    BasicNameValuePair pair = new BasicNameValuePair("imei", imei);
    pairs.add(pair);
    Log.i(TAG, "pairs: " + pairs);
    String responseString = null;

    // Send the find
    try {
        responseString = doHTTPPost(url, pairs);
        DbHelper.getDbManager(context).updateStatus(find, Constants.TRANSACTING);
        DbHelper.getDbManager(context).updateSyncOperation(find, Constants.POSTING);
    } catch (Exception e) {
        Log.i(TAG, e.getMessage());
        Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();
        DbHelper.getDbManager(context).updateStatus(find, Constants.FAILED);
        success = false;
    }

    Log.i(TAG, "sendFind.ResponseString: " + responseString);

    // If the update failed return false
    if (responseString.indexOf("True") == -1) {
        Log.i(TAG, "sendFind result doesn't contain 'True'");
        DbHelper.getDbManager(context).updateStatus(find, Constants.FAILED);
        success = false;
    } else {
        DbHelper.getDbManager(context).updateStatus(find, Constants.SUCCEEDED);
        Log.i(TAG, "sendFind() synced find id: " + find.getId());
        success = true;
    }

    if (!success) {
        //don't bother sending the images if we can't save the find
        return false;
    }

    //Check if the image is out of sync and needs to be sent
    if (Camera.isPhotoSynced(find, context) == false) {
        //We have an image to send!
        //Get the image string
        String fullPicStr = Camera.getPhotoAsString(find.getGuid(), context);
        //Get the thumbnail version of it too
        String thumbPicStr = Camera.getPhotoThumbAsString(find.getGuid(), context);
        //fill in the data needed to send to the photo table
        HashMap<String, String> sendMap = new HashMap<String, String>();
        sendMap.put(COLUMN_IMEI, imei);
        sendMap.put(COLUMN_GUID, find.getGuid());
        sendMap.put(COLUMN_IDENTIFIER, Integer.toString(find.getId()));
        sendMap.put(COLUMN_PROJECT_ID, Integer.toString(find.getProject_id()));
        //          sendMap.put("COLUMN_TIMESTAMP",find.getTime()); //uses current timestamp if not set
        //          sendMap.put("mine_type",imageData.getAsString(PositDbHelper.PHOTOS_MIME_TYPE));      
        sendMap.put(COLUMN_MIME_TYPE, "image/jpeg");
        sendMap.put(COLUMN_DATA_FULL, fullPicStr);
        sendMap.put(COLUMN_DATA_THUMBNAIL, thumbPicStr);

        //ready to send the image to the server
        sendMedia(sendMap, context);
    }

    DbHelper.releaseDbManager();
    return success;
}

From source file:com.andybotting.tubechaser.activity.Home.java

/**
 * Upload statistics to remote server//from  w ww . j a  va2 s.c om
 */
private void uploadStats() {
    if (LOGV)
        Log.v(TAG, "Sending statistics");

    // gather all of the device info
    String app_version = "";
    try {
        try {
            PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0);
            app_version = pi.versionName;
        } catch (NameNotFoundException e) {
            app_version = "N/A";
        }

        TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        String device_uuid = tm.getDeviceId();
        String device_id = "00000000000000000000000000000000";
        if (device_uuid != null) {
            device_id = GenericUtil.MD5(device_uuid);
        }

        String mobile_country_code = tm.getNetworkCountryIso();
        String mobile_network_number = tm.getNetworkOperator();
        int network_type = tm.getNetworkType();

        // get the network type string
        String mobile_network_type = "N/A";
        switch (network_type) {
        case 0:
            mobile_network_type = "TYPE_UNKNOWN";
            break;
        case 1:
            mobile_network_type = "GPRS";
            break;
        case 2:
            mobile_network_type = "EDGE";
            break;
        case 3:
            mobile_network_type = "UMTS";
            break;
        case 4:
            mobile_network_type = "CDMA";
            break;
        case 5:
            mobile_network_type = "EVDO_0";
            break;
        case 6:
            mobile_network_type = "EVDO_A";
            break;
        case 7:
            mobile_network_type = "1xRTT";
            break;
        case 8:
            mobile_network_type = "HSDPA";
            break;
        case 9:
            mobile_network_type = "HSUPA";
            break;
        case 10:
            mobile_network_type = "HSPA";
            break;
        }

        String device_version = android.os.Build.VERSION.RELEASE;

        if (device_version == null) {
            device_version = "N/A";
        }

        String device_model = android.os.Build.MODEL;

        if (device_model == null) {
            device_model = "N/A";
        }

        String device_language = getResources().getConfiguration().locale.getLanguage();
        String home_function = mPreferenceHelper.defaultLaunchActivity();

        // post the data
        HttpClient client = new DefaultHttpClient();
        HttpPost post = new HttpPost("http://tubechaser.andybotting.com/stats/app/send");
        post.setHeader("Content-Type", "application/x-www-form-urlencoded");

        List<NameValuePair> pairs = new ArrayList<NameValuePair>();
        pairs.add(new BasicNameValuePair("device_id", device_id));
        pairs.add(new BasicNameValuePair("app_version", app_version));
        pairs.add(new BasicNameValuePair("home_function", home_function));
        pairs.add(new BasicNameValuePair("device_model", device_model));
        pairs.add(new BasicNameValuePair("device_version", device_version));
        pairs.add(new BasicNameValuePair("device_language", device_language));
        pairs.add(new BasicNameValuePair("mobile_country_code", mobile_country_code));
        pairs.add(new BasicNameValuePair("mobile_network_number", mobile_network_number));
        pairs.add(new BasicNameValuePair("mobile_network_type", mobile_network_type));

        try {
            post.setEntity(new UrlEncodedFormEntity(pairs));
        } catch (UnsupportedEncodingException e) {
            // Do nothing
        }

        try {
            HttpResponse response = client.execute(post);
            response.getStatusLine().getStatusCode();
        } catch (Exception e) {
            if (LOGV)
                Log.v(TAG, "Error uploading stats: " + e.getMessage());
        }

    } catch (Exception e) {
        // Do nothing
    }

}

From source file:org.hfoss.posit.android.web.Communicator.java

public Communicator(Context _context) {
    mContext = _context;//from ww  w.ja v  a  2 s. c om
    mTotalTime = 0;
    mStart = 0;

    mHttpParams = new BasicHttpParams();

    // Set the timeout in milliseconds until a connection is established.
    HttpConnectionParams.setConnectionTimeout(mHttpParams, CONNECTION_TIMEOUT);

    // Set the default socket timeout (SO_TIMEOUT) 
    // in milliseconds which is the timeout for waiting for data.
    HttpConnectionParams.setSoTimeout(mHttpParams, SOCKET_TIMEOUT);

    SchemeRegistry registry = new SchemeRegistry();
    registry.register(new Scheme("http", new PlainSocketFactory(), 80));
    mConnectionManager = new ThreadSafeClientConnManager(mHttpParams, registry);
    mHttpClient = new DefaultHttpClient(mConnectionManager, mHttpParams);

    PreferenceManager.setDefaultValues(mContext, R.xml.posit_preferences, false);
    applicationPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
    setApplicationAttributes(applicationPreferences.getString("AUTHKEY", ""),
            applicationPreferences.getString("SERVER_ADDRESS", server),
            applicationPreferences.getInt("PROJECT_ID", projectId));
    TelephonyManager manager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
    imei = manager.getDeviceId();

}

From source file:com.prey.net.PreyWebServices.java

public PreyHttpResponse registerNewDeviceRemote(Context ctx, String mail, String notificationId,
        String deviceType) throws PreyException {
    PreyConfig preyConfig = PreyConfig.getPreyConfig(ctx);

    String model = Build.MODEL;/*from w w w  . j  a  va 2 s . c om*/
    String vendor = "Google";
    if (!PreyConfig.getPreyConfig(ctx).isCupcakeOrAbove())
        vendor = AboveCupcakeSupport.getDeviceVendor();

    HashMap<String, String> parameters = new HashMap<String, String>();
    parameters.put("device[notification_id]", notificationId);
    parameters.put("device[remote_email]", mail);
    parameters.put("device[title]", vendor + " " + model);
    parameters.put("device[device_type]", deviceType);
    parameters.put("device[os]", "Android");
    parameters.put("device[os_version]", Build.VERSION.RELEASE);
    parameters.put("device[referer_device_id]", "");
    parameters.put("device[plan]", "free");
    parameters.put("device[activation_phrase]", preyConfig.getSmsToRun());
    parameters.put("device[deactivation_phrase]", preyConfig.getSmsToStop());
    parameters.put("device[model_name]", model);
    parameters.put("device[vendor_name]", vendor);

    parameters = increaseData(ctx, parameters);
    TelephonyManager mTelephonyMgr = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
    String imei = mTelephonyMgr.getDeviceId();
    parameters.put("device[physical_address]", imei);

    PreyHttpResponse response = null;
    try {
        String url = "https://panel.preyapp.com/api/v2/remote.json";
        response = PreyRestHttpClient.getInstance(ctx).post(url, parameters);
    } catch (IOException e) {
        throw new PreyException(ctx.getText(R.string.error_communication_exception).toString(), e);
    }

    return response;
}

From source file:com.p2p.misc.DeviceUtility.java

public String getIMEINo() {

    TelephonyManager tManager = (TelephonyManager) mactivity.getSystemService(Context.TELEPHONY_SERVICE);
    String uid = tManager.getDeviceId();

    return uid;//from  w w  w  .ja v a 2 s  . c o m
}

From source file:jp.gr.java_conf.ya.shiobeforandroid3.UpdateTweetDrive.java

@Override
protected final void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build());
    }/* w ww  .  j a  v  a  2  s.c  om*/

    simpleauth();

    crpKey = getString(R.string.app_name);
    final TelephonyManager telephonyManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    crpKey += telephonyManager.getDeviceId();
    crpKey += telephonyManager.getSimSerialNumber();
    try {
        final PackageInfo packageInfo = getPackageManager()
                .getPackageInfo("jp.gr.java_conf.ya.shiobeforandroid3", PackageManager.GET_META_DATA);
        crpKey += Long.toString(packageInfo.firstInstallTime);
    } catch (NameNotFoundException e) {
        WriteLog.write(this, e);
    }

    adapter = new ListAdapter(this, crpKey, null, null);

    setContentView(R.layout.tweet_drive);
    tableLayout1 = (TableLayout) this.findViewById(R.id.tableLayout1);
    editText2 = (EditText) this.findViewById(R.id.editText2);
    editText4 = (EditText) this.findViewById(R.id.editText4);
    editText5 = (EditText) this.findViewById(R.id.editText5);
    editText2.setFocusable(true);
    editText2.setFocusableInTouchMode(true);
    editText2.requestFocusFromTouch();

    pref_app = PreferenceManager.getDefaultSharedPreferences(this);

    final String pref_tl_fontfilename = pref_app.getString("pref_tl_fontfilename", "");
    if (pref_tl_fontfilename.equals("") == false) {
        try {
            WriteLog.write(this, "pref_tl_fontfilename: " + pref_tl_fontfilename);
            fontUtil.loadFont(pref_tl_fontfilename, this);

            fontUtil.setFont(editText2, this);
            fontUtil.setFont(editText4, this);
            fontUtil.setFont(editText5, this);
        } catch (final Exception e) {
            WriteLog.write(this, e);
        }
    }

    final float pref_tl_fontsize_updatetweet = ListAdapter.getPrefFloat(this, "pref_tl_fontsize_updatetweet",
            "14");
    editText2.setTextSize(pref_tl_fontsize_updatetweet);
    editText4.setTextSize(pref_tl_fontsize_updatetweet);
    editText5.setTextSize(pref_tl_fontsize_updatetweet);

    final String pref_tl_bgcolor_updatetweet = pref_app.getString("pref_tl_bgcolor_updatetweet", "#000000");
    pref_tl_fontcolor_text_updatetweet = pref_app.getString("pref_tl_fontcolor_text_updatetweet", "#ffffff");
    pref_tl_fontcolor_text_updatetweet_over = pref_app.getString("pref_tl_fontcolor_text_updatetweet_over",
            "#ff0000");

    if (pref_tl_bgcolor_updatetweet.equals("") == false) {
        try {
            tableLayout1.setBackgroundColor(Color.parseColor(pref_tl_bgcolor_updatetweet));
        } catch (final IllegalArgumentException e) {
        }
    }
    setTextColorOnTextChanged();
    if (pref_tl_fontcolor_text_updatetweet.equals("") == false) {
        try {
            editText4.setTextColor(Color.parseColor(pref_tl_fontcolor_text_updatetweet));
            editText5.setTextColor(Color.parseColor(pref_tl_fontcolor_text_updatetweet));
        } catch (final IllegalArgumentException e) {
        }
    }

    editText2.addTextChangedListener(new TextWatcher() {
        @Override
        public final void afterTextChanged(final Editable s) {
            setTextColorOnTextChanged();
        }

        @Override
        public final void beforeTextChanged(final CharSequence s, final int start, final int count,
                final int after) {
        }

        @Override
        public final void onTextChanged(final CharSequence s, final int start, final int before,
                final int count) {
            setTextColorOnTextChanged();
        }
    });
    editText2.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public final void onFocusChange(final View arg0, final boolean arg1) {
            setTextColorOnTextChanged();
        }
    });

    editText2.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public final boolean onLongClick(final View v) {
            tweet();
            return true;
        }
    });

    map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

    final String pref_map_site = pref_app.getString("pref_map_site", "0");
    if (pref_map_site.equals("0")) {
        try {
            MapsInitializer.initialize(this);
        } catch (final Exception e) {
            toast("You must update Google Google Play Service.");
        }
    } else {
        try {
            map.setMapType(GoogleMap.MAP_TYPE_NONE);

            final TileProvider tileProvider = new UrlTileProvider(256, 256) {
                @Override
                public final synchronized URL getTileUrl(final int x, final int y, final int zoom) {
                    // The moon tile coordinate system is reversed.  This is not normal.
                    // int reversedY = (1 << zoom) - y - 1;
                    // String s = String.format(Locale.US, MOON_MAP_URL_FORMAT, zoom, x, reversedY);
                    final String s = String.format(Locale.US,
                            ((pref_map_site.equals("0")) ? ListAdapter.OSM_MAP_URL_FORMAT
                                    : ListAdapter.GSI_MAP_URL_FORMAT),
                            zoom, x, y);
                    URL url = null;
                    try {
                        url = new URL(s);
                    } catch (final MalformedURLException e) {
                        throw new AssertionError(e);
                    }
                    return url;
                }
            };

            map.addTileOverlay(new TileOverlayOptions().tileProvider(tileProvider));
        } catch (final Exception e) {
            try {
                MapsInitializer.initialize(this);
            } catch (final Exception e1) {
                toast("You must update Google Maps.");
            }
        }
    }

    moveTo(35.66279, 139.759848, 0.0f, 0.0f);
}

From source file:com.prey.net.PreyWebServices.java

/**
 * Register a new device for a given API_KEY, needed just after obtain the
 * new API_KEY./*from  w ww  .  ja  v  a 2 s  . c  o  m*/
 * 
 * @throws PreyException
 */
private PreyHttpResponse registerNewDevice(Context ctx, String api_key, String deviceType)
        throws PreyException {
    PreyConfig preyConfig = PreyConfig.getPreyConfig(ctx);

    String model = Build.MODEL;
    String vendor = "Google";
    if (!PreyConfig.getPreyConfig(ctx).isCupcakeOrAbove())
        vendor = AboveCupcakeSupport.getDeviceVendor();

    HashMap<String, String> parameters = new HashMap<String, String>();
    parameters.put("api_key", api_key);
    parameters.put("title", vendor + " " + model);
    parameters.put("device_type", deviceType);
    parameters.put("os", "Android");
    parameters.put("os_version", Build.VERSION.RELEASE);
    parameters.put("referer_device_id", "");
    parameters.put("plan", "free");
    parameters.put("activation_phrase", preyConfig.getSmsToRun());
    parameters.put("deactivation_phrase", preyConfig.getSmsToStop());
    parameters.put("model_name", model);
    parameters.put("vendor_name", vendor);

    parameters = increaseData(ctx, parameters);
    TelephonyManager mTelephonyMgr = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
    //String imsi = mTelephonyMgr.getSubscriberId();
    String imei = mTelephonyMgr.getDeviceId();
    parameters.put("physical_address", imei);

    PreyHttpResponse response = null;
    try {
        String apiv2 = FileConfigReader.getInstance(ctx).getApiV2();
        String url = PreyConfig.getPreyConfig(ctx).getPreyUrl().concat(apiv2).concat("devices.json");
        PreyLogger.d("url:" + url);
        response = PreyRestHttpClient.getInstance(ctx).post(url, parameters);
        PreyLogger.d("response:" + response.getStatusLine() + " " + response.getResponseAsString());
        // No more devices allowed

        if ((response.getStatusLine().getStatusCode() == 302)
                || (response.getStatusLine().getStatusCode() == 422)
                || (response.getStatusLine().getStatusCode() == 403)) {
            throw new NoMoreDevicesAllowedException(
                    ctx.getText(R.string.set_old_user_no_more_devices_text).toString());
        }
        if (response.getStatusLine().getStatusCode() > 299) {
            throw new PreyException(ctx.getString(R.string.error_cant_add_this_device,
                    "[" + response.getStatusLine().getStatusCode() + "]"));
        }
    } catch (IOException e) {
        throw new PreyException(ctx.getText(R.string.error_communication_exception).toString(), e);
    }

    return response;
}