MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / getUniqueDeviceKey

Method getUniqueDeviceKey

CodenameOne/src/com/codename1/io/Log.java:137–181  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

135 ///
136 /// a unique device id
137 public static String getUniqueDeviceKey() {
138 String devId = Preferences.get("DeviceKey__$", null);
139 if (devId != null) {
140 return devId;
141 }
142
143 devId = Preferences.get("UDeviceKey__$", null);
144 if (devId != null) {
145 return devId;
146 }
147
148 String buildKey = Display.getInstance().getProperty("build_key", null);
149 if (buildKey == null) {
150 buildKey = "";
151 }
152
153 // request the device id from the server
154 ConnectionRequest r = new ConnectionRequest() {
155 @Override
156 protected void readResponse(InputStream input) throws IOException {
157 com.codename1.io.Preferences.set("UDeviceKey__$", Util.readToString(input));
158 }
159
160 @Override
161 protected void handleErrorResponseCode(int code, String message) {
162 Log.p("Error in sending log to server: " + code + " " + message);
163 }
164
165 @Override
166 protected void handleException(Exception err) {
167 err.printStackTrace();
168 }
169 };
170 r.setPost(true);
171 r.setUrl(Display.getInstance().getProperty("cloudServerURL", "https://cloud.codenameone.com/register/device"));
172 r.addArgument("appName", Display.getInstance().getProperty("AppName", ""));
173 r.addArgument("buildKey", buildKey);
174 r.addArgument("builtByUser", Display.getInstance().getProperty("built_by_user", ""));
175 r.addArgument("packageName", Display.getInstance().getProperty("package_name", ""));
176 r.addArgument("appVersion", Display.getInstance().getProperty("AppVersion", "0.1"));
177 r.addArgument("platformName", Display.getInstance().getPlatformName());
178 //r.addArgument("u", Display.getInstance().getProperty("udid", ""));
179 com.codename1.io.NetworkManager.getInstance().addToQueueAndWait(r);
180 return Preferences.get("UDeviceKey__$", null);
181 }
182
183 /// Sends the current log to the cloud. Notice that this method is synchronous and
184 /// returns only when the sending completes

Callers 2

sendLogImplMethod · 0.95
invokeStatic9Method · 0.80

Calls 9

getMethod · 0.95
getInstanceMethod · 0.95
setPostMethod · 0.95
setUrlMethod · 0.95
addArgumentMethod · 0.95
getPropertyMethod · 0.65
getPlatformNameMethod · 0.45
addToQueueAndWaitMethod · 0.45
getInstanceMethod · 0.45

Tested by

no test coverage detected