当前位置:  编程技术>移动开发
本页文章导读:
    ▪PendingIntent的重复有关问题        PendingIntent的重复问题 今天做Android推送通知模块,发现在Service中使用PendingIntent打开Activity时,虽然每次通知都会改变putExtra中的值,但是Activity里getStringExtra时,值没有任何变化,很奇怪。 加.........
    ▪ spring security原理图及其解释(3)        spring security原理图及其解释(三) What is spring_security_login and how did we get here?You may have noticed that when you attempted to hit the home page of our JBCP Pets store, you were redirected to the URL http://localhost:8080/JBCPPets.........
    ▪ andriod一次退出全部的Activity       andriod一次退出所有的Activity 自己实现了一个Activity管理,可以实现一次退出所有的Activity。在Activity启动的时候,将调用里面的put方法,将Activity对象加入进来。在要退出某个activity的时候.........

[1]PendingIntent的重复有关问题
    来源: 互联网  发布时间: 2014-02-18
PendingIntent的重复问题

今天做Android推送通知模块,发现在Service中使用PendingIntent打开Activity时,虽然每次通知都会改变putExtra中的值,但是Activity里getStringExtra时,值没有任何变化,很奇怪。


加了一些Flag

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
 


也没有起作用

 

查了一些资料,发现如果你之前已经创建过一个PendingIntent,而之后创建的PendingIntent和之前的基本相似,那么就必须加上如下的声明PendingIntent.FLAG_UPDATE_CURRENT,否则extras不会传递到目标Activity

 

PendingIntent contentIntent = PendingIntent.getActivity(this, 0, 
                        notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); 
 


原文如下:

http://stackoverflow.com/questions/4340431/how-can-i-correctly-pass-unique-extras-to-a-pending-intent

 


    
[2] spring security原理图及其解释(3)
    来源: 互联网  发布时间: 2014-02-18
spring security原理图及其解释(三)
What is spring_security_login and how did we get here?

You may have noticed that when you attempted to hit the home page of our JBCP Pets store, you were redirected to the URL http://localhost:8080/JBCPPets/ spring_security_login




The spring_security_login portion of the URL represents a default login page as named in the DefaultLoginPageGeneratingFilter class. We can use configuration attributes to adjust the name of this page to be something unique to our application.

Let's look at the HTML source of this form (stripping out table layout information) to figure out what the UsernamePasswordAuthenticationFilter is expecting:

<form name='f' action='/JBCPPets/j_spring_security_check/index.html' method='POST'>
    User:<input type='text' name='j_username' value=''>
    Password:<input type='password' name='j_password'/>
    <input name="submit" type="submit"/>
    <input name="reset" type="reset"/>
</form>

As our application is not utilizing the security component of our host servlet container, we could explicitly configure the UsernamePasswordAuthenticationFilter to expect form fields with different names. This particular configuration change is more complicated than you might expect; so for now, we'll trace back the lineage of UsernamePasswordAuthenticationFilter to see how it arrived in our configuration in the first place

The UsernamePasswordAuthenticationFilter is configured through the use of the <form-login> sub-element of the <http> configuration directive. As we mentioned earlier in this chapter, the auto-config attribute that we set will automatically add <form-login> capability to your application if you haven't explicitly included the directive. As you may guess, the j_spring_security_check URL doesn't map to anything physical in our application. This is a special URL that is watched for by the UsernamePasswordAuthenticationFilter to handle form-based login. In fact, there are several of these special URLs that cover specific global behavior in Spring Security. You'll find a table of these URLs in Appendix, Additional Reference Material.

Where do the user's credentials get validated?

In our simple three-step configuration file, we used an in-memory credential store to get up and running quickly:

<authentication-manager alias="authenticationManager">
        <authentication-provider>
                <user-service>
                        <user authorities="ROLE_USER" name="guest" password="guest"/>
                </user-service>
        </authentication-provider>
</authentication-manager>

We didn't wire this AuthenticationProvider to any explicit implementation, and we see once again that the security namespace handler performs a lot of rote configuration work on our behalf. Remember that the default implementation of the AuthenticationManager supports configuration of one or more AuthenticationProvider implementations. The <authentication-provider> declaration will by default instantiate an out of the box implementation known as o.s.s.authentication.dao.DaoAuthenticationProvider. The declaration of the <authentication-provider> element will also automatically wire this AuthenticationProvider to the configured (or, in our case, automatically configured) AuthenticationManager.

AuthenticationProvider虽然没有指定实现类,但是系统默认为我们指定了。而且默认的AuthenticationManager实现支持一个或者多个AuthenticationProvider。<authentication-provider>默认声明一个箱外的实现DaoAuthenticationProvider,用它来声明的会自动装配到AuthentiacationManager里面。

The DaoAuthenticationProvider is an AuthenticationProvider that provides a thin wrapper to implement the AuthenticationProvider interface and then delegates to an implementation of the o.s.s.core.userdetails. UserDetailsService interface. The UserDetailsService is responsible for returning an implementation of o.s.s.core.userdetails.UserDetails.

DaoAuthenticationProvider是一种AuthenticationProvider并且提供了一层AuthenticationProvider接口的简单实现,它代理UserDetailsService的实现。UserDetailsService 负责返回一个UserDetails的实现。

If you review the Javadoc for UserDetails, you'll notice that it looks strikingly similar to the Authentication interface we reviewed earlier. Don't get confused, although they have a lot of overlap in method names and capabilities, they have quite different purposes:

如果你重新看javadoc来查看UserDetails,你会发现它和接口Authentication非常相似。不要搞混了,虽然他们有很多重复的方法名和容器,但是他们有不同的目的:





Our declaration of the <user-service> subelement triggered a configuration of the o.s.s.core.userdetails.memory.InMemoryDaoImpl implementation of the UserDetailsService. As you'd anticipate, this implementation stores the users configured in the XML security configuration file in a memory-resident data store. The configuration of this service supports other attributes allowing accounts to be disabled or locked as well.

Let's visually review how the components of the DaoAuthenticationProvider interact to provide authentication support to the AuthenticationManager:



    
[3] andriod一次退出全部的Activity
    来源: 互联网  发布时间: 2014-02-18
andriod一次退出所有的Activity
自己实现了一个Activity管理,可以实现一次退出所有的Activity。在Activity启动的时候,将调用里面的put方法,将Activity对象加入进来。在要退出某个activity的时候,将其remove。如果要退出所有的Activity,调用closeAllActivity即可。
/*
 * @(#)ActivityManager.java		       version: 0.1 
 * Date:2012-2-3
 *
 * Copyright (c) 2011 CFuture09, Institute of Software, 
 * Guangdong Ocean University, Zhanjiang, GuangDong, China.
 * All rights reserved.
 */
package com.sinaapp.msdxblog.androidkit.ui.util;

import java.util.HashMap;

import java.util.Set;

import android.app.Activity;

/**
 * 一个Activity管理器管理活动的Activity。
 * 
 * @author Geek_Soledad (66704238@51uc.com)
 */
public class ActivityTaskManager {

	private static ActivityTaskManager activityTaskManager = null;
	private HashMap<String, Activity> activityMap = null;

	private ActivityTaskManager() {
		activityMap = new HashMap<String, Activity>();
	}

	/**
	 * 返回activity管理器的唯一实例对象。
	 * 
	 * @return
	 */
	public static synchronized ActivityTaskManager getInstance() {
		if (activityTaskManager == null) {
			activityTaskManager = new ActivityTaskManager();
		}
		return activityTaskManager;
	}

	/**
	 * 将一个activity添加到管理器。
	 * 
	 * @param activity
	 */
	public Activity putActivity(String name, Activity activity) {
		return activityMap.put(name, activity);
	}

	/**
	 * 得到保存在管理器中的Activity对象。
	 * 
	 * @param name
	 * @return
	 */
	public Activity getActivity(String name) {
		return activityMap.get(name);
	}

	/**
	 * 返回管理器的Activity是否为空。
	 * 
	 * @return 当且当管理器中的Activity对象为空时返回true,否则返回false。
	 */
	public boolean isEmpty() {
		return activityMap.isEmpty();
	}

	/**
	 * 返回管理器中Activity对象的个数。
	 * 
	 * @return 管理器中Activity对象的个数。
	 */
	public int size() {
		return activityMap.size();
	}

	/**
	 * 返回管理器中是否包含指定的名字。
	 * 
	 * @param name
	 *            要查找的名字。
	 * @return 当且仅当包含指定的名字时返回true, 否则返回false。
	 */
	public boolean containsName(String name) {
		return activityMap.containsKey(name);
	}

	/**
	 * 返回管理器中是否包含指定的Activity。
	 * 
	 * @param activity
	 *            要查找的Activity。
	 * @return 当且仅当包含指定的Activity对象时返回true, 否则返回false。
	 */
	public boolean containsActivity(Activity activity) {
		return activityMap.containsValue(activity);
	}

	/**
	 * 关闭所有活动的Activity。
	 */
	public void closeAllActivity() {
		Set<String> activityNames = activityMap.keySet();
		for (String string : activityNames) {
			finisActivity(activityMap.get(string));
		}
		activityMap.clear();
	}

	/**
	 * 关闭所有活动的Activity除了指定的一个之外。
	 * 
	 * @param nameSpecified
	 *            指定的不关闭的Activity对象的名字。
	 */
	public void closeAllActivityExceptOne(String nameSpecified) {
		Set<String> activityNames = activityMap.keySet();
		Activity activitySpecified = activityMap.get(nameSpecified);
		for (String name : activityNames) {
			if (name.equals(nameSpecified)) {
				continue;
			}
			finisActivity(activityMap.get(name));
		}
		activityMap.clear();
		activityMap.put(nameSpecified, activitySpecified);
	}

	/**
	 * 移除Activity对象,如果它未结束则结束它。
	 * 
	 * @param name
	 *            Activity对象的名字。
	 */
	public void removeActivity(String name) {
		Activity activity = activityMap.remove(name);
		finisActivity(activity);
	}

	private final void finisActivity(Activity activity) {
		if (activity != null) {
			if (!activity.isFinishing()) {
				activity.finish();
			}
		}
	}
}

本文原创,转载请注明原文地址:http://maosidiaoxian.iteye.com/blog/1404725
或我的另一个个人博客:http://msdxblog.sinaapp.com

    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3