小编dom*_*omi的帖子

使用上下文操作栏在自定义列表视图上选择的项目

我最近开始使用机器人为其他动作上下文的动作条(CAB).

我只有一个活动是ListActivity.基本上我使用以下代码剪切来"激活"CAB:

ListView listView = getListView();
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
listView.setMultiChoiceModeListener(new MultiChoiceModeListener() {

    @Override
    public void onItemCheckedStateChanged(ActionMode mode, int position,
                                      long id, boolean checked) {
        // Here you can do something when items are selected/de-selected,
        // such as update the title in the CAB
    }

    @Override
    public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
        // Respond to clicks on the actions in the CAB
        switch (item.getItemId()) {
            case R.id.menu_delete:
                deleteSelectedItems();
                mode.finish(); // Action picked, so close the CAB
                return true; …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-listview android-linearlayout

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

无法在xd-singlenode上使用spring-data-jpa部署spring-xd处理器模块

我有一个spring-xd处理器模块,它使用spring-data-jpa对项目具有依赖性:

xd-processor模块的pom.xml:

<dependencies>
    <dependency>
        <groupId>org.test.common</groupId>
        <artifactId>org.test.common</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)

org.test.common的pom.xml:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)

如果我运行集成测试一切正常.但是部署到xd-singlenode(1.2.0.RELEASE)失败,出现以下错误:

2015-06-21T20:50:35+0200 1.2.0.RELEASE ERROR    DeploymentsPathChildrenCache-0 boot.SpringApplication - Application startup failed
java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.jpaVendorAdapter
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:58) ~[spring-boot-autoconfigure-1.2.3.RELEASE.jar:1.2.3.RELEASE]
...
Caused by: java.lang.IllegalArgumentException: @ConditionalOnMissingBean annotations must specify at least one bean (type, name or annotation)
...
Run Code Online (Sandbox Code Playgroud)

你可以在github上查看完整的样本.

我究竟做错了什么?任何帮助,将不胜感激.

java spring maven spring-data-jpa spring-xd

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

从Spring RESTful资源服务器验证OAuth 2.0访问令牌

我想保护我的Spring RESTful后端.一种方式(右边?)是使用OAuth 2.0,如下所示:

http://www.youtube.com/watch?v=8uBcpsIEz2I

在我的架构中,资源服务器和授权服务器不是同一个实体.我真的只是提供一些JSON REST服务.没有UI.如果我阅读OAuth2 RFC,他们只会说:

授权服务器和资源服务器之间的交互超出了本规范的范围.授权服务器可以是与资源服务器相同的服务器或单独的实体.单个授权服务器可以发出由多个资源服务器接受的访问令牌.

我在cloudfoundry.com上找到了一个很好的图表(与上面的youtube视频相关),我用它来说明我的观点:

在此输入图像描述

"令牌"提供者:这可能/应该是google或facebook.

RESTful后端:这实际上是我的代码.Spring RESTful服务,例如:

@Controller
@RequestMapping("/api/v1")
public class MyResourceToProtect {

    @Autowired
    private MyService service;

    @RequestMapping(value = "/resource/delete/{name}",
                    method = RequestMethod.DELETE,
                    consumes = MediaType.APPLICATION_JSON_VALUE,
                    headers = "Content-Type=application/json")
    @ResponseStatus(HttpStatus.OK)
    public void delete(@PathVariable("name") String name) {
        service.delete(name);
    }
}
Run Code Online (Sandbox Code Playgroud)

(这只是一些示例代码)

现在我的问题是:以某种方式可以验证由AuthServer(Facebook,Google)生成的访问令牌吗?我知道我需要在ResourceServer的某个地方有一个"令牌到用户"映射(数据库).基本上我想设计一个来自PayPal的RESTful API:

https://developer.paypal.com/webapps/developer/docs/integration/direct/make-your-first-call/

但是,如果我想使用Facebook或Google作为身份验证提供商,我该如何处理步骤1和2?这甚至可能吗?

额外的想法:可能我需要提供自己的/oauth2/token端点,然后委托给底层的AuthProvider.

java rest spring spring-security oauth-2.0

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

用android.content.Intent.ACTION_SENDTO启动whatsapp

我正在试图用android意图启动whatsapp:

String uri = "smsto:+123456";
Intent messageIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse(uri));
messageIntent.putExtra("sms_body", "My Message");
startActivity(messageIntent);
Run Code Online (Sandbox Code Playgroud)

如果用户选择正常的消息传递应用程序,它会很有用.但是如果用户从选择器中选择whatsapp则不行.来自whatsapp的"撰写文本字段"仍为空.

我在这做错了什么?我需要另一个putExtra()吗?

messaging android uri android-intent whatsapp

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