Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devicePicker = DevicePicker() not working.below refrence code is given #8

Open
asadgondal581 opened this issue Jul 26, 2023 · 1 comment

Comments

@asadgondal581
Copy link

package com.example.connectcasttesting

import android.app.AlertDialog
import android.os.Bundle
import android.widget.AdapterView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.connectsdk.device.ConnectableDevice
import com.connectsdk.device.ConnectableDeviceListener
import com.connectsdk.device.DevicePicker
import com.connectsdk.discovery.DiscoveryManager
import com.connectsdk.service.DeviceService
import com.connectsdk.service.command.ServiceCommandError

class MainActivity : AppCompatActivity(),ConnectableDeviceListener {

private var mDiscoveryManager: DiscoveryManager? = null
private var mDevice: ConnectableDevice? = null


override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    DiscoveryManager.init(applicationContext)
    mDiscoveryManager = DiscoveryManager.getInstance()
    mDiscoveryManager?.start()
    showImage()
}

val deviceListener = DeviceListener(this)
val selectDevice = AdapterView.OnItemClickListener { adapter, parent, position, id ->
    val mDevice = adapter.getItemAtPosition(position) as ConnectableDevice
    mDevice.addListener(deviceListener)
    mDevice.connect()
}
private fun showImage() {
    val devicePicker = DevicePicker(this)
    val dialog: AlertDialog = devicePicker.getPickerDialog("Show Image:", selectDevice)
    dialog.show()
    Toast.makeText(this, "Show Image function Toast", Toast.LENGTH_SHORT).show()
}

override fun onDeviceReady(device: ConnectableDevice?) {
    TODO("Not yet implemented")
}

override fun onDeviceDisconnected(device: ConnectableDevice?) {
    TODO("Not yet implemented")
}

override fun onPairingRequired(
    device: ConnectableDevice?,
    service: DeviceService?,
    pairingType: DeviceService.PairingType?
) {
    TODO("Not yet implemented")
}

override fun onCapabilityUpdated(
    device: ConnectableDevice?,
    added: MutableList<String>?,
    removed: MutableList<String>?
) {
    TODO("Not yet implemented")
}

override fun onConnectionFailed(device: ConnectableDevice?, error: ServiceCommandError?) {
    TODO("Not yet implemented")
}

}
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}

android {
namespace 'com.example.connectcasttesting'
compileSdk 33

defaultConfig {
    applicationId "com.example.connectcasttesting"
    minSdk 24
    targetSdk 33
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
    jvmTarget = '1.8'
}
buildFeatures{
    viewBinding true
}

}

dependencies {
implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
//custom
implementation 'com.connectsdk:connect-sdk-android:1.6.0'
// implementation 'org.java-websocket:Java-WebSocket:1.5.3'
//implementation project(':Connect-SDK-Android')

}

@yjojovasuka
Copy link

uske liye paisa lgega bol dega? , to btau ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants