小编Mr_*_*s_D的帖子

Android:IllegalArgumentException:API 17中的"组件类X不存在"(API 8中没有崩溃)

我的模拟器:

模拟器

当我启动平板电脑模拟器时,我得到:

FATAL EXCEPTION: main
java.lang.IllegalArgumentException: Component class TriggerMonitoringBootReceiver does not exist in di.k23b.hw3
    at android.os.Parcel.readException(Parcel.java:1429)
    at android.os.Parcel.readException(Parcel.java:1379)
    at android.content.pm.IPackageManager$Stub$Proxy.setComponentEnabledSetting(IPackageManager.java:2561)
    at android.app.ApplicationPackageManager.setComponentEnabledSetting(ApplicationPackageManager.java:1250)
    at di.k23b.hw3.receivers.TriggerMonitoringBootReceiver.enable(TriggerMonitoringBootReceiver.java:81)
    at di.k23b.hw3.receivers.TriggerMonitoringBootReceiver.enable(TriggerMonitoringBootReceiver.java:86)
    at di.k23b.hw3.activities.SettingsActivity.onSharedPreferenceChanged(SettingsActivity.java:192)
    at android.app.SharedPreferencesImpl$EditorImpl.notifyListeners(SharedPreferencesImpl.java:475)
    at android.app.SharedPreferencesImpl$EditorImpl.apply(SharedPreferencesImpl.java:385)
    at android.preference.Preference.tryCommit(Preference.java:1349)
    at android.preference.Preference.persistBoolean(Preference.java:1615)
    at android.preference.TwoStatePreference.setChecked(TwoStatePreference.java:83)
    at android.preference.TwoStatePreference.onClick(TwoStatePreference.java:69)
    at android.preference.Preference.performClick(Preference.java:949)
    at android.preference.PreferenceScreen.onItemClick(PreferenceScreen.java:215)
    at android.widget.AdapterView.performItemClick(AdapterView.java:298)
    at android.widget.AbsListView.performItemClick(AbsListView.java:1100)
    at android.widget.AbsListView$PerformClick.run(AbsListView.java:2749)
    at android.widget.AbsListView$1.run(AbsListView.java:3423)
    at android.os.Handler.handleCallback(Handler.java:725)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5041)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
    at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)

当我启动froyo模拟器时一切都很好(编辑:不,它不是 - 接收器未启用但仍然没有崩溃).
这是一个已知的问题还是什么? …

android illegalargumentexception android-2.2-froyo

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

完全用github中的另一个替换远程分支,不留下旧的痕迹

我把一个分支推到了一个空的github仓库:

MrD@MRSD /c/Dropbox/eclipse_workspaces/javaEE/ted2012 (GitHubSquash)
$ git remote add github  https://github.com/Utumno/ted2012.git
MrD@MRSD /c/Dropbox/eclipse_workspaces/javaEE/ted2012 (GitHubSquash)
$ git push -u github GitHubSquash
Username for 'https://github.com': Utumno
Password for 'https://Utumno@github.com':
//...
To https://github.com/Utumno/ted2012.git
 * [new branch]      GitHubSquash -> GitHubSquash
Branch GitHubSquash set up to track remote branch GitHubSquash from github.
Run Code Online (Sandbox Code Playgroud)

然后我注意到我已经推了一些绒毛并试图删除分支/用另一个等替换它.我失败了:

MrD@MRSD /c/Dropbox/eclipse_workspaces/javaEE/ted2012 (GitHub2)
$ git push  :github && git push github GitHub2
ssh: connect to host  port 22: Bad file number
fatal: Could not read from remote repository.

Please make sure you have …
Run Code Online (Sandbox Code Playgroud)

git ssh push

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

无法通过反射hibernate获取字段值

我在jpa中更新对象时遇到问题

我有bean用户

public class User {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    private Long id;
    @Column(name = "name", nullable = false)
    private String name;
    @OneToMany(fetch = FetchType.EAGER)
    @JoinColumn(name = "fk_program_rating")
    private List<Rating> ratingList = new ArrayList<Rating>();
}
Run Code Online (Sandbox Code Playgroud)

public class Rating extends BaseModel {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    private Long id;
    @ManyToOne()
    @JoinColumn(name = "fk_program_rating", nullable = false)
    @ForeignKey(name = "FK_prog_rate")
    @OnDelete(action = OnDeleteAction.CASCADE) …
Run Code Online (Sandbox Code Playgroud)

java hibernate jpa

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

在android设置中防止"匹配的活动可能不存在"

Settings类中的大多数Activity Actions(用于启动各种Settings活动)都带有警告:

在某些情况下,匹配的活动可能不存在,因此请确保您不会受到此类保护.

那我该如何防范呢?

try {
    final Intent i = new Intent(Settings. ACTION_WIRELESS_SETTINGS); // say
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // not sure if needed
    startActivity(i);
} catch (Exception e) { // what should I catch here 
    // I would hate to catch Throwable, but should I ?
}
Run Code Online (Sandbox Code Playgroud)

如果我正确读取了这个,例如抛出了运行时异常(NPE).我希望能够使用更具体的东西ActivityNotFoundException- 但这样就够了吗?

android android-intent android-activity android-settings

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

当我定义一个接口方法的参数final时,我需要在实现中重复final吗?

所以我需要在下面的案例中重复最终决定吗?

interface Foo {

    void meth(final Bar bar);
}

public Baz implements Foo {

    @Override
    void meth(/* is it final ?*/ Bar bar){}
}
Run Code Online (Sandbox Code Playgroud)

问题不仅是接口继承,还有类继承 - 我猜答案是一样的

java inheritance final

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

Servlet/JSP MVC模式如何转换为JSF/Facelets(特别是服务和控制器部分)?

让我们举一个基本的例子.在servlet应用程序中,我将拥有这些类:

  • app.domain.User:域或模型POJO,将包含字段和getter/setter
  • app.service.UserService:将包含对User实例进行操作的方法,例如Register(User).会打电话给DAO.
  • app.dao.UserDao:实际上会被服务调用,比如在数据库中插入一个用户.
  • app.servlets.RegisterController:一个servlet拦截对www.app/registration的请求并调用app.service.UserService中的方法.然后它会重定向到WEB-INF\JSPs\registration.jsp哪个会处理视图.

所有这些对我来说都很有意义,并且明确区分了这些问题.

我已经尝试过围绕JSF/Facelets的思维方式.我已经在SO和其他地方经历了许多优秀的资源,但是没有任何地方可以解决这个简单的问题 - 即dao/service/controller/view模式如何转换为JSF.

继续我的例子 - 我已经在eclipse中设置了一个JSF项目,已经将我的数据库模式转换为"entities"现在我想知道 - 我应该创建什么样的类来处理用户注册?我知道我必须为视图创建xhtml页面,但控制器在哪里?

请不要指教我- 我知道很多,其中@BalusC一个 - 我的问题不是让这个工作,而是要了解模式.我已经看到"session"包中包含"托管bean","抽象外观"模式等等,但没有任何东西可以像旧的servlet模式一样清晰.

所以 - 在DB创建的"实体"中,有一个看起来像模型的User.java类.该视图将是一个xhtml.控制器?

注意:这并不是要求这么多重复这些技术之间的差异 - 我要求将非常清晰直观的控制器/ dao /服务模式清晰地转换为JSF框架 - 或明确声明不存在这样的技术翻译.

也可以看看:

model-view-controller jsf jsp servlets java-ee

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

是否可以在Qt5 QML中断开所有插槽与信号的连接?

在QML中,不可能在.disconnect()没有参数的情况下调用信号:

file:mainwindow.qml:107: Error: Function.prototype.disconnect: no arguments given
Run Code Online (Sandbox Code Playgroud)

那么如何在不指定每个插槽的情况下断开所有插槽?或者也许可以通过传递信号对象C++并以某种方式断开它?或者可能存在任何解决方法?

我想达到的目标是通过将不同的插槽连接到它的信号来改变对象的行为.例如:

object.disconnect() // disconnect all slots
object.connect(one_super_slot)
object.disconnect() // disconnect all slots
object.connect(another_super_slot)
Run Code Online (Sandbox Code Playgroud)

qt signals disconnect qml slot

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

2> LINK:致命错误LNK1104:无法打开文件'libboost_filesystem-vc120-mt-sgd-1_58.lib'

难怪因为没有这样的文件...\boost_1_58_0\stage\lib.我该怎么办?我只有:

boost_1_58_0\stage\lib\libboost_filesystem-vc120-mt-s-1_58.lib
boost_1_58_0\stage\lib\libboost_filesystem-vc120-s-1_58.lib
Run Code Online (Sandbox Code Playgroud)

在那里.尝试使用各种选项进行编译提升 --build-type=complete(最终解决它的问题)(链接器错误LNK1104中的"穷人"解决方案与'libboost_filesystem-vc100-mt-s-1_49.lib')得到:

> b2 toolset=msvc threadapi=win32 link=static runtime-link=static \
variant=release address-model=32 --with-filesystem --with-locale --with-regex \
--with-system --with-iostreams --build-type=complete
Run Code Online (Sandbox Code Playgroud)

在我正在导入的项目的自述文件中建议的命令行 - 仍然没有乐趣.这是一个CMake项目我为构建MSVS解决方案付出了一些努力.

注意:仔细观察CMake gui时我的问题解决了:

在此输入图像描述

我意识到,当我右键单击"解决方案">配置管理器>更改为发布版本时,调试配置无法构建且确定无误.问题仍然存在 - 我如何获得libboost_filesystem-vc120-mt- sgd -1_58.lib构建?

boost cmake msvc12

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

Python Popen - wait vs communication vs CalledProcessError

继续我之前的问题,我看到要获取我在python中通过Popen生成的进程的错误代码,我必须调用wait()或communic()(可以用来访问Popen stdout和stderr属性):

app7z = '/path/to/7z.exe'
command = [app7z, 'a', dstFile.temp, "-y", "-r", os.path.join(src.Dir, '*')]
process = Popen(command, stdout=PIPE, startupinfo=startupinfo)
out = process.stdout
regCompressMatch = re.compile('Compressing\s+(.+)').match
regErrMatch = re.compile('Error: (.*)').match
errorLine = []
for line in out:
    if len(errorLine) or regErrMatch(line):
        errorLine.append(line)
    if regCompressMatch(line):
        # update a progress bar
result = process.wait() # HERE
if result: # in the hopes that 7z returns 0 for correct execution
    dstFile.temp.remove()
    raise StateError(_("%s: Compression failed:\n%s") % (dstFile.s, 
                       "\n".join(errorLine)))
Run Code Online (Sandbox Code Playgroud)

然而,文档警告wait() …

python error-handling popen python-2.7

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

访问pandas数据列中的total_seconds()

我想在pandas数据框中创建一个新列,它是从数据帧开始经过的时间.我正在将日志文件导入到具有数据时间信息的数据框中,但是访问s_df ['delta_t']中的total_seconds()函数不起作用.如果我访问列的各个元素(s_df ['delta_t'].iloc [8] .total_seconds()),它可以工作,但我想用total_seconds()创建一个新列,我的尝试失败了.

s_df['t'] = s_df.index  # s_df['t] is a column of datetime
s_df['delta_t'] = ( s_df['t'] - s_df['t'].iloc[0]) # time since start of data frame
s_df['elapsed_seconds'] = # want column s_df['delta_t'].total_seconds()
Run Code Online (Sandbox Code Playgroud)

python datetime pandas

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