问题列表 - 第39636页

音频会话属性侦听器在UIImagePickerController中自动停用?

我正在开发一个相机应用程序,以便在按下音量按钮时拍照.

我曾经AudioSessionAddPropertyListener(kAudioSessionProperty_CurrentHardwareOutputVolume, audioVolumeChangeListenerCallback, self);在相机启动前按下音量按钮时成功收到通知.但是,在我启动相机后,此属性侦听器不再起作用.是自动停用还是什么?

我试图实现一个自定义的UIImagePickerController,在ImagePickerController中包含Audio Session Property Listener但没有希望.如果有人可以分享您的观点,感激不尽.谢谢.

iphone xcode camera button

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

Rails 3身份验证解决方案

我在StackOverflow和谷歌周围探索,但找不到任何人为Rails整理了身份验证宝石或插件的比较(我正在为Rails 3寻找一些东西).Rails 3有哪些认证解决方案最受欢迎,它们之间有什么区别?

authentication plugins rubygems ruby-on-rails ruby-on-rails-3

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

寻找高级C++ SSL库

我今晚检查了很多SSL图书馆.OpenSSL看起来不错,但缺少文档,因为大多数都可以.当我找到NetSieben的SSL C++库(http://www.netsieben.com/products/ssh/index.phtml)时,我以为我中了大奖,但是几小时后,我无法进行编译.它说它需要Botan的lib,但绝对没有信息如何将它与Botan或任何东西联系起来.

所以我正在寻找一个相当容易使用的SSL库.我只是将它用于客户端应用程序以连接到现有的服务器.

c++ ssl

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

PHP微优化

我怎样才能发现无用的微优化技术?

应该避免什么?

php micro-optimization

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

Robolectric启动时反射的NullPointerException - 任何提示?

我正在Eclipse上开发一个Android项目,我正在尝试从模拟器/设备(非常慢)上的运行测试切换到Robolectric.

我用Robolectric取代了Android库,将JUnit添加到路径中,将测试用例更改回常规TestCase并添加@RunWith(RobolectricTestRunner.class)快速入门指南中的建议(进行必要的更改以实例化我的Activity而不是依赖于Android的活动测试来执行此操作为了我).

但是,当我运行测试时,我得到:

java.lang.NullPointerException
 at com.xtremelabs.robolectric.RobolectricTestRunner.isInstrumented(RobolectricTestRunner.java:123)
 at com.xtremelabs.robolectric.RobolectricTestRunner.<init>(RobolectricTestRunner.java:72)
 at com.xtremelabs.robolectric.RobolectricTestRunner.<init>(RobolectricTestRunner.java:57)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
 at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
 at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
 at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
 at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
 at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
 at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:29)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:40)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:30)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Run Code Online (Sandbox Code Playgroud)

这似乎与此代码有关(来自0.9标签,因为0.9.1标签没有它)RobolectricTestRunner.java:

private static boolean isInstrumented() {
    return RobolectricTestRunner.class.getClassLoader().getClass().getName().contains(RobolectricClassLoader.class.getName());
}
Run Code Online (Sandbox Code Playgroud)

但我无法理解,因为这种反思应该来自班级本身.

此外,我可以发誓它在重复失败之前运行了一次 - 我已经删除了robolectric缓存(如此处所示)并用最新版本(4.8.2)替换了Eclipse的JUnit,但没有任何改变.

任何提示?

更新:我尝试创建一个新的Java(即普通的,非Android)测试项目,就像快速入门指南中所述.但是,现在测试运行抱怨没有AndroidManifest.xml:

java.lang.RuntimeException: …
Run Code Online (Sandbox Code Playgroud)

java junit android nullpointerexception

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

Java:没有包访问的子类访问

相当新的Java,但我想知道为什么包访问被认为比子类访问"更具限制性".也就是说,为子类提供对成员访问权限的每个访问修饰符也为整个包提供访问权限,并且存在提供包访问但不提供子类访问的修饰符.

这不是完全倒退吗?假设我在某个包中有一个类ControlledInstantiation.如果我有另一个类AlsoControlledInstantiation扩展ControlledInstantiation,我无法调用ControlledInstantiation的构造函数,除非我将其设置为protected或public.如果我将它设置为protected,那么包中的任何其他类都可以根据需要经常实例化它.因此,对于其超类(和语法,是)必须替代的东西获得与超类相同或更少的访问权限,而不是服务于不同但相关的函数的东西.这就像告诉你的孩子他不能玩你的钱包,因为你不会让你的邻居这样做,然后让你的邻居睡在你的房子,因为你的孩子.

所以我想我在问,这个决定的动机是什么,我怎么能绕过它呢?

java access-modifiers

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

cython中可能的优化:numpy数组

以下是我从多变量正态分布中绘制的Cython代码.我正在使用循环,因为每次我有不同的密度.(conLSigma是Cholesky因子)

这花费了很多时间,因为我正在对每个循环进行逆和Cholesky分解.它比纯python代码更快,但我想知道是否有任何方法可以提高速度.

from __future__ import division

import numpy as np 

cimport numpy as np 

ctypedef np.float64_t dtype_t

cimport cython
@cython.boundscheck(False)
@cython.wraparound(False)

def drawMetro(np.ndarray[dtype_t, ndim = 2] beta,
              np.ndarray[dtype_t, ndim = 3] H,
              np.ndarray[dtype_t, ndim = 2] Sigma,
              float s):

    cdef int ncons = betas.shape[0]
    cdef int nX = betas.shape[1]
    cdef int con

    cdef np.ndarray betas_cand = np.zeros([ncons, nX], dtype = np.float64)
    cdef np.ndarray conLSigma = np.zeros([nX, nX], dtype = np.float64)

    for con in xrange(ncons):
        conLSigma = np.linalg.cholesky(np.linalg.inv(H[con] + Sigma))
        betas_cand[con] …
Run Code Online (Sandbox Code Playgroud)

python numpy cython

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

纯python ssh

在纯python中是否有SSH的实现?最好是开源?

我特意找的是客户端,而不是服务器.

python ssh

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

Android ScrollView在子imageview的顶部和底部添加了额外的填充

我在渲染ScrollView时遇到问题.基本上,布局是固定的页眉和页脚,中间有一个滚动视图.我们的想法是,当为内容EditText激活屏幕键盘时,如果图像的高度比中间视图长,则可以滚动图像.

在测试布局时,我发现在我的Android手机(Xperia X10 Android 1.6)上,在ImageView的顶部和底部添加了一大堆填充.

我很感激有关如何防止这种情况发生的任何建议.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <!-- Header -->
    <RelativeLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#FFFFFF">
        <TextView
            android:text="Share your photo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="left"/>
        <Button
            android:id="@+id/btnStack"
            android:text="Stacks"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"/>
    </RelativeLayout>
    <!-- End Header -->


    <!-- Body -->
    <ScrollView
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:padding="5px"
        android:background="#CCCCCC">
        <ImageView
            android:id="@+id/imgPreview"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
    </ScrollView>
    <!-- End Body -->


    <!-- Footer -->
    <RelativeLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#FFFFFF"
        android:layout_alignParentBottom="true">
        <EditText
            android:id="@+id/caption"
            android:text="Type your caption"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/caption" …
Run Code Online (Sandbox Code Playgroud)

android emulation scrollview imageview

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

C#WinForms:我应该使用Web浏览器控件吗?

我正在构建一个Windows窗体应用程序,我将在其中添加一个控件,它将显示相当多的不同数据.在大多数情况下,内部数据将是导航按钮和帮助/培训文本.

我认为如果我能用HTML编写内容然后只在应用程序的控件中显示它,那将是理想的,但我不确定这是不是一个好主意.

另一点需要注意的是,在不久的将来某个时候将会有一个基于Web的相同应用程序版本,并且在HTML中执行这部分应用程序将使非常容易的可重用性.

如果这很重要,用户将不会安装IIS.

c# winforms

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