How to save info such as a user name to the device?
With the help of SharedPreferences you can store the info locally use the dependencies in pubspec.yaml file
dependencies:
shared_preferences: ^0.5.7+3
and import the package :
import 'package:shared_preferences/shared_preferences.dart';
String userName;
String userId;
String salary;
_saveValues(bool val, int screen) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString("name", responseJson.name);
prefs.setString("id", "userId");
prefs.setString("salary", "1200000");
}
getSharedPreferencesValue() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
userName = prefs.getString("name")?? "";
userId = prefs.getString("password")?? "";
salary = prefs.getString("salary")?? "";
}
Hope this will help you!!
Best way to get user-defined custom name for an Android device
I have posted this answer before:
Use
String ownerInfo = Settings.Secure.getString(getContentResolver(),
"lock_screen_owner_info");
Make sure to catch SettingNotFoundException
Update
As of Android 4.4.2 the owner info value is moved to lock screen database,/data/system/locksettings.db
, to which 3rd-party apps have no read/write access. That's, there is no reliable way of reading owner info for later Android versions.
How to get the phone user's name?
You can get users email with GET_ACCOUTNS permission but for getting User Name you need to implement some OAuth to access User's Name and other profile informations.
One way is to user Google Sign-in developers.google.com/identity/sign-in/android/people
How to find last logged in user on Intune/Azure
To fetch the details of last logged on users on Intune, make use of below query in Microsoft Graph Explorer:
GET https://graph.microsoft.com/beta/deviceManagement/managedDevices/{managedDeviceId}
The above query will only work on beta version of Microsoft Graph.
Please check the required permissions below:
In the output response, you can find the UserId
and LastlogonDateTime
in usersLoggedOn field.
In order to display the username via UserId
, make use of powershell script mentioned in this reference.
Note: The Microsoft Graph API for Intune requires an active Intune license for the tenant. Beta version is subject to change don't use it for production.
For more information, please refer below links:
Get windowsManagedDevice - Microsoft Graph beta | Microsoft Docs
Find out last logon user of MDM assigned Coporate Device - Microsoft Q&A
Is there any way i can get the name of the user of the phone(android) in flutter app?
Hello you can use this plugin device_info, you can see the documentation about it here :
https://pub.dev/packages/device_info#-example-tab-
import 'package:device_info/device_info.dart';
void getDeviceinfo() async {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidDeviceInfo = await deviceInfo.androidInfo; // instantiate Android Device Information
IosDeviceInfo iosInfo = await deviceInfo.iosInfo; // instantiate IOS Device Information
print("for Android : ${androidDeviceInfo.product}");
print("for IOS : ${iosInfo.name}");
}
Related Topics
Symbolicate Crash in iOS8 with Xcode 6 .1
Where Is the Official Documentation for Cvopenglestexture Method Types
Detect Moment When Newline Starts in Uitextview
How to Debug an Issue with a Release Mode Build in iOS
How to Get the MAC Os X Firewall to Permanently Allow My iOS App
How Do Set a Width and Height of an Image in Swift
How to Implement Localization in Swift Ui
Less Blur with 'Visual Effect View with Blur'
What Is Container View in iOS 5 Sdk
iOS Enterprise Provisioning Profile Expiration
Add Uiview Banner Above Status Bar iOS 7
Pulling Data from a Cmsamplebuffer in Order to Create a Deep Copy