Android Button – Remove Shadow and Border from Button with Image on it

We can remove the border and shadows from a button by adding the following style code in your activity_main.xml file. Or what ever your XML file is.

style="?android:attr/borderlessButtonStyle"

Code for button. We are setting an image as the background.

  <Button
        android:id="@+id/button"
        style="?android:attr/borderlessButtonStyle"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:background="@drawable/gear"
        android:onClick="launchSettings"
        android:textSize="12sp"/>

Comparison of buttons. One on the left still has the shadow on it

Difference between border and borderless buttons

More info here

https://stackoverflow.com/questions/28756035/how-to-remove-button-shadow-android
https://stackoverflow.com/questions/27867284/remove-shadow-effect-on-android-button/30856094

Getting Android WiFi state in Kotlin

In Kotlin you can request if the WiFi adapter is on or off with the following code
This changes the text on a textbox, replace with your textbox.

wifiManager = this.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
textBox.text = "WiFi State = ${wifiManager.wifiState}"

The important part is

wifiManager.wifiState

It will return a number from 0-4 which indicates if it is on or off.

0 = WiFi is being disabled
1 = WiFi Disabled
2 = WiFi is being enabled
3 = WiFi is Enabled
4 = Error

https://developer.android.com/reference/kotlin/android/net/wifi/WifiManager#WIFI_STATE_DISABLED:kotlin.Int

Kotlin, Launching Settings Activity is Showing Main Activity

The problem is that the code in SettingsActivity is not tied to the settings_activity.xml file. So it is using the activity_main.xml instead. It does in fact switch activities, the header at the top shows that it is in the Settings, but it shows the same information on the Main Activity. Problem showed up after copying and pasting code.

Check the following line under the initial onCreate function

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)  // <-- Should be R.layout.settings_activity

The setContentView line should reflect the Layout XML file under res -> layout -> settings_activity.xml

You need to use a Theme.AppCompat theme (or descendant) with this activity.

https://stackoverflow.com/questions/21814825/you-need-to-use-a-theme-appcompat-theme-or-descendant-with-this-activity

You need to use a Theme.AppCompat theme (or descendant) with this activity.

Looks like you can get the above error resolved by adding the following to the Android Manifest file.

android:theme="@style/Theme.AppCompat.Light

Kotlin – Buttons and TextViews

Set Text for text view

val textBoxVar: TextView = findViewById(R.id.textBoxID)
textBoxVar.text = "Hello World!"

Button clicked – do something

val buttonVar: Button = findViewById(R.id.buttonID)
buttonVar.setOnClickListener {
    buttonVar.text = "Button Pushed..."  //Change text on button

}

Toast notification

val text = "Hello World! This is a toast message!"
val duration = Toast.LENGTH_SHORT
val toast = Toast.makeText(applicationContext, text, duration)
toast.show()

Changing Boot Animation over adb on Android Things

You’ll need to install and setup adb and then run the following commands. Change ipaddress to the ip address of the device running Android Things

adb connect ipaddress
adb root
adb remount
adb push bootanimation.zip /system/media/
adb reboot

bootanimation.zip will either need to be in the same directory as adb, or you can specify the path. For example if it is located on your Desktop you can use

For Windows

adb push \Users\username\Desktop\bootanimation.zip /system/media/

on Linux or MacOS

adb push ~/Desktop/bootanimation.zip /system/media/

Installing Android Things on Raspberry Pi 3 B+

https://developer.android.com/things/hardware/raspberrypi

Download the Console Tools from the following link. You will need to sign into your Google account.

https://partner.android.com/things/console/#/tools

Unzip the file and Launch the correct utility for your OS.

On Windows you will need to launch as administrator by right clicking on the Windows Application and Run as administrator.

Run as administrator

The program is easy to follow along with and automatically downloads and creates the SD card for the Pi.

After you are finished, put the card in the Pi and boot it up.

Turn 3.5mm Jack on Raspberry Pi Running LineageOS 16

You will need an Android Terminal. You can turn on the default one in the developer settings. Need to turn on developer mode?

You will also need to enable root which can also be done in the Developer settings

Open up the terminal app and run

su
rpi3-audio-jack.sh

More info here

https://konstakang.com/devices/rpi3/LineageOS16.0/

Install Factory Android Image on Pixel 1

Note: Some of these notes were saved in a draft and going off of memory. May not be entirely complete.

Basic Steps

Basic steps to flash the factory Android image back onto a Google Pixel 1

  • Boot into the boot menu.
  • Select recovery
  • Select Apply update from ADB
  • Sideload the OTA image downloaded below
  • Reboot and resetup

Downloading OTA image

You can download the full OTA image from
https://developers.google.com/android/ota