小编use*_*041的帖子

Python,反原子增量

如何将以下代码从Java转换为Python?

AtomicInteger cont = new AtomicInteger(0);

int value = cont.getAndIncrement();
Run Code Online (Sandbox Code Playgroud)

python

35
推荐指数
4
解决办法
4万
查看次数

Android Q (10) 请求获得访问所有存储的权限。范围存储

在 Android 10 中,需要访问存储的应用程序需要请求访问具体路径的权限。但是像文件浏览器这样的应用程序可以请求访问根存储的权限并获得对所有存储的读/写权限。这就是我正在努力做的。

根据Android,我们必须ACTION_OPEN_DOCUMENT_TREE为此使用。我遇到的问题是一切似乎都正确,但未向应用授予权限。

  private void askAndroid10Perm()
    {
        Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
        intent.addFlags(
                Intent.FLAG_GRANT_READ_URI_PERMISSION
                        | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
                        | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
                        | Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
        startActivityForResult(intent, REQUEST_CODE_OPEN_DOCUMENT_TREE);
    }
Run Code Online (Sandbox Code Playgroud)

在这里,用户可以看到 Android 文件树,并选择主存储,单击以授予权限。“它将允许 - 应用程序名称 - 可以完全访问当前存储在此位置下的所有文件,以及存储在此处的任何未来内容”-> 允许

然后:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
        case REQUEST_CODE_OPEN_DOCUMENT_TREE:
            if (resultCode == Activity.RESULT_OK) {
                Uri treeUri = data.getData();
                int takeFlags = data.getFlags();
                takeFlags &= (Intent.FLAG_GRANT_READ_URI_PERMISSION |
                        Intent.FLAG_GRANT_WRITE_URI_PERMISSION);

                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {

                    Log.i("TAG", "takePersistableUriPermission: " …
Run Code Online (Sandbox Code Playgroud)

android android-10.0 scoped-storage

23
推荐指数
3
解决办法
2万
查看次数

Firebase onMessageReceived未调用

FCM服务:

public class FCMService extends FirebaseMessagingService {


    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {


        Log.i(Constants.TAG,"onMessageReceived");

        Log.i(Constants.TAG, "From: " + remoteMessage.getFrom());

        if (remoteMessage.getData().size() > 0) {
            Log.d(Constants.TAG, "Message data payload: " + remoteMessage.getData());
        }


        if (remoteMessage.getNotification() != null) {
            Log.d(Constants.TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
        }


    }

}
Run Code Online (Sandbox Code Playgroud)

App Gradle:

  compile 'com.google.firebase:firebase-messaging:10.2.6'
Run Code Online (Sandbox Code Playgroud)

表现:

   <service android:name="communications.FCMService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
    </service>
Run Code Online (Sandbox Code Playgroud)

- 我从FCM控制台发送消息但没有到达.发送消息时,FCM控制台显示确定.

-I从java服务器发送消息,消息不到.发送消息时,Java服务器显示OK.

- 发送消息我在Android设备中使用生成的令牌.

- 之前,我错误地导入FCM库,错误已解决.每次发送邮件时发生过去的错误,Android上都会发生异常.现在什么也没收到.

- 我在Android设备上有一个Internet连接,我通过GCM(而不是FCM)从我过去实现的另一个应用程序接收消息.

-App在前台.

有些日志使用"fcm"过滤器.我发送消息时会收到此日志.

08-14 12:09:25.640 800-4739/? D/PowerManagerService: acquireWakeLockInternal: lock=862109980, flags=0x1, …
Run Code Online (Sandbox Code Playgroud)

android firebase firebase-cloud-messaging

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

项目取决于com.google.android.support:wearable:2.0.2

我用android studio创建了一个演示服装项目而没有触及任何东西.在build.Gradle中发生此错误,虽然我发现它让应用程序编译好奇.

项目依赖于com.google.android.support:wearable:2.0.2,因此它还必须依赖(作为提供的依赖项)com.google.android.wearable:wearable:2.0.2

在此输入图像描述

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    compile 'com.google.android.support:wearable:1.4.0'
    compile 'com.google.android.gms:play-services-wearable:9.4.0'
}
Run Code Online (Sandbox Code Playgroud)

android android-gradle-plugin wear-os

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

致命错误:没有足够的位来表示 Swift 中传递的值 (Int16)

我正在将一个库从 Java (Android) 翻译为 -> Swift (iPhone)

Java代码,工作正常:

   long a = 48590108397870l;
   short b = ((short)(a & 65535));//b == -28370
Run Code Online (Sandbox Code Playgroud)

SWIFT代码:

    let a : Int64  = 48590108397870
    let b: Int16 = Int16(a & 65535)//Fatal error: Not enough bits to represent the passed value
Run Code Online (Sandbox Code Playgroud)

swift

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

Android使椭圆形背景可绘制与聊天角落

我知道如何创建椭圆形背景,我将此drawable添加到RelativeLayout背景:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" android:padding="10dp">
    <solid android:color="#FFFFFF"/>
    <corners
        android:bottomRightRadius="15dp"
        android:bottomLeftRadius="15dp"
        android:topLeftRadius="15dp"
        android:topRightRadius="15dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)

但我想创建这个drawable和聊天的角落,如下所示:

椭圆形图像

如何在聊天的角落添加这个drawable?

android android-layout android-drawable

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

fetchPairData() 中的异常:在方法 getReserves() 中调用恢复异常

我试图调用“fetchPairData”函数(https://uniswap.org/docs/v2/SDK/fetcher/),但出现以下错误。

Error: call revert exception (method="getReserves()", errorSignature=null, errorArgs=[null], reason=null, code=CALL_EXCEPTION, version=abi/5.1.2)
    at Logger.makeError (C:\Users\*\Desktop\ProyectoTransaccion\v2\node_modules\@ethersproject\logger\lib\index.js:180:21)
    at Logger.throwError (C:\Users\*\Desktop\ProyectoTransaccion\v2\node_modules\@ethersproject\logger\lib\index.js:189:20)
    at Interface.decodeFunctionResult (C:\Users\*\Desktop\ProyectoTransaccion\v2\node_modules\@ethersproject\abi\lib\interface.js:289:23)
    at Contract.<anonymous> (C:\Users\*\Desktop\ProyectoTransaccion\v2\node_modules\@ethersproject\contracts\lib\index.js:329:56)
    at step (C:\Users\*\Desktop\ProyectoTransaccion\v2\node_modules\@ethersproject\contracts\lib\index.js:48:23)
    at Object.next (C:\Users\*\Desktop\ProyectoTransaccion\v2\node_modules\@ethersproject\contracts\lib\index.js:29:53)
    at fulfilled (C:\Users\*\Desktop\ProyectoTransaccion\v2\node_modules\@ethersproject\contracts\lib\index.js:20:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  reason: null,
  code: 'CALL_EXCEPTION',
  method: 'getReserves()',
  errorSignature: null,
  errorArgs: [ null ],
  address: '0x80f836E71a6C92acebf6A49ad39038609c780070',
  args: [],
  transaction: {
    data: '0x0902f1ac',
    to: '0x80f836E71a6C92acebf6A49ad39038609c780070'
  }
}
Run Code Online (Sandbox Code Playgroud)

相关代码:

const {ChainId, Token, TokenAmount, Fetcher, Pair, Route, Trade, TradeType, Percent} = require('@pancakeswap-libs/sdk');

    const INPUT_TOKEN = new Token(ChainId.MAINNET,InputTokenAddr, …
Run Code Online (Sandbox Code Playgroud)

swap node.js smartcontracts web3js binance-smart-chain

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

当泽西岛发生 500 服务器错误时,如何获取堆栈跟踪?

在球衣服务器中时,出现服务器 500 错误:

\n\n
    \n
  • 在服务器响应中,不\xc2\xb4t 有堆栈跟踪或一些信息。

  • \n
  • 在 Eclipse 控制台中,don\xc2\xb4t 有异常堆栈跟踪

  • \n
\n\n

我尝试捕获服务器中的异常并在控制台中打印跟踪,但没有任何反应

\n\n

发生 500 服务器错误时如何获取堆栈跟踪?

\n

grizzly maven jersey-2.0

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

我无法在linux中杀死我的python脚本

我试图杀死我的python进程并始终在那里.

也尝试使用sudo,如果我使用顶级命令,该过程仍然存在.

python脚本是由我创建的,没有其他进程在不断调用.

ubuntu@ip-*******:~/Desktop/Servidor$ pkill python -e

python killed (pid 1284)

ubuntu@ip-*******:~/Desktop/Servidor$ pkill python -e

python killed (pid 1284)

ubuntu@ip-*******:~/Desktop/Servidor$ pkill python -e

python killed (pid 1284)
Run Code Online (Sandbox Code Playgroud)

python linux kill-process

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