小编Ija*_*d N的帖子

aws lambda函数为单个事件触发多次

我正在使用aws lambda函数将存储桶中的上传的wav文件转换为mp3格式,然后将文件移动到另一个存储桶.它工作正常.但是触发有问题.当我上传小wav文件时,lambda函数被调用一次.但是当我上传一个大型的wav文件时,会多次触发此功能.

我已经google了这个问题,发现它是无状态的,所以它会被多次调用(不确定这个触发器是多次上传还是同一次上传).

https://aws.amazon.com/lambda/faqs/

是否有任何方法可以为单个上传调用此函数一次?

amazon-s3 amazon-web-services aws-lambda

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

Slack - 使用传入的网络钩子发布消息后获取线程 ID

我正在使用 slack 传入网络钩子将消息发布到频道。这是我的代码

curl -X POST \
  https://hooks.slack.com/services/TXXXXXXXX/BXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX \
  -H 'Content-Type: application/json' \
  -d '{
    "text": "Test message"
}'
Run Code Online (Sandbox Code Playgroud)

我得到ok作为回应。我需要线程 id(thread_tsts) 来回复该线程。

如何在使用传入的 Web 钩子将消息发布到 slack 时获取线程 ID

slack-api slack

9
推荐指数
1
解决办法
2746
查看次数

从cordova插件启动android活动

我知道这可能是一个重复的问题,我已经尝试了堆栈的所有答案,但没有一个完整的答案.

大多数答案只是给出了如何启动一个活动,但没有提示如何配置Android Manifest文件中的活动以及保存活动布局和清单文件的位置.

任何人都可以提供完整的代码结构来启动cordova插件的活动.

android android-activity cordova cordova-plugins

7
推荐指数
1
解决办法
1万
查看次数

Cordova - 通知后台运行服务

我正在使用cordova来构建我的android应用程序.由于android杀死服务,我绑定服务与通知,以避免服务终止.

这是我如何通过通知绑定服务的方法

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    context = this.getApplicationContext();
    notifyService();

    return START_NOT_STICKY;
}

private void notifyService() {
    String package_name = this.getApplication().getPackageName();

    Intent notificationIntent = new Intent(this, MainActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

    Bitmap icon = BitmapFactory.decodeResource(getResources(),
            this.getApplication().getResources().getIdentifier("icon", "drawable-hdpi", package_name));

    Notification notification = new NotificationCompat.Builder(this)
            .setContentTitle("Smart Home")
            .setContentText("Smart Home running in background")
.setSmallIcon(this.getApplication().getResources().getIdentifier("icon", "drawable-hdpi", package_name))
            .setContentIntent(pendingIntent)
            .setOngoing(true)
            .build();

    startForeground(notificationId, notification);
} 
Run Code Online (Sandbox Code Playgroud)

这是输出

在此输入图像描述

生成通知但通知标题不是我设置的.此外,当我点击此通知时,它正在转移到应用信息活动.但我想转到我的主要活动.

有没有人遇到同样的问题?或者我的代码需要对cordova进行任何更改?

android android-service android-notifications cordova-plugins

6
推荐指数
1
解决办法
575
查看次数

.htaccess允许图像直接显示

我有很多文件,包括图像,php和js脚本和子文件夹.我需要使用.htaccess重定向到index.php以获取任何uri.
例如:

www.example.com/test should be redirect to index.php
Run Code Online (Sandbox Code Playgroud)

但是图像不应该重定向到index.php.相反,它应该直接在浏览器中打印.
例如:

www.example.com/sample.jpg should display sample.jpg.
Run Code Online (Sandbox Code Playgroud)

我在.htaccess代码中使用以下代码:

RewriteEngine On  
RewriteRule ^(.*)$ index.php
Run Code Online (Sandbox Code Playgroud)

有人可以解释如何允许图像显示?

php regex apache .htaccess redirect

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

带有actionLayout的Android OnCreateOptionsMenu项不起作用

我需要在选项菜单中显示一个布局。

menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/action_likes"
        android:showAsAction="never"
        android:actionLayout="@layout/likes_layout"/>

    <item
        android:id="@+id/settings"
        android:showAsAction="never"
        android:title="Settings"
        />
</menu>
Run Code Online (Sandbox Code Playgroud)

shape_notification.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <stroke android:color="#080808" android:width="2dp"/>
    <corners android:radius="5dp" />
    <solid android:color="#85ea32"/>
</shape>
Run Code Online (Sandbox Code Playgroud)

likes_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="3"
        android:id="@+id/likes"
        android:linksClickable="false"
        android:text="Likes"
        android:gravity="center_vertical|center_horizontal"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="5"
        android:layout_gravity="center"
        android:id="@+id/notif_count"
        android:background="@drawable/shape_notification"
        android:text="0"
        android:textSize="16sp"
        android:gravity="center"
        android:padding="2dp"
        android:singleLine="true"
        android:layout_margin="5dp"
        android:textColor="#fff"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

MainActivity.java

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) { …
Run Code Online (Sandbox Code Playgroud)

java xml android android-layout android-menu

4
推荐指数
2
解决办法
4516
查看次数

Android BLE Gatt连接更改状态

我有一个Android应用程序连接到BLE设备并写入它.我可以成功连接,读取和写入它.作为测试的一部分,我们正在尝试不同的断开连接.

有时,如果ble设备断开连接,我将连接更改为断开连接,状态值为19.此外,如果存在任何绑定错误,则状态等于22.如果我以编程方式断开连接,则此状态为0.但没有除了0之外的这些状态在android文档中指定.

发布示例BluetoothGattCallback

private BluetoothGattCallback bluetoothGattCallback = new BluetoothGattCallback() {
    @Override
    public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
        Log.i(TAG, "onConnectionStateChange status: "+status+", newState: "+newState);
        /*i need to know the posiible values for this status variable*/
        if(newState == BluetoothProfile.STATE_CONNECTED) {
            gatt.discoverServices();
        } else {
            gatt.close();
        }
    }

    @Override
    public void onServicesDiscovered(BluetoothGatt gatt, int status) {
        Log.i(TAG, "onServicesDiscovered service discovered");
    }
};
Run Code Online (Sandbox Code Playgroud)

有没有人遇到同样的问题,并整理出状态列表.我需要知道onConnectionStateChange方法中状态变量的可能值

android bluetooth android-bluetooth android-ble bluetooth-gatt

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

将登录信息插入mysql数据库

我正在学习php mysql,但我遇到了这个问题.我无法将登录信息插入到我的数据库表中.我的数据库名称是loginapp,表名是用户.请查看我为其创建的代码----

<?php 
if(isset($_POST['submit'])){
   $username = $_POST['username'];
   $password = $_POST['password'];
    $connection = mysqli_connect('localhost', 'root', '','loginapp');
    if(!$connection){
    die("Database connection failed");
    }
    $query = "INSERT INTO users(username,password)";
    $query .= "VALUES ('$username', '$password')";
    $result = mysqli_query($connection, $query);
    if(!$result){
    die('query is faild' . mysqli_connect_error());
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login </title>
    <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

</head>
<body>

    <div class="container">
        <div class="col-xs-6">
             <form action="login.php" method="post">
                 <div class="form-group">
                    <label for="username">Username</label>
                     <input type="text"  name="username"class="form-control"> …
Run Code Online (Sandbox Code Playgroud)

php mysqli mysql-error-1064

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