File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
AndroidSDKTests/src/test/java/com/leanplum
AndroidSDK/src/com/leanplum Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -295,6 +295,20 @@ public static void setDeviceId(String deviceId) {
295295 userSpecifiedDeviceId = true ;
296296 }
297297
298+ /**
299+ * Gets the deviceId in the current Leanplum session. This should only be called after
300+ * {@link Leanplum#start}.
301+ *
302+ * @return String Returns the deviceId in the current Leanplum session.
303+ */
304+ public static String getDeviceId () {
305+ if (!LeanplumInternal .hasCalledStart ()) {
306+ Log .e ("Leanplum.start() must be called before calling getDeviceId." );
307+ return null ;
308+ }
309+ return Request .deviceId ();
310+ }
311+
298312 /**
299313 * Sets the application context. This should be the first call to Leanplum.
300314 */
Original file line number Diff line number Diff line change @@ -1213,4 +1213,17 @@ public void variablesChanged() {
12131213 handlers = CollectionUtil .uncheckedCast (TestClassUtil .getField (Leanplum .class , "onceNoDownloadsHandlers" ));
12141214 assertEquals (0 , handlers .size ());
12151215 }
1216+
1217+ /**
1218+ * Test for {@link Leanplum#getDeviceId()}.
1219+ */
1220+ @ Test
1221+ public void testGetDeviceId () {
1222+ String deviceId = Leanplum .getDeviceId ();
1223+ assertNull (deviceId );
1224+ Leanplum .start (mContext );
1225+ assertTrue (Leanplum .hasStarted ());
1226+ deviceId = Leanplum .getDeviceId ();
1227+ assertNotNull (deviceId );
1228+ }
12161229}
You can’t perform that action at this time.
0 commit comments