Exploring the functionality of Intent.PutExtra and Intent.GetExtra generating Null

I have recently followed a Tutorial on Youtube by Philip Lackner(https://www.youtube.com/watch?v=A41hkHoYu4M) and built a basic Bluetooth app.I am looking to further the app

I am currently looking into using Intent filters to transfer information in a dual pane layout. The Intents seem to work but Im not sure, but I have noticed a few things that I would like help with.

Firstly I have a dual pane layout, I would like to send a Bluetooth device name through the fragment via the intent, but when I pull across the intent to the other side it generates a null.

I have tried all sorts of null checks, alterations and improvisations (I have got some very unique results) but I still have not got the Bluetooth name Im after and Im really wondering what I’m doing wrong.

Secondly, I have put a Log Statement in the intent PutExtra statement, the log is never sent to logcat or it seems even looked at, I believe this could be the problem but not sure how to solve it

I am using Hilt and Dagger, could this be part of the problem?

Here is my Main Activity

    @AndroidEntryPoint
    class MainActivity : AppCompatActivity() {
    
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
    
            setContentView(R.layout.activity_main)
    
            if (DEVICE_ID != null && !DEVICE_ID.isEmpty() && !DEVICE_ID.equals("null"))
    
    
                intent.let {
                //      val devices = it.getStringExtra(DEVICES)
                //      findViewById<TextView>(R.id.tt_conf_label)
                //          .text = getString(R.string.tt_confirmation_label, devices)
    
    
                    val transfer = intent.extras?.getString(DEVICE_ID)
                    findViewById<TextView>(R.id.tt_conf_label)
                        .text = getString(R.string.tt_confirmation_label, transfer)
                    Log.d("test3 MA", "DEVICEID:"+ DEVICE_ID)
    
                }
            }
        }
    
import android.annotation.SuppressLint
import android.content.ContentValues.TAG
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.core.content.ContextCompat.startActivity
import androidx.fragment.app.Fragment
import com.example.fragmentintro.StyleFragment
import com.example.fragmentintro.exchange.BluetoothDevice
import com.example.fragmentintro.presentation.BluetoothUiState
import com.example.fragmentintro.presentation.MainActivity
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import com.example.fragmentintro.R

const val DEVICE_ID = "DEVICE_ID"
@Composable
    fun DeviceScreen(
        state: BluetoothUiState,
        onStartScan: () -> Unit,
        onStopScan: () -> Unit
    ) {
        Column(
            modifier = Modifier
                .fillMaxSize()
        ) {
            BluetoothDeviceList(
                pairedDevices = state.pairedDevices,
                scannedDevices = state.scannedDevices,
                onClick = {},
                modifier = Modifier
                    .fillMaxWidth()
                    .weight(1f)
            )
            Row(
                modifier = Modifier.fillMaxWidth(),
                horizontalArrangement = Arrangement.SpaceAround
            ) {

                Button(onClick = onStartScan) {
                    Text(text = "Start scan")
                }
                Button(onClick = onStopScan) {
                    Text(text = "Stop scan")
                }
            }
        }
    }

    @Composable
    fun BluetoothDeviceList(
        pairedDevices: List<BluetoothDevice>,
        scannedDevices: List<BluetoothDevice>,
        onClick: (BluetoothDevice) -> Unit,
        modifier: Modifier = Modifier
    ) {
        LazyColumn(
            modifier = modifier
        ) {
            item {
                Text(
                    text = "Paired Devices",
                    fontWeight = FontWeight.Bold,
                    fontSize = 24.sp,
                    modifier = Modifier.padding(16.dp)
                )
            }
            items(pairedDevices) { device ->
                Text(
                    text = device.name ?: "(No name)",
                    modifier = Modifier
                        .fillMaxWidth()
                        .clickable { onClick(device) }
                        .padding(16.dp)
                )
            }

            item {
                Text(
                    text = "Scanned Devices",
                    fontWeight = FontWeight.Bold,
                    fontSize = 24.sp,
                    modifier = Modifier.padding(16.dp)
                )
            }
            items(scannedDevices) { device ->
                Text(
                    text = device.name ?: "(No name)",
                    modifier = Modifier
                        .fillMaxWidth()
                        .clickable { onClick(device) }
                        .padding(16.dp))
                class DeviceActivity : Fragment() {

                    override fun onCreateView(
                        inflater: LayoutInflater, container: ViewGroup?,
                        savedInstanceState: Bundle?
                    ): View? {
                        // Inflate the layout for this fragment
                        return inflater.inflate(R.layout.fragment_style, container, false)
                    }

                    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
                        super.onViewCreated(view, savedInstanceState)

                        class MainActivity : AppCompatActivity() {
                            override fun onCreate(savedInstanceState: Bundle?) {
                                super.onCreate(savedInstanceState)

                                Intent(this, StyleFragment::class.java)
                                    .also { styleFragment ->
                                        styleFragment.putExtra(DEVICE_ID, device.name)
                                        startActivity(styleFragment)
                                    }
                                        val conf = findViewById<Button>(R.id.tt_cont_button)
                                        conf.setOnClickListener() {
                                            Log.d("test3 DS", "DEVICEID:" + DEVICE_ID)
                                        }
                                    }
                            }
                        }
                    }
                }
            }
        }

package com.example.fragmentintro.presentation.components


import android.annotation.SuppressLint
import android.content.ContentValues.TAG
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.core.content.ContextCompat.startActivity
import androidx.fragment.app.Fragment
import com.example.fragmentintro.StyleFragment
import com.example.fragmentintro.exchange.BluetoothDevice
import com.example.fragmentintro.presentation.BluetoothUiState
import com.example.fragmentintro.presentation.MainActivity
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import com.example.fragmentintro.R

const val DEVICE_ID = "DEVICE_ID"
@Composable
    fun DeviceScreen(
        state: BluetoothUiState,
        onStartScan: () -> Unit,
        onStopScan: () -> Unit
    ) {
        Column(
            modifier = Modifier
                .fillMaxSize()
        ) {
            BluetoothDeviceList(
                pairedDevices = state.pairedDevices,
                scannedDevices = state.scannedDevices,
                onClick = {},
                modifier = Modifier
                    .fillMaxWidth()
                    .weight(1f)
            )
            Row(
                modifier = Modifier.fillMaxWidth(),
                horizontalArrangement = Arrangement.SpaceAround
            ) {

                Button(onClick = onStartScan) {
                    Text(text = "Start scan")
                }
                Button(onClick = onStopScan) {
                    Text(text = "Stop scan")
                }
            }
        }
    }

    @Composable
    fun BluetoothDeviceList(
        pairedDevices: List<BluetoothDevice>,
        scannedDevices: List<BluetoothDevice>,
        onClick: (BluetoothDevice) -> Unit,
        modifier: Modifier = Modifier
    ) {
        LazyColumn(
            modifier = modifier
        ) {
            item {
                Text(
                    text = "Paired Devices",
                    fontWeight = FontWeight.Bold,
                    fontSize = 24.sp,
                    modifier = Modifier.padding(16.dp)
                )
            }
            items(pairedDevices) { device ->
                Text(
                    text = device.name ?: "(No name)",
                    modifier = Modifier
                        .fillMaxWidth()
                        .clickable { onClick(device) }
                        .padding(16.dp)
                )
            }

            item {
                Text(
                    text = "Scanned Devices",
                    fontWeight = FontWeight.Bold,
                    fontSize = 24.sp,
                    modifier = Modifier.padding(16.dp)
                )
            }
            items(scannedDevices) { device ->
                Text(
                    text = device.name ?: "(No name)",
                    modifier = Modifier
                        .fillMaxWidth()
                        .clickable { onClick(device) }
                        .padding(16.dp))
                class DeviceActivity : Fragment() {

                    override fun onCreateView(
                        inflater: LayoutInflater, container: ViewGroup?,
                        savedInstanceState: Bundle?
                    ): View? {
                        // Inflate the layout for this fragment
                        return inflater.inflate(R.layout.fragment_style, container, false)
                    }

                    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
                        super.onViewCreated(view, savedInstanceState)

                        class DeviceScreen: AppCompatActivity() {
                            override fun onCreate(savedInstanceState: Bundle?) {
                                super.onCreate(savedInstanceState)

                                Intent(this, MainActivity::class.java)
                                    .also { styleFragment ->
                                        styleFragment.putExtra(DEVICE_ID, device.name)
                                        startActivity(styleFragment)
                                    }
                                        val conf = findViewById<Button>(R.id.tt_cont_button)
                                        conf.setOnClickListener() {
                                            Log.d("test3 DS", "DEVICEID:" + DEVICE_ID)
                                        }
                                    }
                            }
                        }
                    }
                }
            }
        }
    ```

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật