小编Mil*_*ani的帖子

无法解析方法setLatestEventInfo

我正在处理通知,我必须使用setLatestEventInfo.但是,Android Studio显示以下错误消息:

无法解析方法setLatestEventinfo

这是我的代码片段:

private void createNotification(Context context, String registrationID) {
    NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new Notification(R.drawable.icon,"Registration Successfull",System.currentTimeMillis());
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    Intent intent = new Intent(context,RegistrationResultActivity.class);
    intent.putExtra("registration_ID",registrationID);
    PendingIntent pendingIntent = PendingIntent.getActivity(context,0,intent,0);
    notification.setLatestEventInfo(context,"Registration","Successfully Registered",pendingIntent);
}
Run Code Online (Sandbox Code Playgroud)

或者,如果他们是另一种方式,请善意地告诉我.

android

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

无法打开文件 lol.json:使用 Jq 拒绝权限?

我在这里面临某种许可问题。我可以使用 读取文件cat,使用 对其进行更改,nano但由于某种原因,jq存在权限问题。这是我面临的:

msp@coolpad:~/projects/lol$ jq .name lol.json
jq: error: Could not open file lol.json: Permission denied
Run Code Online (Sandbox Code Playgroud)

在检查权限时,这就是我得到的:

msp@coolpad:~/projects/lol$ ls -l
total 4
-rw-rw-r-- 1 msp msp   0 Sep 27 04:04 lol-domains.txt
-rwxrwxrwx 1 msp msp 593 Sep 27 04:38 lol.json
Run Code Online (Sandbox Code Playgroud)

如您所见,我已尝试授予它777权限,但它仍然显示Permission denied. 我知道设置777权限不是一个好主意,我完全打算664在问题解决后将其改回。Anyhelp会appriciated。

更新 1:我尝试重新安装jqsnap但仍然无法解决问题。

更新 2:输出cat lol.json

msp@coolpad:~$ cat lol.json
{"name":"lol"}

Run Code Online (Sandbox Code Playgroud)

更新 3:输出echo '{"name":"lol"}' | jq …

linux permissions bash jq

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

没有用于调用strcmp的匹配函数

我是c ++的新手,目前在使用时遇到错误strcmp.

我已经定义了如下结构:

struct student
{
 string name;
 int roll;
 float marks;
 dob dobi;
 string dobp;
};
student *p;
Run Code Online (Sandbox Code Playgroud)

然后,我将指针传递给函数以对其进行排序,如下所示:

void sortData(student *p)
{
 int a=0,b=0;
 for (a=0; a<=arraySize; a++)
 {
    for (b=a; b<=arraySize; b++)
    {
        if( strcmp(p[a].name, p[b].name) > 0 ) //Error
        {
           //sort logic yet to be implemented 
        }
    }
 }
}
Run Code Online (Sandbox Code Playgroud)

有人可以指出错误.

错误信息:

呼叫没有匹配功能 strcmp

c++

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

如何将关键字参数添加到通过 ThreadPoolExecuter 和 run_in_executor 调用的方法?

我正在尝试在 的帮助下同时发送 POST 请求concurrent.futures。由于某种原因,我无法设置自定义标头。我想设置

  1. Authorization
  2. Content-type

这是我到目前为止所取得的进展。

import asyncio
import concurrent.futures
import requests
from urllib.parse import urlencode, quote_plus


params = urlencode({'a': 'b', 'c': 'd', 'e': 'f'})
headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "*/*","Authorization": "Bearer kdjalskdjalskd"}

async def main():

    with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:

        loop = asyncio.get_event_loop()
        futures = [
            loop.run_in_executor(
                executor, 
                requests.post,
                'https://fac03c95.ngrok.io',params, headers)
            for i in range(20)
        ]
        for response in await asyncio.gather(*futures):
            print(response.text)
            pass

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Run Code Online (Sandbox Code Playgroud)

但由于某种原因,标头似乎没有显示在请求中。有人可以帮我从这里出去吗?

提前致谢 :)

python python-3.x python-requests python-asyncio

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

在C++中使用Array of Structures元素

我刚开始学习c ++而且我被困在这里.我做了一个结构

...
struct student{
string name;
int roll;
};
...
Run Code Online (Sandbox Code Playgroud)

然后,我在全球范围内称呼它.student s1[20];在我的主要功能中,我做了类似的事情

...
int count=0;
student *p;
p=s1;
cout<<"Enter the Number of records, you wish to consider.";
cin>>arraySize;
p = new student[arraySize];
while (count!=arraySize) {
    cout<<"Enter name.";
    cin>>*(p+count)->name; //Error comes over here
}
...
Run Code Online (Sandbox Code Playgroud)

我得到的错误信息是Indirection requires pointer operand.有人可以帮我解决这个问题吗?

c++

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

在c ++中使用isDigit()函数的正确方法

我是C++的新手,我学习了一些C语言的基础知识.这是我的代码片段.

#include "iostream"

using namespace std;

int main(){
int a=108;
if(!isdigit(a)){
    cout<<"The number is not a digit";
}
else
cout<<"It's a Number!";
}
Run Code Online (Sandbox Code Playgroud)

我不知道为什么,但它满足条件.它应该输出,It's a Number!请纠正我,如果你有更好的解决方案,建议!(为了更清楚)我想检查输入的int是否实际上由数字组成.谢谢

c++

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

尝试从window.open()访问Passed URL

我试图从window.open访问解析的URL的URL.我知道这可能听起来很愚蠢,但我想在用户执行一些操作后获取URL的值.

这是我一直在玩的代码片段,

function myFunction() {
  var myWindow = window.open("http://google.com", "MsgWindow", "width=200,height=100");

  document.getElementById("demo").innerHTML =
    "The full URL of this page is:<br>" + myWindow.location.href;
}
Run Code Online (Sandbox Code Playgroud)
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
Run Code Online (Sandbox Code Playgroud)

html javascript html5 webpage

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

错误找不到合适的add方法(int,Fragment)

我试图在Activity中膨胀片段,这是代码.

public class DetailActivity extends AppCompatActivity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_detail);
            if (savedInstanceState == null) {
                getSupportFragmentManager().beginTransaction()
                        .add(R.id.container2, new DetailFragment()) 
                        .commit();    //Line with Error
            }
        }


        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.detail, menu);
            return true;
        }

        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            // Handle action bar item clicks here. The action bar will
            // automatically handle clicks on the Home/Up …
Run Code Online (Sandbox Code Playgroud)

error-handling android exception-handling android-fragments

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