问题列表 - 第46902页

负字符串长度

你有一个负的字符串长度?如果是这样,它是否与null相同?

java string

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

彩虹桌?

有谁知道它为什么叫彩虹表?记得我们已经知道有一种叫做"字典攻击"的攻击.为什么不是字典?

security rainbowtable rainbowattack

6
推荐指数
2
解决办法
3356
查看次数

GWT中的MessageBox

如何在GWT中显示AJAX"消息框"?我知道我可以使用这个Window.alert()功能,但这太丑陋/烦人了.有内置功能吗?

谢谢!

伊凡

java gwt messagebox

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

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

Bundle.putExtra与android的问题

我目前正在开发一个Android应用程序,我在其中创建一个通知Intent,它将参数添加到intent的包中.单击通知时,它会调用活动并从捆绑包中获取数据.但是,第一次使用该应用程序时,它工作正常,但是当您单击其他项目时,它应该将不同的数据传递到通知活动,但由于某种原因,它不会用新的数据替换旧数据.

在我使用putExtra之前,我曾尝试调用bundle.removeExtra("companyPassword"),但它似乎没有任何区别.以下是通知的代码

private void notification(String companyName, String companyURL, String companyUsername, String loginPassword)
{
    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager mNotificationManager = (NotificationManager)getSystemService(ns);

    int icon = R.drawable.icon;
    CharSequence tickerText = "Click notification to copy password";
    long when = System.currentTimeMillis();

    Notification notification = new Notification(icon, tickerText, when);

    Context context = getApplicationContext();
    CharSequence contentTitle = "PM - Login Management";
    CharSequence contentText = "Click here to copy password";
    Intent notificationIntent = new Intent(ShowLogins.this, DataManagement.class);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    notificationIntent.removeExtra("companyName");
    notificationIntent.removeExtra("companyURL");
    notificationIntent.removeExtra("companyUsername");
    notificationIntent.removeExtra("companyPassword");
    notificationIntent.putExtra("companyName", companyName);
    notificationIntent.putExtra("companyURL", companyURL);
    notificationIntent.putExtra("companyUsername", companyUsername); …
Run Code Online (Sandbox Code Playgroud)

android bundle android-intent

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

BroadcastReceiver没有收到BOOT_COMPLETED

我在这里寻找类似的问题,但由于某种原因,我的BroadcastReceiver永远不会收到android.intent.action.BOOT_COMPLETED Intent.

这是我的(相对)Android.Manifest文件:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>    
<receiver android:name=".BootReceiver"
        android:enabled="true"
        android:exported="true"
        android:label="BootReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED"></action>

        </intent-filter>
    </receiver>
Run Code Online (Sandbox Code Playgroud)

这是实际的接收器.

public class BootReceiver extends BroadcastReceiver {
private static final String TAG="BootReceiver";

@Override public void onReceive(Context context,Intent intent){
    try{
        context.startService(new Intent(context,ConnectivityListener.class));
        Log.i(TAG,"Starting Service ConnectivityListener");
    }catch(Exception e){
        Log.e(TAG,e.toString());
    }
}
}
Run Code Online (Sandbox Code Playgroud)

谢谢!任何帮助是极大的赞赏

boot android broadcastreceiver

66
推荐指数
6
解决办法
9万
查看次数

recv()直到收到NUL字节?

我正在尝试一次从服务器接收单个数据包,因为数据包的运行速度太快,并且每个数据包的大小都未定义,因此调用带有读取字节数的recv()会读取第一个数据包,也许是其中的一部分第二个数据包。由于每个数据包都以NULL终止,因此我想逐字节读取直到接收到NULL字节。

    int recvLen = 0;
    char TB;
    char recvBuffer[1024];
    while (recv(Socket, &TB, 1, 0) > 0 && TB != 0 && recvLen < 1024)
    {
        recvBuffer[recvLen] = TB;
        recvLen++;
    }
Run Code Online (Sandbox Code Playgroud)

我认为这种方法根本无效。如果服务器发送了1024个字节,recv()将被调用1024次。

在接收到NULL字符之前,是否还有其他方法可以调用recv(),或者有比我正在使用的方法更好的方法?


编辑:我在从服务器发送的数据的前面添加了数据包大小,但是现在,如果一个错误的数据包甚至有时无缘无故,数据包就会混乱,并且无法接收到正确的数据。这是我的代码

#define UPLOAD_LEN 2755
int PacketSize, recvLen;
char Size[4];
char recvBuffer[UPLOAD_LEN+1];
while(1)
{
    if(recv(Socket,Size,4,0)>0)
    {
        Size[4] = '\0';
        PacketSize = atoi(Size);
        if (PacketSize > UPLOAD_LEN || PacketSize <= 0) continue;
        recvLen = recv(Socket, recvBuffer, PacketSize, 0);
    } else recvLen = -1;
    if (recvLen > 0)
    { …
Run Code Online (Sandbox Code Playgroud)

c sockets winsockets

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

TDD:测试构造函数设置属性是否有意义?

[TDD新手]

我有一辆带有颜色和品牌属性的汽车.

在TDD中测试构造函数是否设置了这些属性是否有意义?或者我等待测试(并实施)直到我需要它?

那么,我是否构建了这样的测试:

(C#)

public class CarTests
{
  public void Constructor_Should_Set_Color()
  {
    var car = new Car("Green", "Volvo");

    Assert.Equals(car.Color, "Green");
  }
}
Run Code Online (Sandbox Code Playgroud)

或者我等到我有一个用例场景,例如,我必须从使用构造函数构建的列表中筛选所有绿色汽车,这将失败,因为汽车将为null作为颜色?

直接测试构造函数真的有意义吗?怎么样Equals()?

.net c# tdd unit-testing

5
推荐指数
3
解决办法
1790
查看次数

我应该在grails应用程序中将临时域类放在哪里?

我应该在grails应用程序中将临时域类放在哪里?

即我有一个Action类将被传递,并使用,但从未保存.它应该在grails-app/domain文件夹中,还是在其他地方?

grails grails-domain-class

8
推荐指数
2
解决办法
4298
查看次数

Magento - addCategoryFilter抛出错误

我成功运行了这个查询:

 $_productCollection = Mage::getResourceModel('reports/product_collection')
                        ->addAttributeToSelect('*')
                        ->setOrder('created_at', 'desc')
                        ->setPage(1, 5);
Run Code Online (Sandbox Code Playgroud)

但是当我补充说

->addCategoryFilter('3')
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

Fatal error: Call to a member function getId() on a non-object in /home/sitename/public_html/app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Collection.php on line 556
Run Code Online (Sandbox Code Playgroud)

它运行的块定义为

<block type="catalog/product_list" name="catalog.right.bestsellers" template="catalog/navigation/right.phtml"/>
Run Code Online (Sandbox Code Playgroud)

在catalog.xml

magento magento-1.4

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