类似java应用程序的shareit到热点的连接不是在TargetsDKVersion29上扫描,而是在android 10上在28上运行

b09cbbtk  于 2021-06-29  发布在  Java
关注(0)|答案(0)|浏览(170)

我正在做的应用程序,做文件共享工作,如分享它。我的应用程序在android 10上的targetsdkversion 28上运行正常,但在更改为29或30之后就不能正常工作了。意味着扫描热点的条形码和连接在更改targetsdkversion后在android 10上不起作用。但同样的功能在android9上也能正常工作。我该怎么办?请建议我。

This is my barcode scanner activity.

public class BarcodeScannerActivity extends Activity
{
    public static final String EXTRA_DEVICE_ID = "extraDeviceId";
    public static final String EXTRA_CONNECTION_ADAPTER = "extraConnectionAdapter";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_barcode_scanner);

        Toolbar toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        setResult(RESULT_CANCELED);

        if (getSupportActionBar() != null)
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        QRConnectFragment qRConnectFragment = (QRConnectFragment) getSupportFragmentManager().findFragmentById(R.id.barcodeScannerFragment);
        if (qRConnectFragment != null) {
            qRConnectFragment.setDeviceSelectedListener(new NetworkDeviceSelectedListener() {
                public boolean isListenerEffective() {
                    return true;
                }

                public boolean onNetworkDeviceSelected(NetworkDevice networkDevice, NetworkDevice.Connection connection) {
                    BarcodeScannerActivity.this.setResult(-1, new Intent().putExtra("extraDeviceId", networkDevice.deviceId).putExtra("extraConnectionAdapter", connection.adapterName));
                    BarcodeScannerActivity.this.finish();
                    return true;
                }
            });
        }
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (16908332 != menuItem.getItemId()) {
            return super.onOptionsItemSelected(menuItem);
        }
        onBackPressed();
        return true;
    }
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题