-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aed7fcb
commit b0217cf
Showing
4 changed files
with
80 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.BugBazaar.utils; | ||
|
||
import android.content.Context; | ||
import android.os.Build; | ||
import android.provider.Settings; | ||
import android.text.TextUtils; | ||
import com.google.android.gms.tasks.OnCompleteListener; | ||
import com.google.android.gms.tasks.Task; | ||
import com.google.firebase.FirebaseApp; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class DeviceDetails { | ||
|
||
public static void initializeFirebase(Context context) { | ||
FirebaseApp.initializeApp(context); | ||
} | ||
|
||
public static String getDeviceName() { | ||
String manufacturer = Build.MANUFACTURER; | ||
String model = Build.MODEL; | ||
if (model.startsWith(manufacturer)) { | ||
return capitalize(model); | ||
} else { | ||
return capitalize(manufacturer) + " " + model; | ||
} | ||
} | ||
|
||
private static String capitalize(String s) { | ||
if (TextUtils.isEmpty(s)) { | ||
return ""; | ||
} | ||
char firstChar = s.charAt(0); | ||
if (Character.isUpperCase(firstChar)) { | ||
return s; | ||
} else { | ||
return Character.toUpperCase(firstChar) + s.substring(1); | ||
} | ||
} | ||
|
||
public static String getDeviceId(Context context) { | ||
return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); | ||
} | ||
|
||
} |