小编Cas*_*per的帖子

通过意图将BluetoothDevice对象传递给另一个活动

我正在写蓝牙客户端,我有一个问题.我的第一个活动显示在ListView中启用了设备.单击此列表中的某个项目时,它应该启动新活动并在那里传递BluetoothDevice对象.我写的是这样的:

public void onItemClick(AdapterView<?> parent, View view, int position,
        long id) {
    // TODO Auto-generated method stub
    if(btAdapter.isDiscovering()) {
        btAdapter.cancelDiscovery();
    }
    if(listAdapter.getItem(position).contains("Paired")) {

        BluetoothDevice selectedDevice = devices.get(position);
        Intent intent = new Intent (this, BTActivity.class);
        intent.putExtra("btdevice", selectedDevice);
        startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

是否可以将BluetoothDevice对象传递给另一个活动?如何在新活动中提取此对象?

对不起我的英语不好.如果事情不明确,我会尝试更好地解释.

android bluetooth android-intent android-activity

5
推荐指数
1
解决办法
6179
查看次数

什么应该是传递给`gorilla/sessions`中的`NewCookieStore()`的密钥(或身份验证密钥)?

gorilla/sessions中,func NewCookieStore(keyPairs ...[]byte) *CookieStore用于创建新的CookieStore.但我实际上并不知道什么是密钥(或身份验证密钥).

描述说:

建议使用32或64字节的身份验证密钥.

因此,这是否意味着我可以随机推送长度为32或64的任何字符串?您如何选择身份验证密钥?

go gorilla

5
推荐指数
1
解决办法
569
查看次数

在Ubuntu 16.10上将C程序编译为WebAssembly程序,出现“错误:没有可用的目标与此三元组兼容”

在学习完本教程之后,我尝试使用以下命令将C程序编译为WebAssembly。

emcc hello.c -s WASM=1 -o hello.html
Run Code Online (Sandbox Code Playgroud)

但是我遇到了“ No available targets are compatible with this triple.”问题。

$ emcc hello.c -s WASM=1 -o hello.html
WARNING  root: LLVM version appears incorrect (seeing "(https://github.com/kripken/emscripten-fastcomp-clang/", expected "3.4")
INFO     root: (Emscripten: Running sanity checks)
WARNING  root: Assigning a non-existent settings attribute "WASM"
WARNING  root:  - did you mean one of ASM_JS?
WARNING  root:  - perhaps a typo in emcc's  -s X=Y  notation?
WARNING  root:  - (see src/settings.js for valid values)
/home/casper/Desktop/test/emsdk/clang/fastcomp/build_incoming_64/bin/lli: error …
Run Code Online (Sandbox Code Playgroud)

c ubuntu emscripten webassembly

5
推荐指数
1
解决办法
2270
查看次数

“ AllowSpin”属性已由“ Xceed_Wpf_Toolkit_Primitives_UpDownBase”注册

WPF UserControl XAML文件中使用的DateTimePicker

<xctk:DateTimePicker Name="start" AutoCloseCalendar="True" BorderThickness="0" Background="Transparent" BorderBrush="#FFD6D6D6"
                    Value="{Binding Path=StartTime, 
                                    RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:RestrictionPanel}, Mode=TwoWay}"
                    TimeFormat="Custom" TimeFormatString="HH:mm"
                    Format="Custom" FormatString="yyyy-MM-dd   HH:mm"
                    FontSize="22" ShowButtonSpinner="False" ShowDropDownButton="False"
                    TextAlignment="Center" 
                    Maximum="{Binding ElementName=end, Path=Value, TargetNullValue={x:Static sys:DateTime.MaxValue}}"
                    IsEnabled="{Binding ElementName=chk_start, Path=IsChecked}"/>
Run Code Online (Sandbox Code Playgroud)

错误是:

“ AllowSpin”属性已由“ Xceed_Wpf_Toolkit_Primitives_UpDownBase`1_0_197800013”注册。

在此处输入图片说明

如果我用替换上面的代码<xctk:DateTimePicker />,则错误仍然存​​在。我该如何解决?

wpf xaml datetime datetimepicker

5
推荐指数
1
解决办法
214
查看次数

Android 6.0蓝牙程序无法发现任何可用的蓝牙设备

目标

发现所有可用的蓝牙设备,例如我的iPad蓝牙ON(可发现).

ANDROID VERSION

6

问题

无法发现任何蓝牙设备.

// Permission
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

public BroadcastReceiver mReceiver;
public IntentFilter filter;

private boolean discover_AvailableBluetoothDevice() {
        mReceiver = new BroadcastReceiver() {
            public void onReceive(Context context, Intent intent) {
                Log.d(TAG, "onReceive Called");
                String action = intent.getAction();
                // When discovery finds a device
                if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)) {
                    Log.d(TAG, "ACTION_DISCOVERY_STARTED");
                } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
                    Log.d(TAG, "ACTION_DISCOVERY_FINISHED");
                } else if (BluetoothDevice.ACTION_FOUND.equals(action)) {
                    Log.d(TAG, "ACTION_FOUND");
                    // Get the BluetoothDevice object from the Intent
                    BluetoothDevice device …
Run Code Online (Sandbox Code Playgroud)

android bluetooth android-permissions android-6.0-marshmallow

4
推荐指数
1
解决办法
2256
查看次数

如何在 Go 中实现 PHP 函数 `die()`(或 `exit()`)?

在 PHP 中,die()用于停止运行脚本以防止意外行为。在 Go 中,死一个句柄函数的惯用方法是什么?panic()或者return

exit die go

4
推荐指数
1
解决办法
3224
查看次数

制作自定义结构类型的常量全局变量

我想创建一个“类”来处理输入验证。我首先创建一个类型,Input其中一个是用于存储用户输入的字符串,另一个是REGP存储正则表达式模式和模式描述的类型。我创建了两个常量实例REGP_LOGINNAMEREGP_PASSWORD. 但我得到const initializer REGP literal is not a constant. 为什么?

package aut

import "regexp"

type Input string

type REGP struct {
    pattern string
    Descr   string
}

const REGP_LOGINNAME = REGP{ //const initializer REGP literal is not a constant
    "regex pattern 1",
    "regex description 1",
}

const REGP_PASSWORD = REGP{ //const initializer REGP literal is not a constant
    "regex pattern 2",
    "regex description 2",
}

func (i Input) isMatch(regp REGP) bool …
Run Code Online (Sandbox Code Playgroud)

types constants go

3
推荐指数
1
解决办法
6917
查看次数

WPF 动画 GIF 使用太多内存来显示大 GIF 图像

我想通过使用库WPF Animated GIF来显示GIF。但是PictureSource设置属性后,进程内存从208MB上升到1GB。为什么?

在此处输入图片说明

XAML

<Image Name="content" MaxHeight="240" MaxWidth="340" 
       RenderOptions.BitmapScalingMode="LowQuality"
       Width="340" Height="240"
       MinWidth="340" MinHeight="240"
       gif:ImageBehavior.AutoStart="True"
       gif:ImageBehavior.AnimatedSource="{Binding Path=PictureSource}">
        <Image.Stretch>
            <MultiBinding Converter="{StaticResource ImageStretchConverter}">
                <Binding Path="PictureSource" />
                <Binding ElementName="content" Path="Source.Width" />
                <Binding ElementName="content" Path="Source.Height" />
            </MultiBinding>
        </Image.Stretch>
        <Image.BitmapEffect>
            <BlurBitmapEffect Radius="0" />
        </Image.BitmapEffect>
    <Image.CacheMode>
        <BitmapCache EnableClearType="True" 
                RenderAtScale="0.2" 
                SnapsToDevicePixels="True"/>
    </Image.CacheMode>
    <!--<Image.Source>
        <BitmapImage StreamSource="{Binding Path=PictureSource}" UriSource="{Binding Path=PictureSource}"
            DecodePixelWidth="340" DecodePixelHeight="240"/>
    </Image.Source>-->
</Image>
Run Code Online (Sandbox Code Playgroud)

图像拉伸转换器

public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) {
    string path = values[0] …
Run Code Online (Sandbox Code Playgroud)

wpf xaml animated-gif

3
推荐指数
1
解决办法
1726
查看次数

AVR定时器编程:CTC模式与正常模式

当比较优势劣势CTC模式普通模式的AVR定时器编程,你觉得哪一个更好?为什么?你能为我解释一下吗?

谢谢你的帮助.

comparison avr timer

2
推荐指数
1
解决办法
9503
查看次数

在 Windows 上安装 APM 的完整指南

目前,我正在使用Atom 编辑器研究 ReactJS,我想尝试使用ATOM REACT PLUGIN。对于安装,它需要我使用该命令,apm install react但 Windows CMD 无法识别apm. 网上查了一下,好像apmMac上调用命令很简单,在Windows上调用命令就不简单了。apm在 Windows 中是否有分步安装指南?

在 Mac 上安装 Shell 命令: 在此处输入图片说明

在 Windows 版本中,我找不到它: 在此处输入图片说明

windows installation atom-editor

2
推荐指数
1
解决办法
5309
查看次数