How to test the ram memory usage in react native? - reactjs

I am very new on react native, I am trying to know how to see the memory usage that my app need when I developing, and some tricks to improve this.

If you are here in 2022. Use this:
Android Profiler: https://developer.android.com/studio/profile/android-profiler
Android Device Monitor was deprecated since Android Studio 3.1.
More info here: https://developer.android.com/studio/profile/monitor

For Android, I hope this helps
adb shell dumpsys meminfo
But this is not human friendly, very difficult to understand.
You can also try.
Android Device Monitor, if you have Android Studio, you already have it. Open it up with these steps:
Run React Native app normally (react-native run-android)
Run Android Studio
On the menu, click Tools → Android → Enable ADB Integration
Click Tools → Android → Android Device Monitor
When Android Device Monitor shows up, click Monitor → Preferences
On the dialog, in Android → DDMS, check these two options:
Heap updates enabled by default
Thread updates enable by default (optional)
Then you will see a pie-chart type data in System Information tab.
In order check Heap allocation and/or usage, select your app on the Devices tab on the left.
Reference
https://shift.infinite.red/react-native-android-app-memory-investigation-55695625da9c

Related

How to capture screenshot on KaiOS device (Nokia 8110 4G)

Does anyone know how to capture screenshot on Nokia 8110 4G (KaiOS)?
You may follow these steps to get screenshot via Firefox WebIDE.
On the device - dial *#*#33284#*#* to enable developer mode. There will be a bug icon on the status bar.
Download Firefox 58.
[Important] Disable your internet access, this is to prevent Firefox got updated to a newer version which might break the WebIDE functionality.
Launch Firefox 58 and disable auto update.
Resume your internet access.
Launch WebIDE in Tools > Web Developer > WebIDE.
Restart the WebIDE (because the ADB helper would be downloaded automatically, and need to restart it to take effect.)
Now you should be able to see Nokia 8110 detected under "USB devices" at the right panel. (if not, see below)
Click the device, "Nokia 8110", and then click Screenshot.
See here for a sample screenshot.
Troubleshooting if you failed to see Nokia 8110 detected:
I found it might fail if your Firefox got updated to a newer version automatically, in this case you might need to leverage creating new profile to start over again, see here for details.
If the Firefox version stays correctly at 58 but after you click the device, it shows an error saying "Failed to connect", try to reboot the phone and also restart the WebIDE as this post suggested.
EDIT: Yes it is - Joelbert W's answer worked and makes the other responses a bit silly by comparison, just * and # together :-)
Unfortunately, it is currently not possible :-(
https://twitter.com/KaiHelps/status/1072446931421593603
https://twitter.com/KaiHelps/with_replies
It is possible either with WebIDE connection or with a custom ROM such as GerdaOS where you can make screenshots by pressing Power with half-open slide lid.
However, I'd only recommend installing custom ROMs for experienced users only since you can't use any official updates after installing them.
So I have a go flip 3, and i stumbled on if u press * and # almost simultaneously, it takes a screenshot.
I believe it's possible on certain devices and OS versions using the Screen Capture API as well.

How to show soft keyboard on Android Things?

I'm trying to show soft keyboard on Android Things, Raspberry Pi 3. I tried the methods below, but not succeeded so far:
<activity
...
android:windowSoftInputMode="stateAlwaysVisible">
and
<EditText
...
android:inputType="numberDecimal"/>
Does Android Things 7.0 support soft keyboard, or am I missing something?
Update II: there is a bug with Dev Preview 5.1 when Google's soft keyboard doesn't show up at all.
Update: starting with Dev Preview 4 the Android Things image is shipped with com.google.android.inputmethod.latin preinstalled. If you're going to use a 3d party keyboard app the approach below is still valid.
You should enable the IME in Android Things Developer Preview in order for it to show up. Let's consider Google Keyboard as an example (since it worked for you). Once the keyboard has been installed and you shell-ed in (with adb shell) the following options might be used:
Command line solution
Find out the IME ID
$ ime list -a | grep mId
Enable the IME using the fully qualified mId
Android Things 0.5+ (you might get already enabled)
$ ime enable com.android.inputmethod.latin/.LatinIME
Android Things 0.1 - 0.4:
$ ime enable com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME
Note: If you'd like to use the IME "app-wide" (not "system-wide"), use ime set ID instead of ime enable ID.
Settings app solution
Android Things 0.5+:
am start -n com.android.settings/.Settings\$SystemDashboardActivity
Languages & Input -> Virtual keyboard -> Manage keyboards and enable the IME (should already be enabled)
Android Things 0.1 - 0.4:
am start -n com.android.settings/.Settings\$InputMethodAndLanguageSettingsActivity
Virtual keyboard -> Manage keyboards and enable the IME
Note: In order to close _Android_'s settings app from within shell you can emulate a back button press multiple times with input keyevent 4 or force close the app with am force-stop com.android.settings.
By default, keybord apps are not installed on AT Developer Preview. You have to install it. See software keyboard.

How do I view my site on multiple screen sizes?

Ok, so I know how to write code for multiple screen sizes. But, I have no idea how to view my code on a mobile device before making my site go live. Please help!
You can play around with emulators which can simulate a variety of cellular devices. These can be downloaded using a program called Bluestacks for example.
If you have Google Chrome you can open a website and press F12 (on windows) to enter Developer Mode.
On the top left you can see a little smartphone icon.
Click it and choose a device. Then refresh the page.
Chrome will emulate the experience of a smartphone user straight from your computer, sou you can test it from there.
This is a view of this question on the emulator:
Here is the solution if you are using safari.
Enable the "develop" menu bar using Safari > Preferences > Advanced. Your menu bar should look like this:
Go to your website
Go to Develop > User Agent and choose the device/browser you wish to emulate.
You have two options.
Use of Emulators.
What you need - is any modern browser. Nearly every modern browser will offer you roughly similar emulator capabilities where you can select a target device/resolution. #intboolstring & #Pither has already mentioned safari & chrome options for you. IE & Edge have similar features (which you can probably explore yourself or see this link IE Emulator feature).
Using actual devices.
What you need - 1) wireless router 2) your dev machine/laptop which has a web server (like IIS on windows) & 3) some mobile devices (I would assume you would have atleast one smartphone which has a mobile browser on it).
You will need to connect your dev machine/laotop & your device(s) to the wireless and setup firewall on your dev machine to allow access to your website on your local wireless network. Check out this answer.
Once this is done, you should be able to load your site on any device connected on your wireless by tying http://your.dev.machine.ipv4:port-if-applicable/landingpage.html in the mobile browser.
(to find your machine's ipv4 address, goto command prompt and type ipconfig and press enter - I am assuming you are using windows)
You may be limiting your testing to a much smaller set of devices (ones you have access to). But this will give you a real-world idea (if not a much better one) of how you site renders & behaves on devices.

How to modify the TI SensorTag Firmware to advertise indefinitely?

When the side button of the TI SensorTag is pressed, pairing with a device is possible for approx. 2-3 minutes. How do you modify the SensorTag's firmware so that it advertises forever and pressing the side button is not necessary every time?
And how do you upload the firmware with an iOS device, so without using CC-debugger?
How I did it, with help of Chris Innanen (thanks!!)
You will need a Windows virtual machine if you do it on a Mac.
Download IAR Embedded Workbench for 8051 (http://supp.iar.com/Download/SW/?item=EW8051-EVAL). Make sure to take the 30-day evaluation copy and not the 4k limited.
Download BLE-STACK from Texas Instruments (http://www.ti.com/tool/ble-stack) and install it on a Windows (virtual) machine. By default, the installer will install here: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\SensorTag\CC2541DB\SensorTag.eww".
Open this SensorTag.eww file with IAR Embedded Workbench.
Select "CK2541DK-Sensor-OAD-ImgA" in the dropdown menu in the "workspace" section on the left
To prevent a compiling error later on: go to Project -> Options... and change the value for "Number of virtual registers" from 16 to 8.
Find "SensorTag.c" in the filetree in the workspace section on the left: "SensorTag - CK2541DK-Sensor-OAD-ImgA/APP/SensorTag.c"
Search for GAP_ADTYPE_FLAGS_LIMITED and change it to GAP_ADTYPE_FLAGS_GENERAL to enable indefinit advertising
Make the build with Project -> Make. Wait until it's done
By default, the new firmware image (.bin file) is now in "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\SensorTag\CC2541DB\CC2541DK-Sensor-OAD-ImgA\Exe" (Make sure to place it somewhere you can reach it from Mac OS X later, if you use a virtual machine)
Repeat steps 4 to 10, but now for "CC2541DK-Sensor-OAD-ImgB"
Now get the app to upload the new firmware over the air. Get it here: https://itunes.apple.com/us/app/ti-sensortag/id552918064?mt=8
Open iTunes in Mac OS X and open your iOS device, go to the 'Apps' section, scroll to the bottom to see the apps with filesharing possibilities. "SensorTag" should be in that list. Click on it and add the two new firmware files, both Image A and B.
If that's done, open the SensorTag app on your iOS device and connect it to the SensorTag. Then in the bottom of the app tap "Update FW" -> "Select FW file" -> Shared Files > And then tap Image B and upload it. It takes a few minutes. A firmware with type A is already on your SensorTag by default. Because you've put a B Image on it just now, with any new changes you would need to upload an Image A.
Good luck!
Additional: changing the signal strength
1) Find "HCI_EXT_ClkDivOnHaltCmd" and you'll add a new line (and optional comment) after it:
// ADDITION Adjust TX power level
HCI_EXT_SetTxPowerCmd( HCI_EXT_TX_POWER_0_DBM );
1b) You can change "_0_DBM" to "_4_DBM" or "_MINUS_6_DBM" or "_MINUS_23_DBM" as well
2) Find "GAP_ADTYPE_POWER_LEVEL" and change the value on the next line to match the above power level
The above solution didn't work for me until I changed:
initial_advertising_enable = TRUE;
In SensorTag_Init().
I am using this firmware and it will start broadcasting whenever it's not connected. The side button acts as an on and off switch.
http://www.myweathercenter.net/installing-a-new-firmware-for-ti-sensortag/

Codename one crashes on device only

I have a codenameone app that works fine in the desktop emulator (windows 7) but when I run it on my Xperia Z1 (android) it crashes when I try to show a new form (this has been working fine).
I am currently using the free account and so do not get crash reports (e.g. a call stack). And it'll take me forever to keep trial-and-error hoping to find it ....
Any suggestions?
Install the Android SDK, connect your device with a cable and launch the DDMS tool to connect to the device. You should be able to see the log messages and stack trace thru that and it might give you a better indication of what is going on.

Resources