问题列表 - 第13079页

退出我的活动时为什么会崩溃?

当我从我的活动中退出(通过后退按钮)时,我的应用程序出现崩溃.据我所知,这是在Android代码库中发生而不是我的,但我并不完全相信.

这是来自adb的stacktrace:

AndroidRuntime  E  Uncaught handler: thread main exiting due to uncaught exception
AndroidRuntime  E  java.lang.RuntimeException: Unable to stop activity {MyApp/MyApp.MainActivity}: java.lang.NullPointerException
AndroidRuntime  E      at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3097)
AndroidRuntime  E      at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3159)
AndroidRuntime  E      at android.app.ActivityThread.access$2400(ActivityThread.java:112)
AndroidRuntime  E      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1724)
AndroidRuntime  E      at android.os.Handler.dispatchMessage(Handler.java:99)
AndroidRuntime  E      at android.os.Looper.loop(Looper.java:123)
AndroidRuntime  E      at android.app.ActivityThread.main(ActivityThread.java:3948)
AndroidRuntime  E      at java.lang.reflect.Method.invokeNative(Native Method)
AndroidRuntime  E      at java.lang.reflect.Method.invoke(Method.java:521)
AndroidRuntime  E      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
AndroidRuntime  E      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
AndroidRuntime  E      at dalvik.system.NativeStart.main(Native Method)
AndroidRuntime  E  Caused by: java.lang.NullPointerException
AndroidRuntime  E      at …
Run Code Online (Sandbox Code Playgroud)

java crash android nullpointerexception android-activity

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

c ++模板语法错误

在过去的六年里,我的C++在Java和C#中工作有点生疏.我有一个愚蠢的小错误,我无法弄清楚.

我尽可能地减少了代码.

#include <list>
template<class T> class Subscriber
{
    virtual void published( T t ) = 0;
};

template <class T> class PubSub
{
private:
    std::list< Subscriber<T>* > subscribers;
public:
    void publish( T t );
};

template<class T> void PubSub<T>::publish( T t ) 
{
    for( std::list< Subscriber<T>* >::iterator i = subscribers.begin(); i != subscribers.end(); ++i )
        i->published( t );
}
Run Code Online (Sandbox Code Playgroud)

当我尝试编译它(通过在代码文件中包含此头文件)时,我收到以下错误:

../util/pubsub.h: In member function ‘void PubSub<T>::publish(T)’:
../util/pubsub.h:18: error: expected `;' before ‘i’
../util/pubsub.h:18: error: ‘i’ was not declared in …
Run Code Online (Sandbox Code Playgroud)

c++ syntax templates

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

使用jQuery实现"这需要太长时间"的消息

如何使用jQuery Ajax API实现类似gmail的"这需要太长时间"的警告消息

对于那些从未在gmail上看过这条消息的人来说,当"登录"过程需要很长时间才能完成时会出现,然后会建议一些解决方案.

我在我的网站上使用jQuery Ajax,我想在页面加载非常慢时警告用户然后建议一些解决方案(例如刷新页面或帮助页面的链接).

javascript ajax jquery

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

ListProperty的密钥与App Engine中的多对多

作为一个假设的例子,我有一个模型TodoItem和一个模型TodoList.TodoList具有TodoItems的有序列表,并且任何一个TodoItem可以属于任意数量的TodoLists(多对多).除了TodoList中TodoItem的顺序之外,不需要存储关于其关系的其他信息.在数据存储中表示这一点的最佳方法是什么?

有两种实现方法 - 给TodoList类一个db.Key的ListProperty,它将引用TodoItem:

class TodoList(db.Model):
  items = db.ListProperty(db.Key)
Run Code Online (Sandbox Code Playgroud)

或者创建一个也包含订购信息的ListItem模型:

class TodoListItem(db.Model):
  item = db.ReferenceProperty(TodoItem)
  list = db.ReferenceProperty(TodoList)
  order = db.IntegerProperty()
Run Code Online (Sandbox Code Playgroud)

我肯定会通过对模型进行非规范化来优化它,但是预优化,任何一种表示都优于另一种吗?

google-app-engine models

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

允许用户在PHP中提交HTML

我想允许很多用户提交用户配置文件的html,我目前试图过滤掉我不想要的内容,但我现在想要更改并使用白名单方法.

这是我目前的非白名单方法

function FilterHTML($string) {
    if (get_magic_quotes_gpc()) {
        $string = stripslashes($string);
    }
    $string = html_entity_decode($string, ENT_QUOTES, "ISO-8859-1");
    // convert decimal
    $string = preg_replace('/&#(\d+)/me', "chr(\\1)", $string); // decimal notation
    // convert hex
    $string = preg_replace('/&#x([a-f0-9]+)/mei', "chr(0x\\1)", $string); // hex notation
    //$string = html_entity_decode($string, ENT_COMPAT, "UTF-8");
    $string = preg_replace('#(&\#*\w+)[\x00-\x20]+;#U', "$1;", $string);
    $string = preg_replace('#(<[^>]+[\s\r\n\"\'])(on|xmlns)[^>]*>#iU', "$1>", $string);
    //$string = preg_replace('#(&\#x*)([0-9A-F]+);*#iu', "$1$2;", $string); //bad line
    $string = preg_replace('#/*\*()[^>]*\*/#i', "", $string); // REMOVE /**/
    $string = preg_replace('#([a-z]*)[\x00-\x20]*([\`\'\"]*)[\\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iU', '...', $string); //JAVASCRIPT
    $string = preg_replace('#([a-z]*)([\'\"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iU', '...', $string); …
Run Code Online (Sandbox Code Playgroud)

php whitelist

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

将ASM转换为C(不是逆向工程)

我用谷歌搜索,我看到一个惊人的轻浮反应,基本上嘲笑提问者问这样的问题.

Microchip免费提供一些源代码(我不想在这里发布,以防万一.基本上,谷歌AN937,点击第一个链接,有一个链接"源代码"及其压缩文件).它在ASM中,当我看到它时,我开始睁大眼睛.我想将它转换为类似ac类型语言的东西,以便我可以跟随它.因为行如:

GLOBAL  _24_bit_sub
movf    BARGB2,w
subwf   AARGB2,f
Run Code Online (Sandbox Code Playgroud)

可能很简单,但它们对我毫无意义.

必须有一些自动ASM到C的翻译器,但我能找到的是人们说它不可能.坦率地说,它不可能是不可能的.两种语言都有结构,这种结构肯定可以翻译.

谢谢.

c embedded assembly reverse-engineering microchip

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

为iPhone SDK生成Objective C中的随机数

我使用arc4random()函数来生成一个随机组和数字序列,但我被告知这是过度的,我应该使用random()函数.但是,random()函数每次都给我相同的数组和数字序列.

我的应用程序第一次启动时,我调用srand(time(0))一次,以便为random()函数播种.你是否需要重新设置random()函数?

我错过了什么吗?

谢谢.

iphone random numbers objective-c

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

在c#中手动触发事件

我想使用c#手动触发事件.例如,假设我想从表单B中激活表单A的Form_closing事件.怎么做?

得到一些评论后.我想我需要对此进行更多解释.

由于我的表单A引用了.dll,它在桌面上创建了一个自定义任务栏,因此我可以从表单B中关闭该自定义任务栏.我已经尝试过表单B中的FormA.Close().这样,.dll将从应用程序域中卸载,因此自定义任务栏占用的空间将被阻止.

但是,当我单击自定义任务栏中的关闭按钮时,情况并非如此.当我这样做时,空间被释放了.

这就是我想从表格B手动触发表格A的关闭事件的原因,这将解决我的问题.

谢谢.

c#

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

从Interface类调用IEnumerator

如果这个问题听起来很愚蠢,我是新来的枚举集合,请原谅.

我上课了

public class PersonStuff : IPersonStuff, IEnumerable<User>
    {
        Person person = new Person();
        ...

        IEnumerator<Person> IEnumerable<Person>.GetEnumerator()
        {
            return (person as IEnumerable<Person>).GetEnumerator();
        }
}
Run Code Online (Sandbox Code Playgroud)

如您所见,我在上面实现了两个接口:一个是IPersonStuff,另一个是IEnumerable.

Person类是一个简单的getter/setter,每个类型都是字符串,例如名称,地址除了dateofbirth是DateTime.

在我的IPersonStuff中我有这个:

interface IPersonStuff
    {
        ...
        IEnumerator<Person>  IEnumerable<Person>.GetEnumerator();
    }
Run Code Online (Sandbox Code Playgroud)

一旦工作,我想以下面的方式(从任何类)来调用它:

    IPersonStuff personStuff = new PersonStuff();

    foreach (Person u in personStuff)
    {
        //this loop should iterate thru the elements.
    }
Run Code Online (Sandbox Code Playgroud)

但是,我收到以下错误:

  • 'IEnumerable <...>.GetEnumerator':显式接口声明只能在类或结构中声明

基本上我想知道如何通过IPersonStuff接口调用我在PersonStuff类中的IEnumerator IEnumerable.GetEnumerator().

c# generics ienumerator interface

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

iPhone的配置框架限制?

小伙子们,

我正在开发一个应用程序,其中我需要多次向用户询问其位置的功能,当用户允许一次使用他的位置时会发生什么,当他导航到另一个部分时,它不会要求他获取他的位置,它正在采取它来自已经缓存的位置.

是否有可能要求用户多次获得他的批准才能获得他的位置?

任何帮助赞赏.

干杯,阿米特

iphone core-location

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