小编Adr*_*aan的帖子

kill app甚至在某些设备中使用START_STICKY后服务无法再次启动

在我服务,我已经回到START_STICKY让我Service重新启动后,再次我杀的应用程序.
我有测试,它在设备正常工作Samsung,Sony,LGXiaomi它无法正常工作(服务不可重新开始)

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    return START_STICKY;
}
Run Code Online (Sandbox Code Playgroud)

我该如何处理这个案子.任何帮助或建议将非常感谢?
来自Android文档

/**
 * Constant to return from {@link #onStartCommand}: if this service's
 * process is killed while it is started (after returning from
 * {@link #onStartCommand}), then leave it in the started state but
 * don't retain this delivered intent.  Later the system will try to
 * re-create the service.  Because it …
Run Code Online (Sandbox Code Playgroud)

service android

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

如何获取Google Cloud Storage中存在的视频的视频时长

我已将视频上传到Google的Cloud Storage存储桶,并在Video Intelligence API中引用了它们的URL。当我尝试获取上载视频的视频时长时,Video Intelligence API不会返回任何内容。

这是我使用的代码:

require "google/cloud/video_intelligence"

video_intelligence_client = Google::Cloud::VideoIntelligence.new
features_element = :LABEL_DETECTION
features = [features_element]

operation = video_intelligence_client.annotate_video input_uri: input_uri, features: features
p "PROCESSING......"
p operation
raise operation.results.message? if operation.error?

operation.wait_until_done!
metadata = operation.metadata
puts metadata
Run Code Online (Sandbox Code Playgroud)

使用Video Intelligence API是否可以获取视频时长?另外,我应该如何从Google Cloud Storage API获取它?

google-cloud-storage google-cloud-platform video-intelligence-api

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

Terraform - 放置 S3 通知配置时出错:InvalidArgument:无法验证以下目标配置

我正在尝试使用 terraform v0.11.8 在 S3 中配置 Lambda 事件通知。这就是我的地形的样子 -

###########################################
#### S3 bucket 
###########################################
resource aws_s3_bucket ledger_summary_backups {
  bucket = "${var.environment_id}-ledgersummary-backups"
  acl    = "private"
  tags   = local.common_tags
}

###########################################
######  Lambda Functions
###########################################
resource aws_s3_bucket_notification bucket_notification {
  bucket = aws_s3_bucket.ledger_summary_backups.id

  lambda_function {
    lambda_function_arn = aws_lambda_function.account_restore_ledgersummary_from_s3.arn
    events              = ["s3:ObjectCreated:*"]
    filter_prefix       = "AWSDynamoDB/"
    filter_suffix       = ".gz"
  }

  depends_on = [aws_lambda_permission.allow_bucket]
}

resource aws_lambda_permission allow_bucket {
  statement_id  = "AllowS3Invoke"
  action        = "lambda:InvokeFunction"
  function_name = aws_lambda_function.account_restore_ledgersummary_from_s3.arn
  principal     = "s3.amazonaws.com"
  source_arn    = aws_s3_bucket.ledger_summary_backups.arn
}

resource …
Run Code Online (Sandbox Code Playgroud)

amazon-s3 amazon-web-services aws-lambda terraform terraform-provider-aws

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

如何进行快速多维矩阵向量乘法?

A是一个3D N*N*L矩阵,x是一个N*1向量,我需要在其上执行以下操作:

for i=1:L
    res(i)=x'*squeeze(A(:,:,i))*x
end
Run Code Online (Sandbox Code Playgroud)

我希望使用最有效的矢量化方法而不是for循环.请有人给我一些建议吗?

performance matlab matrix vectorization matrix-multiplication

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

在Matlab R2015中计算字符串中的数字和字符的函数

例如,我在单元格内部有一个字符串'5a5ac66'.我想计算该字符串中的数字和字符数.

'5a5ac66'= 4位数(5566)和3个字符(aac)

我怎样才能做到这一点?MATLAB中有什么功能吗?

matlab function counting digits char

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

MATLAB 中方括号的使用

在 MATLAB 中,您可以轻松地创建一个整数数组

N = 100; % Number of points
A = 1:N; % row vector of 1,2,3,..., 100
Run Code Online (Sandbox Code Playgroud)

如果我想要一个列向量而不是一个行向量,我可以用

A = [1:N].';
Run Code Online (Sandbox Code Playgroud)

现在,MATLAB 警告我

Use of brackets [] is unnecessary. Use parentheses to group if necessary.
Run Code Online (Sandbox Code Playgroud)

好吧,它们不是不必要的,因为1:N.' 创建了一个行向量,因为只有标量N被转置,而不是整个数组。

我当然可以在该行、该文件或所有文件中取消显示此消息,但是为什么 MATLAB 首先会抛出此警告,因为在这种情况下我似乎不能没有这些括号?

事实证明,很大一部分混淆源于 The MathWorks 对美式英语的使用,因为其他英语世界使用术语括号for()和术语方括号for []。参见维基百科

matlab vector square-bracket

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

矢量化和矢量索引

我目前需要加速我的代码,因此想要使用矢量化而不是循环.以下代码是在我的计算过程中被调用的代码的(非常)简化版本:

    T=10; n=5; w0 = 25000; w1 = 23000; b0 = 15000; 
    vec = zeros(1,T+2*n+1); vec(1:n+1) = w0; vec(n+2:n+T+1) = b0; vec(n+T+2:T+2*n+2) = w1;
    ref0=zeros(1,n);
    for i = 1:n
        ref0(i) = sum(vec(T+i+2:n+T+i+2));
    end
Run Code Online (Sandbox Code Playgroud)

我试图使用矢量化,但不幸的是它似乎不起作用,因为我的矢量的第一个条目i被用作矢量索引过程中的输入:

i = 1:n;
ref1 = sum(vec(T+i+2:n+T+i+2));
Run Code Online (Sandbox Code Playgroud)

输出如下:

ref0 =

  106000      114000      122000      130000      138000

ref1 =

  106000
Run Code Online (Sandbox Code Playgroud)

有没有办法实现ref1使用向量化提供与ref0相同的输出?这可能是非常明显的,但我似乎没有在这里进一步.我很感激任何帮助!非常感谢提前.

indexing matlab vectorization

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

如何为矩阵的每个元素设置不同的显示样式?

我有一个矩阵:

G =

10.0000e+000     0.0000e+000     4.0000e+000     2.7013e-009
10.0000e+000    10.0000e+000     1.0000e+000     7.7550e-009
 5.0000e+000     5.0000e+000     2.0000e+000   -15.3223e-009
10.0000e+000    10.0000e+000     3.0000e+000     6.6898e-009
Run Code Online (Sandbox Code Playgroud)

但我想像这样显示它,只有科学记数法中的特定数字,这可能吗?:

G =

10     0     4     2.7013e-009
10    10     1     7.7550e-009
 5     5     2   -15.3223e-009
10    10     3     6.6898e-009
Run Code Online (Sandbox Code Playgroud)

矩阵码:

x_1=0;  y_1=0;   z_1=0; 
x_2=10; y_2=0;   z_2=4;
x_3=10; y_3=10;  z_3=1;
x_4=5;  y_4=5;   z_4=2;

cT21 =   2.701320e-09 
cT31 =   7.755042e-09 
cT41 =   -1.532233e-08 
cT51 =   6.689788e-09 

format shortEng
G = [x_2 y_2 z_2 cT21; x_3 y_3 z_3 cT31; x_4 y_4 z_4 cT41; x_5 …
Run Code Online (Sandbox Code Playgroud)

matlab matrix

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

normpdf表现得很奇怪

以下面的方式,

function ret = f(pIx5, dS)
    sigma = 1;    

    rho = dS(1);
    theta = dS(2);

    mu_x = rho*cos(theta);

    display(pIx5);
    display(mu_x);

    pdf = normpdf(pIx5, mu_x, sigma);

    ret = max(pdf);
end
Run Code Online (Sandbox Code Playgroud)

我收到以下错误消息,

pIx5 =
       54   65   11    0    0

mu_x =
       11.9218

Error using normpdf (line 36) Non-scalar arguments must match in size.

Error in f (line 11)

        pdf = normpdf(pIx5, mu_x, sigma);
Run Code Online (Sandbox Code Playgroud)

但是,它可以通过以下方式正常工作,

function ret = f(pIx5, dS)
    sigma = 1;    

    rho = dS(1);
    theta = dS(2);

    pIx5 = [54,65, 11, …
Run Code Online (Sandbox Code Playgroud)

matlab probability-density

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

为什么绘制这个方程不会生成正确的曲线?

目的是绘制以下等式:P*sin(x)/ x + cos(x),对于P = 1.6和x在[0,5]中,忽略绿色填充区域,应该看起来像:

在此输入图像描述

但是,从以下代码:

x = 0 : 0.01 : 5;     % ka/pi, where k-wavevector, a-lattice spacing.

P = 1.6;              % 2*m*U_0 / hbar^2.
rhs =  P * sinc(x*pi) + cos(x*pi);
rhs2 = P * ( sin(x*pi) / x*pi) + cos(x*pi);

plot(x, rhs, '--b', x, rhs2, 'b', x, -1*ones(size(x)), 'r', x, 1*ones(size(x)), 'r')
axis([0 5 -3 3])
xlabel('ka/pi')
legend('P*sinc(x) + cos(x)', '(2mU_0b)/(hbar^2) * sin(ka)/ka + cos(ka)', 'y = -1', 'y = 1')
Run Code Online (Sandbox Code Playgroud)

我目前得到的是:

在此输入图像描述

我在这做错了什么?


我在Windows 10,Octave-4.2.1上

matlab trigonometry octave

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