Posts

Android - Optimize and Publish Apps

Before developers publish apps, the following things should be done to prevent the Google Play Console from annoying us. 1. Change the package name com.example.<Name of project> to com.<Name of organization>.<Name of project> in the build.gradle file. 2. Check and adjust versionCode and versionName in the build.gradle file properly. 3. Reduce your app size by using android { // Other settings buildTypes { release { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } in the build.gradle file. 4. Convert images to WebP by right clicking on an image file or an image folder, and then click convert to WebP. 5. Prepare and upload one 512 x 512 32-bits PNG icon file and one 1024 x 500 24-bits PNG feature graphic file. References: https://developer.android.com/topic/performance/...

Android - Clipboard and Keyboard

1. Copy text to the clipboard. In Activity, use val clipboard = getSystemService(ClipboardManager::class.java) val clipData = ClipData.newPlainText("The first copied text.", "Hello World!") clipboard.setPrimaryClip(clipData) In Fragment, use val clipboard = requireActivity().getSystemService(ClipboardManager::class.java) val clipData = ClipData.newPlainText("The first copied text.", "Hello World!") clipboard.setPrimaryClip(clipData) 2. Close the keyboard and the cursor. In Activity, use getSystemService(InputMethodManager::class.java) .hideSoftInputFromWindow(<The View object of scope>.windowToken, 0) currentFocus?.clearFocus() In Fragment, use requireActivity().getSystemService(InputMethodManager::class.java) .hideSoftInputFromWindow(<The View object of scope>.windowToken, 0) requireActivity().currentFocus?.clearFocus()

Android - Scrollable TextView in ViewPager2

1. Check the scrollbars in the attributes of TextView. 2. Use textView.movementMethod = ScrollingMovementMethod() 3. Use textView.setOnTouchListener { _, _ -> textView.parent.requestDisallowInterceptTouchEvent(true) false // It must return false to make TextView scrollable in ViewPager2. } Reference: https://stackoverflow.com/questions/29471842/allow-scrolling-edittext-and-swiping-viewpager

Android - ViewPager2, TabLayout, and Fragment

1. Prerequisites: Before using ViewPager2 and TabLayout, append implementation 'com.google.android.material:material:$material_version' to the build.gradle file. 2. Usage: a. Use ViewPager2 and TabLayout in the activity_main layout. b. Create Fragment classes and their layout files. Warning: All subclasses of Fragment must include a public no-argument constructor. class FragmentA: Fragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { return inflater.inflate(R.layout.fragment_a, container, false) } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) // Change UI and use listeners here. } } c. Connect Fragment to TabLayout in MainActivity. viewPager.adapter = object : FragmentStateAdapter(this) { override fun getItemCount(): Int { ...

Blogger - Troubleshoot Issues of Blogger

1. Fail to create tables with horizontal scrollbars. Simply, customize the HTML of Blogger theme and change the following content body{ overflow-wrap:break-word; word-break:break-all; word-wrap:break-word } to body{ overflow-wrap:break-word; word-break:keep-all; word-wrap:break-word } 2. Fail to insert tab keys. Instead of using &#09; , use &Tab; References: https://dev.w3.org/html5/html-author/charref

TwinCAT - Troubleshoot Issues of TwinCAT 3

1. VirtualBox error and real-time configuration As soon as a component of the computer uses Hyper-V, only the engineering environment (XAE) can be used on this computer, not the runtime environment (XAR). The VT-x-CPU function is mandatory with 64-bit operating systems (must be enabled in BIOS and be available). To release CPUs to TwinCAT real-time operation, users should run: msconfig Leave one or more CPUs for the operation. Reboot is needed. Note that hard real-time operation is supported only on Intel Ethernet controllers. 2. 'TwinCAT System' (10000): Sending ams command >> Init4\RTime: Start Interrupt: Ticker started >>AdsWarning: 4115 (0x1013, RTIME: system clock setup fails. Run: C:/TwinCAT/3.1/System/win8settick.bat Reboot is needed. 3. AdsWarning 1823 LAN adapters need to install "TwinCAT RT-Ethernet Filter Driver" from Windows control panel or TwinCAT settings. 4. ESI files, also called XML description, need to be ...

Cygwin - Troubleshoot Issues of Installing Kaldi on Cygwin

1. Files are too big. Enter the following command before configure in kaldi/src: export CXXFLAGS=”-O3” 2. OpenFst error After install tools, install openfst 1.6.7 in kaldi/tools again. Append option "--fst-root=" and location of openfst in /usr to ./configure. 3. Replace Intel MKL with OpenBLAS. By appending "--mathlib=OPENBLAS" to ./configure, use OpenBLAS instead of Intel MKL.