Android 11 removes the three menus [Bluetooth], [Cast], and [Files received via Bluetooth] in the connection preferences.

Encountered a project that does not require WiFi or Bluetooth. The customer requested that the Bluetooth-related function menu items in Settings be removed. Because the hardware is not attached, the software corresponding to it must also be removed, because the IC chip is Bluetooth and WiFi is two-in-one, so in fact WiFi is also not […]

Mathematical Model 2: Technique for Order Preference by Similarity to Ideal Solution

Table of Contents 1 Introduction 2. Model (1) Essence (2) steps STEP1: Positive indicators STEP2: Matrix normalization STEP3: Calculate the score and normalize it 3. Code 1. Introduction The TOPSIS method is a commonly used comprehensive evaluation method that can make full use of the information of the original data, and its results can accurately […]

Explore the Jetpack PreferenceDataStore principle

Foreword What is DataStore? Jetpack DataStore is a data storage solution, which can store key-value pairs like SharedPreferences, and can also use Protocol Buffers protocol to store typed object data. DataStore uses Kotlin Flow to store data asynchronously. Android officially recommends that we migrate SharedPreferencs to DataStore. Preference DataStore and Proto DataStore DataStore provides two […]

SharedPreference Caton Optimization for Android Performance Optimization

The source code below is based on Android api 31 1. Use of SharedPreference val sharePref = getPreferences(Context.MODE_PRIVATE) with(sharePref. edit()) {<!– –> putBoolean(“isLogin”, true) putInt(“age”, 18) apply() } val isLogin = sharePref. getBoolean(“isLogin”, false) val age = sharePref. getInt(“age”, -1) Log.d(TAG, “isLogin $isLogin age $age”) 1. Get SharedPreferencesImpl The implementation class for obtaining sharedpreferences is […]

Performance Optimization: How to Completely Solve the Caton Caused by SharedPreferences

Background After launching the ANR monitoring platform, a lot of ANR logs have been collected online. From the flame graph information, the function is blocked on QueuedWork related functions. This article mainly introduces the reasons for this phenomenon and how to solve this problem. The solution introduced in this article has been put on github […]

android jetpack DataStore (java) instead of SharedPreferences

Table of Contents How to use Preferences DataStore? import dependencies Create a Preferences DataStore read content write content How to use Proto DataStore? import dependencies create proto Create a Serializer Use DataStore DataStore provides two different implementations: Preferences DataStore and Proto DataStore. Preferences DataStore stores and accesses data using keys Proto DataStore stores data as […]

Android experiment nine – use SharedPreferences to store simple data

Complete the following procedures (the main Activity interface is shown in Figure 1): Click the “Parameter Settings” button in Figure 1 to start the Activity shown in Figure 2. After the user enters the user name in Figure 2, click the “OK” button to close the Activity (you need to use SharedPreferences.Editor Save the username), […]

Realize offline and real-time consumer product transaction behavior analysis based on Hadoop ecology (consumption behavior analysis, purchase preference analysis)

Project Background Big data professional comprehensive project practice, the data set adopts the public data set of Ali Tianchi, download link: consumer commodity transaction research list This data set is a sample set with more than 5,000 records in total, and each record represents a consumer’s commodity transaction research information. Below is a description of […]

NeoPreference: a tool to simplify the use of SharedPreferences

Project address: https://github.com/Nagi1225/NeoPreference After a while, I found that many people read the previous article “A Simple, Elegant and Safe Usage of SharedPreferences”, so I fixed some problems, organized the code, and published it to jitpack for easy use. This article is the previous summary, induction and optimization. For the thinking process, you can refer […]

Mobile application development technology – SharedPreferences storage

Front-end XML <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” xmlns:tools=”http://schemas.android.com/tools” android:layout_width=”match_parent” android:layout_height=”match_parent” android:orientation=”vertical” android:background=”@color/teal_200″ android:padding=”10dp” tools:context=”.MainActivity”> <ImageView android:layout_width=”70dp” android:layout_height=”70dp” android:src=”@drawable/head” android:layout_gravity=”center_horizontal” android:layout_marginTop=”30dp” /> <RelativeLayout android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_marginTop=”15dp” android:background=”@color/white”> <TextView android:id=”@ + id/tv_username” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”Account:” android:layout_marginLeft=”10dp” android:layout_centerVertical=”true” android:textColor=”@color/black” android:textSize=”20sp”/> <EditText android:id=”@ + id/username” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_toEndOf=”@ + id/tv_username” android:layout_marginStart=”15dp” android:padding=”10dp” /> </RelativeLayout> <RelativeLayout android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:background=”@color/white”> […]