??xml version="1.0" encoding="utf-8" standalone="yes"?>99国产精品国产精品毛片,蜜臀av一区二区三区,国产精品推荐精品http://www.aygfsteel.com/lincode/archive/2012/05/29/379418.htmllincodelincodeTue, 29 May 2012 03:07:00 GMThttp://www.aygfsteel.com/lincode/archive/2012/05/29/379418.htmlhttp://www.aygfsteel.com/lincode/comments/379418.htmlhttp://www.aygfsteel.com/lincode/archive/2012/05/29/379418.html#Feedback0http://www.aygfsteel.com/lincode/comments/commentRss/379418.htmlhttp://www.aygfsteel.com/lincode/services/trackbacks/379418.html1 Launch Keychain Access from your local Mac and from the login keychain, filter by the Certificates category. You will see an expandable option called “Apple Development Push Services”
2 Right click on “Apple Development Push Services” > Export “Apple Development Push Services ID123″. Save this as apns-dev-cert.p12 file somewhere you can access it. There is no need to enter a password.
3 The next command generates the cert in Mac’s Terminal for PEM format (Privacy Enhanced Mail Security Certificate):
openssl pkcs12 -in apns-dev-cert.p12 -out apns-dev-cert.pem -nodes -clcerts


lincode 2012-05-29 11:07 发表评论
]]>
[iOS] 引用外部?rn)态库Ӟ目录Ҏ(gu)无法加蝲问题http://www.aygfsteel.com/lincode/archive/2012/04/23/376373.htmllincodelincodeMon, 23 Apr 2012 06:56:00 GMThttp://www.aygfsteel.com/lincode/archive/2012/04/23/376373.htmlhttp://www.aygfsteel.com/lincode/comments/376373.htmlhttp://www.aygfsteel.com/lincode/archive/2012/04/23/376373.html#Feedback0http://www.aygfsteel.com/lincode/comments/commentRss/376373.htmlhttp://www.aygfsteel.com/lincode/services/trackbacks/376373.htmlq个 bug ?xcode 4.3 以下?x)出玎ͼ?.3 以后已经修正?jin)?br />解决Ҏ(gu)为:(x)扑ֈ target 的图标,更改?Other Linker Flags 为:(x) -all_load ?-force_load
-force_loadQ后跟随一个文件位|,可以更精地加蝲所需文g?br /> 
Ҏ(gu)的解释ؓ(f) Q?http://developer.apple.com/library/mac/#qa/qa1490/_index.html

单点说就是,Objective-C 的动态特性得需要,为链接器d一个标{(讄 Other Linker Flags ?-ObjCQ来解决通过 Category 向类dҎ(gu)的问题?br />但这个标{?QObjC ?64 ??iOS 中有问题Q需要?-all_load ?-force_load?br />
ȝ如下Q?br />如果Q第三库中没?categoryQOther Linker Flags 无需讄
如果Q第三方库中?categoryQ需要设|ؓ(f) -ObjC
如果Q某?Xcode 版本中,出现问题Q修改设|ؓ(f) -all_load

lincode 2012-04-23 14:56 发表评论
]]>
[iOS] 阅读 Crash Report http://www.aygfsteel.com/lincode/archive/2012/03/18/372131.htmllincodelincodeSun, 18 Mar 2012 05:56:00 GMThttp://www.aygfsteel.com/lincode/archive/2012/03/18/372131.htmlhttp://www.aygfsteel.com/lincode/comments/372131.htmlhttp://www.aygfsteel.com/lincode/archive/2012/03/18/372131.html#Feedback0http://www.aygfsteel.com/lincode/comments/commentRss/372131.htmlhttp://www.aygfsteel.com/lincode/services/trackbacks/372131.html获得 Crash ReportQ?/strong>
1 itunesConnect 的后C(x)提供一?Crash report 表;
2 把一台打开?jin)开发模式的机器接入 MacQXcode ?Organizer 中能查看q台讑֤?Crash ReportQ?br />3 若用了(jin) Umeng.com, Bugsense.com 之类的工兗?br />
阅读 Crash Report:
q之前需要一个名?AppName.app.dSYM 的文件。Xcode 中,Archive 一个项目之后,可以?Organizer ?Archives 分页中,扑ֈ所有项目的 Archvie 文g?br />右键点击一个, Show Package ContentQ就能看C个类?AppNameQ?Q?9Q?2.app.PM.xcarchive  的文Ӟshow in finder q个文gQ就能找?.dSYM 文g?br />
?Ternimal 中执行,若是 来自?iphone 3G 的机器,需要?armv6 代替 armv7.

 atos -o AppName.app.dSYM/Contents/Resources/DWARF/AppName  -arch armv7 0x0000b82

q样p看到Q地址对应的类Q函敎ͼ代码行数。这个命令只能解析出客户代码的位|。若是错误堆栈中的系l调用,是无法翻译出来的?/div>

lincode 2012-03-18 13:56 发表评论
]]>[iOS] 地址反向解析http://www.aygfsteel.com/lincode/archive/2012/01/12/368424.htmllincodelincodeThu, 12 Jan 2012 13:27:00 GMThttp://www.aygfsteel.com/lincode/archive/2012/01/12/368424.htmlhttp://www.aygfsteel.com/lincode/comments/368424.htmlhttp://www.aygfsteel.com/lincode/archive/2012/01/12/368424.html#Feedback0http://www.aygfsteel.com/lincode/comments/commentRss/368424.htmlhttp://www.aygfsteel.com/lincode/services/trackbacks/368424.htmlGoogle map 也提供了(jin)一个类似的服务Q是讉K一?google map ?apiQ这里试囑ְ装了(jin) google map 的服务。使用 apple ?google 的服务的接口基本一_(d)替换h很容易。Google map 的这个服务在中国的状态比 apple E微好一些,但也有不E_的时候。我猜想Qapple 也许是?google 的服务封装了(jin)自己?nbsp;MKReverseGeocoder。若是如此,q里的尝试也没有什么意义了(jin)?br />
DOUHttpRequest 是对 ASIHTTPRequest 的一个简单封装。这些代码可?l承?nbsp;MKReverseGeocoder。这P使用Ҏ(gu)和 MKReverseGeocoder 一样了(jin)?br />
static NSString* kGeoServerUrl = @"http://maps.google.com/maps/api/geocode/json?latlng=%f,%f&sensor=true&language=en";
static NSString* kLatitudeUserInfoKey = @"latitudeUserInfoKey";
static NSString* kLongitudeUserInfoKey = @"longitudeUserInfoKey";

//
// It's tje solution for replacing MKReverseGeocoder that has problem in China.
//
- (void)startedReverseGeoderWithLatitude:(double)latitude longitude:(double)longitude {
  NSString *url = [NSString stringWithFormat:kGeoServerUrl, latitude, longitude];
  DOUHttpRequest *req = [DOUHttpRequest requestWithURL:[NSURL URLWithString:url] target:self];
  
  NSNumber *lat = [NSNumber numberWithDouble:latitude];
  NSNumber *lon = [NSNumber numberWithDouble:longitude];
  req.userInfo = [NSDictionary dictionaryWithObjectsAndKeys:lat, kLatitudeUserInfoKey, lon, kLongitudeUserInfoKey, nil];
  
  DOUService *service = [DOUService sharedInstance];  
  [service addRequest:req];
}


- (NSDictionary *)addressDictionary:(NSObject *)obj {
  
  NSArray* ary = nil;
  if (IS_INSTANCE_OF(obj, NSDictionary)) {
    NSObject* data = [(NSDictionary*)obj objectForKey:@"results"];
    if (IS_INSTANCE_OF(data, NSArray)) {
      ary = (NSArray*)data;
      NSDictionary *dic = [ary objectAtIndex:0];
      
      NSArray *addressComps = [dic objectForKey:@"address_components"];
      
      //NSString *streetNumber = @"";
      NSString *route = @"";
      NSString *locality = @"";
      NSString *country = @"";
      for (NSDictionary *comp in addressComps) {
        NSArray *types = [comp objectForKey:@"types"];
        NSString *type = [types objectAtIndex:0];
        
//        if ([type isEqualToString:@"street_number"]) {
//          streetNumber = [comp objectForKey:@"long_name"];
//        }
        
        if ([type isEqualToString:@"route"]) {
          route = [comp objectForKey:@"long_name"];
        }
        
        if ([type isEqualToString:@"locality"]) {
          locality = [comp objectForKey:@"long_name"];
        }
        
        if ([type isEqualToString:@"country"]) {
          country = [comp objectForKey:@"long_name"];
        }        
      }
      
      NSDictionary *addressDic = [NSDictionary dictionaryWithObjectsAndKeys:route, kABPersonAddressStreetKey,
                                  locality, kABPersonAddressCityKey,                                        
                                  country, kABPersonAddressCountryKey, nil];
      return addressDic;
    }
  }
  return nil;
}


- (void)requestFinished:(DOUHttpRequest *)req {
  NSError *error = [req error];
  if (!error) {
    DebugLog(@"str:%@", [req responseString]);
    
    NSObject *obj = [[req responseString] JSONValue];
    NSDictionary *addressDic = [self addressDictionary:obj];
    
    CLLocationCoordinate2D coordinate;
    coordinate.latitude = [[req.userInfo objectForKey:kLatitudeUserInfoKey] doubleValue];
    coordinate.longitude = [[req.userInfo objectForKey:kLongitudeUserInfoKey] doubleValue]; 
    MKPlacemark *placemark = [[[MKPlacemark alloc] initWithCoordinate:coordinate 
                                                   addressDictionary:addressDic] autorelease];
    [self reverseGeocoder:nil didFindPlacemark:placemark];
  }
}

- (void)requestFailed:(DOUHttpRequest *)req { 
  [self reverseGeocoder:nil didFailWithError:[req error]];
}


#pragma mark - MKReverseGeocoderDelegate

static NSString * const AppleLanguagesKey = @"AppleLanguages";

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark {

  NSArray *array = [[NSUserDefaults standardUserDefaults] objectForKey:AppleLanguagesKey];
  NSString *currentLanguage = [array objectAtIndex:0];
  
  // set current language as english
  [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"zh-Hans", nil] 
                                            forKey:AppleLanguagesKey];
  NSString *local = [placemark.locality lowercaseString];
 
  [AppContext sharedInstance].currentCityUid = local;
  
  // reset current language
  [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:currentLanguage, nil] 
                                            forKey:AppleLanguagesKey];
}

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error {
  TraceLog(@"reverseGeocoder :%@", [error localizedDescription]);  
}


lincode 2012-01-12 21:27 发表评论
]]>
OAuth 基本概念http://www.aygfsteel.com/lincode/archive/2011/10/27/362182.htmllincodelincodeThu, 27 Oct 2011 10:15:00 GMThttp://www.aygfsteel.com/lincode/archive/2011/10/27/362182.htmlhttp://www.aygfsteel.com/lincode/comments/362182.htmlhttp://www.aygfsteel.com/lincode/archive/2011/10/27/362182.html#Feedback0http://www.aygfsteel.com/lincode/comments/commentRss/362182.htmlhttp://www.aygfsteel.com/lincode/services/trackbacks/362182.html
定义

OAuthQ开放授权)(j)是一?a class="new" title="开放标? style="text-decoration: none; color: #ba0000; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">开放标?/a>Q允许用戯W三方应用访问该用户在某一|站上存储的U密的资源(如照片,视频Q联pMh列表Q,而无需用户名和密码提供给W三方应用?/p>

OAuth允许用户提供一个o(h)牌,而不是用户名和密码来讉K他们存放在特定服务提供者的数据。每一个o(h)牌授权一个特定的|站Q例如,视频~辑|站)在特定的时段Q例如,接下来的2时内)(j)内访问特定的资源Q例如仅仅是某一相册中的视频Q。这POAuth允许用户授权W三方网站访问他们存储在另外的服务提供者上的信息,而不需要分享他们的讉K许可或他们数据的所有内宏V?/p>

认证和授权过E?/strong>

在认证和授权的过E中涉及(qing)的三方包括:(x)

  • 服务提供?/strong>Q用户用服务提供方来存储受保护的资源,如照片,视频Q联pMh列表?/li>
  • 用户Q存攑֜服务提供方的受保护的资源的拥有者?/li>
  • 客户?/strong>Q要讉K服务提供方资源的W三方应用,通常是网站,如提供照片打印服务的|站。在认证q程之前Q客L(fng)要向服务提供者申请客L(fng)标识?/li>

使用OAuthq行认证和授权的q程如下所C?

  1. 用户讉K客户?/strong>的网站,x(chng)作用户存攑֜服务提供?/strong>的资源?/li>
  2. 客户?/strong>?strong>服务提供?/strong>h一个(f)时o(h)牌?/li>
  3. 服务提供?/strong>验证客户?/strong>的n份后Q授予一个(f)时o(h)牌?/li>
  4. 客户?/strong>获得临时令牌后,用户引D服务提供?/strong>的授权页面请求用h权。在q个q程中将临时令牌和客L(fng)?a title="回调函数" style="text-decoration: none; color: #0645ad; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">回调q接发送给服务提供?/strong>?/li>
  5. 用户?strong>服务提供?/strong>的网上输入用户名和密码Q然后授权该客户?/strong>讉K所h的资源?/li>
  6. 授权成功后,服务提供?/strong>引导用户q回客户?/strong>的网c(din)?/li>
  7. 客户?/strong>Ҏ(gu)临时令牌?strong>服务提供?/strong>那里获取讉K令牌?/li>
  8. 服务提供?/strong>Ҏ(gu)临时令牌?strong>用户的授权情冉|?strong>客户?/strong>讉K令牌?/li>
  9. 客户?/strong>使用获取的访问o(h)牌访问存攑֜服务提供?/strong>上的受保护的资源?/li>


OAuth 2.0

OAuth 2.0是OAuth协议的下一版本Q但不向后兼容OAuth 1.0?OAuth 2.0x(chng)客户端开发者的易性,同时为Web应用Q桌面应用和手机Q和起居室设备提供专门的认证程。规范还在IETF OAuth工作l的开发中 Q按?a class="new" title="Eran Hammer-Lahav" style="text-decoration: none; color: #ba0000; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial; ">Eran Hammer-Lahav的说法,OAuth于2010q末完成?/p>

Facebook的新的Graph API只支持OAuth 2.0QGoogle?font class="Apple-style-span" color="#0645ad">2011q??/span>亦宣佈Google APIOAuth 2.0的支援?/p>

lincode 2011-10-27 18:15 发表评论
]]>
Q{QRESTful 理解http://www.aygfsteel.com/lincode/archive/2011/10/27/362180.htmllincodelincodeThu, 27 Oct 2011 10:02:00 GMThttp://www.aygfsteel.com/lincode/archive/2011/10/27/362180.htmlhttp://www.aygfsteel.com/lincode/comments/362180.htmlhttp://www.aygfsteel.com/lincode/archive/2011/10/27/362180.html#Feedback0http://www.aygfsteel.com/lincode/comments/commentRss/362180.htmlhttp://www.aygfsteel.com/lincode/services/trackbacks/362180.html

名称

RESTQ即Representational State Transfer的羃写。我对这个词l的译?表现层状态{??/p>

如果一个架构符合REST原则Q就U它为RESTful架构?/p>

要理解RESTful架构Q最好的Ҏ(gu)是ȝ解Representational State Transferq个词组到底是什么意思,它的每一个词代表?jin)什么涵义?/strong>如果你把q个名称搞懂?jin),也就不难体?x)REST是一U什么样的设计?/p>

资源QResourcesQ?/strong>

REST的名U?表现层状态{?中,省略?jin)主语?表现?其实指的?资源"QResourcesQ的"表现??/p>

所?资源"Q就是网l上的一个实体,或者说是网l上的一个具体信息?/strong>它可以是一D|本、一张图片、一首歌曌Ӏ一U服务,M是一个具体的实在。你可以用一个URIQ统一资源定位W)(j)指向它,每种资源对应一个特定的URI。要获取q个资源Q访问它的URI可以,因此URI成?jin)每一个资源的地址或独一无二的识别符?/p>

所?上网"Q就是与互联|上一pd?资源"互动Q调用它的URI?/p>

表现层(RepresentationQ?/strong>

"资源"是一U信息实体,它可以有多种外在表现形式?strong style="font-weight: 800; ">我们?资源"具体呈现出来的Ş式,叫做它的"表现?QRepresentationQ?/strong>

比如Q文本可以用txt格式表现Q也可以用HTML格式、XML格式、JSON格式表现Q甚臛_以采用二q制格式Q图片可以用JPG格式表现Q也可以用PNG格式表现?/p>

URI只代表资源的实体Q不代表它的形式。严格地_(d)有些|址最后的".html"后缀名是不必要的Q因个后~名表C格式,属于"表现?范畴Q而URI应该只代?资源"的位|。它的具体表现Ş式,应该在HTTPh的头信息中用Accept和Content-Type字段指定Q这两个字段才是?表现?的描q?/p>

状态{化(State TransferQ?/strong>

讉K一个网站,׃表了(jin)客户端和服务器的一个互动过E。在q个q程中,势必涉及(qing)到数据和状态的变化?/p>

互联|通信协议HTTP协议Q是一个无状态协议。这意味着Q所有的状态都保存在服务器端。因此,如果客户端想要操作服务器Q必通过某种手段Q让服务器端发生"状态{?QState TransferQ。而这U{化是建立在表现层之上的,所以就?表现层状态{??/strong>

客户端用到的手段Q只能是HTTP协议。具体来_(d)是HTTP协议里面Q四个表C操作方式的动词QGET、POST、PUT、DELETE。它们分别对应四U基本操作:(x)GET用来获取资源QPOST用来新徏资源Q也可以用于更新资源Q,PUT用来更新资源QDELETE用来删除资源?/strong>

lD

l合上面的解释,我们ȝ一下什么是RESTful架构Q?/p>

  Q?Q每一个URI代表一U资源;

  Q?Q客L(fng)和服务器之间Q传递这U资源的某种表现层;

  Q?Q客L(fng)通过四个HTTP动词Q对服务器端资源q行操作Q实?表现层状态{??/p>

误区

RESTful架构有一些典型的设计误区?/p>

最常见的一U设计错误,是URI包含动词?/strong>因ؓ(f)"资源"表示一U实体,所以应该是名词QURI不应该有动词Q动词应该放在HTTP协议中?/p>

举例来说Q某个URI?posts/show/1Q其中show是动词,q个URIp计错?jin),正确的写法应该?posts/1Q然后用GETҎ(gu)表示show?/p>

如果某些动作是HTTP动词表示不了(jin)的,你就应该把动作做成一U资源。比如网上汇ƾ,从̎?向̎?汇款500元,错误的URI是:(x)

  POST /accounts/1/transfer/500/to/2

正确的写法是把动词transferҎ(gu)名词transactionQ资源不能是动词Q但是可以是一U服务:(x)

  POST /transaction HTTP/1.1
  Host: 127.0.0.1
  
  from=1&to=2&amount=500.00

另一个设计误区,是在URI中加入版本号Q?/p>

  http://www.example.com/app/1.0/foo

  http://www.example.com/app/1.1/foo

  http://www.example.com/app/2.0/foo

因ؓ(f)不同的版本,可以理解成同一U资源的不同表现形式Q所以应该采用同一个URI。版本号可以在HTTPh头信息的Accept字段中进行区分(参见Versioning REST ServicesQ:(x)

  Accept: vnd.example-com.foo+json; version=1.0

  Accept: vnd.example-com.foo+json; version=1.1

  Accept: vnd.example-com.foo+json; version=2.0


原帖Qhttp://www.ruanyifeng.com/blog/2011/09/restful.html

lincode 2011-10-27 18:02 发表评论
]]>
[android] PhoneGap ?android 下的实现原理http://www.aygfsteel.com/lincode/archive/2011/09/20/359014.htmllincodelincodeTue, 20 Sep 2011 02:20:00 GMThttp://www.aygfsteel.com/lincode/archive/2011/09/20/359014.htmlhttp://www.aygfsteel.com/lincode/comments/359014.htmlhttp://www.aygfsteel.com/lincode/archive/2011/09/20/359014.html#Feedback1http://www.aygfsteel.com/lincode/comments/commentRss/359014.htmlhttp://www.aygfsteel.com/lincode/services/trackbacks/359014.htmlPhoneGap 是一个移动开发框架。通过 PhoneGapQ开发者可以?JavaScript 调用手机的原生功能,例如Q获取经U度Q让手机振动{?br />主页 http://www.phonegap.com/ ?br />源码 https://github.com/phonegap/phonegap-android ?br />
PhoneGap 在早期,应该是?WebView ?addJavaScriptInterface Ҏ(gu)Q来?JS 提供调用原生功能可能。addJavaScriptInterface Q可以将一?Java 对象l定C?JS 对象。是的,JS对象可以调用 JavaҎ(gu)。但?PhoneGap 1.0.0 q个版本中,PhoneGap 改变?sh)(jin)方法?br />
以振动功能ؓ(f)例,我们可以看一下程序调用的程Q?br />
1 ?JS 中,启动命o(h)

main.js / navigator.notification.vibrate(0);

notification.js / Notification.vibrate.vibrate 中执行了(jin) PhoneGap.exec(null, null, "Notification", "vibrate", [mills]);

phonegap.js / PhoneGap.exc 中执行了(jin) var r = prompt(PhoneGap.stringify(args), "gap:"+PhoneGap.stringify([service, action, callbackId, true]));

q时QW(xu)ebView ׃(x)企图弹出一个窗口。这时?android 提供?nbsp;WebChromeClient ?nbsp;API 可以截?WebView 的这个动??br />
2 JAVA 中,处理命o(h)
WebView ?WebChromClient 实现?jin)下面这个函敎ͼ?x)

public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result)

?onJsPrompt 中执行了(jin) String r = pluginManager.exec(service, action, callbackId, message, async);

PlugManager ?x)根据收到参敎ͼ命令分发给特定?Plugin。这个例子中Q接收的 plugin 是:(x)Notification?br />落实?Notification ?exec 函数Q会(x)执行q一行:(x) this.vibrate(args.getLong(0));

振动的实Cؓ(f)Q?br />

 

 public void vibrate(long time){
        
// Start the vibration, 0 defaults to half a second.
        if (time == 0) {
time 
= 500;
}
        Vibrator vibrator 
= (Vibrator) this.ctx.getSystemService(Context.VIBRATOR_SERVICE);
        vibrator.vibrate(time);
}

 


3 Java 处理完后的数据,需要给 JS 一个反馈:(x)
q里 PhoneGap 使用?jin)一个在客户端本地实现的 XHRServerQ具体到代码中就是一个JAVA c?CallbackServer?br />
分两个部分介l其行ؓ(f)Q?br />本地 XHRServerQ?br />思想是,后台每执行完一个命令,都会(x)结果存?CallbackServer 中的一个链表中Q具体ؓ(f)CallbackServr?private LinkedList<String> javascript;
q个l果其实是一D字W串表示?JS 函数调用。例如检网l调用的l果为:(x)PhoneGap.callbackSuccess('Network Status1',{status:1,message:"wifi",keepCallback:true});
 XHRServer 的行为很单,只要有请求来Q就把链表中的最先进来的提出来,q回l客L(fng)。没有请求来Q则 10U钟q回一个空的回复,以维持XHRServer?div>
Webview 作ؓ(f)客户端:(x)
?WebView 中,?x)有一个轮询机Ӟq可以参?PhoneGap.JSCallack ?nbsp;PhoneGap.JSCallbackPolling 两个函数来访?XHRServer。XHRServerQ返回的l果是 WebView 需要调用的 JS 函数??JS 中,eval() 函数Q将q回的结果变?sh)Z个可以执行的对象Q在 Webview 中执行,可以认ؓ(f)q即是回调函?Callback。这也是Z?PhoneGap Z命名 XHRServer ?CallbackServer 的原因?br />


lincode 2011-09-20 10:20 发表评论
]]>
[android] dipQdpQpxQptQsp 的区?/title><link>http://www.aygfsteel.com/lincode/archive/2011/09/16/358813.html</link><dc:creator>lincode</dc:creator><author>lincode</author><pubDate>Fri, 16 Sep 2011 09:58:00 GMT</pubDate><guid>http://www.aygfsteel.com/lincode/archive/2011/09/16/358813.html</guid><wfw:comment>http://www.aygfsteel.com/lincode/comments/358813.html</wfw:comment><comments>http://www.aygfsteel.com/lincode/archive/2011/09/16/358813.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/lincode/comments/commentRss/358813.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/lincode/services/trackbacks/358813.html</trackback:ping><description><![CDATA[<span id="wmqeeuq" class="Apple-style-span" style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; background-color: #ffffff; ">dip: device independent pixels(讑֤独立像素)。不同设备有不同的显C效果,q个和设备硬件有养I一般我们ؓ(f)?jin)支持WVGA、HVGA和QVGA 推荐使用q个Q不依赖像素?nbsp;<br /><br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; background-color: #ffffff; ">dp:Q与密度无关的像素)(j)一U基于屏q密度的抽象单位。在每英?60点的昄器上Q?dp = 1px?nbsp;<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; background-color: #ffffff; "><br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; background-color: #ffffff; ">px: pixels(像素). 不同讑֤昄效果相同Q一般我们HVGA代表320x480像素Q这个用的比较多?nbsp;<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; background-color: #ffffff; "><br />pt: point(?Q是一个标准的长度单位Q?ptQ?/72英寸Q用于印刷业Q非常简单易用; <br /><br />sp: scaled pixels(攑֤像素). 主要用于字体昄best for textsize?nbsp;</span><img src ="http://www.aygfsteel.com/lincode/aggbug/358813.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/lincode/" target="_blank">lincode</a> 2011-09-16 17:58 <a href="http://www.aygfsteel.com/lincode/archive/2011/09/16/358813.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[android] Serializable ?Parcelable 区别http://www.aygfsteel.com/lincode/archive/2011/09/16/358805.htmllincodelincodeFri, 16 Sep 2011 08:16:00 GMThttp://www.aygfsteel.com/lincode/archive/2011/09/16/358805.htmlhttp://www.aygfsteel.com/lincode/comments/358805.htmlhttp://www.aygfsteel.com/lincode/archive/2011/09/16/358805.html#Feedback0http://www.aygfsteel.com/lincode/comments/commentRss/358805.htmlhttp://www.aygfsteel.com/lincode/services/trackbacks/358805.htmlandroid ?span class="Apple-style-span" style="background-color: #ffffff; ">自定义的对象序列化的问题有两个选择一个是ParcelableQ另外一个是Serializable?/span>

一 序列化原因:(x)

1.怹性保存对象,保存对象的字节序列到本地文g中;
2.通过序列化对象在|络中传递对象;
3.通过序列化在q程间传递对象?nbsp;

?至于选取哪种可参考下面的原则Q?/span>

1.在用内存的时候,Parcelable cLSerializable性能高,所以推荐用ParcelablecR?br style="line-height: 25px; " />2.Serializable在序列化的时候会(x)产生大量的(f)时变量,从而引起频J的GC?br style="line-height: 25px; " />3.Parcelable不能使用在要数据存储在盘?sh)的情况Q因为Parcelable不能很好的保证数据的持箋(hu)性在外界有变化的情况下。尽Serializable效率低点Q?也不提倡用Q但在这U情况下Q还是徏议你用Serializable ?/span>


实现Q?/strong>
1 Serializable 的实玎ͼ只需要? implements Serializable 卛_。这只是l对象打?jin)一个标讎ͼpȝ?x)自动将其序列化?br />
2 Parcelabel 的实玎ͼ需要在cMd一个静(rn)态成员变?CREATORQ这个变量需要?Parcelable.Creator 接口?br />
public class MyParcelable implements Parcelable {
     
private int mData;

     
public int describeContents() {
         
return 0;
     }

     
public void writeToParcel(Parcel out, int flags) {
         out.writeInt(mData);
     }

     
public static final Parcelable.Creator<MyParcelable> CREATOR
             
= new Parcelable.Creator<MyParcelable>() {
         
public MyParcelable createFromParcel(Parcel in) {
             
return new MyParcelable(in);
         }

         
public MyParcelable[] newArray(int size) {
             
return new MyParcelable[size];
         }
     };
     
     
private MyParcelable(Parcel in) {
         mData 
= in.readInt();
     }
 }

 

lincode 2011-09-16 16:16 发表评论
]]>
[android] Activity 的生命周?以及(qing) 横屏竖屏切换?Activity 的状态变?/title><link>http://www.aygfsteel.com/lincode/archive/2011/09/16/358768.html</link><dc:creator>lincode</dc:creator><author>lincode</author><pubDate>Fri, 16 Sep 2011 02:32:00 GMT</pubDate><guid>http://www.aygfsteel.com/lincode/archive/2011/09/16/358768.html</guid><wfw:comment>http://www.aygfsteel.com/lincode/comments/358768.html</wfw:comment><comments>http://www.aygfsteel.com/lincode/archive/2011/09/16/358768.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/lincode/comments/commentRss/358768.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/lincode/services/trackbacks/358768.html</trackback:ping><description><![CDATA[<strong>生命周期</strong><br /><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; background-color: #ffffff; ">Android pȝ在Activity 生命周期中加入一些钩子,我们可以在这些系l预留的钩子中做一些事情?br />例D?7 个常用的钩子Q?br style="line-height: 22px; " /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; background-color: #ffffff; ">protected void onCreate(Bundle savedInstanceState)<br style="line-height: 22px; " /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; background-color: #ffffff; ">protected void onStart()<br style="line-height: 22px; " /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; background-color: #ffffff; ">protected void onResume()<br style="line-height: 22px; " /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; background-color: #ffffff; ">protected void onPause()<br style="line-height: 22px; " /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; background-color: #ffffff; ">protected void onStop()<br style="line-height: 22px; " /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; background-color: #ffffff; ">protected void onRestart()<br style="line-height: 22px; " /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; background-color: #ffffff; ">protected void onDestroy()<br /><br />要说明:(x)<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; background-color: #ffffff; ">onCreate(Bundle savedInstanceState)Q创建activity时调用。设|在该方法中Q还?sh)Bundle中可以提出用于创 Activity 所需的信息?br style="line-height: 22px; " /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; background-color: #ffffff; ">onStart()Qactivity变(sh)ؓ(f)在屏q上对用户可见时Q即获得焦点Ӟ?x)调用?br style="line-height: 22px; " /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; background-color: #ffffff; ">onResume()Qactivity开始与用户交互时调用(无论是启动还是重新启动一个活动,该方法L被调用的Q?br style="line-height: 22px; " /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; background-color: #ffffff; ">onPause()Qactivity被暂停或收回cpu和其他资源时调用Q该Ҏ(gu)用于保存?gu)zd状态的。?br style="line-height: 22px; " /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; background-color: #ffffff; ">onStop()Qactivity被停止ƈ转ؓ(f)不可见阶D及(qing)后箋(hu)的生命周期事件时Q即失去焦点时调用?br style="line-height: 22px; " /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; background-color: #ffffff; ">onRestart()Q重新启动activity时调用。该zd仍在栈中Q而不是启动新的活动?br style="line-height: 22px; " /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 22px; background-color: #ffffff; ">onDestroy()Qactivity被完全从pȝ内存?sh)移除时调用Q该Ҏ(gu)被调用可能是因ؓ(f)有h直接调用 finish()Ҏ(gu) 或者系l决定停止该zd以释放资源?br /></span><br /><strong>横竖屏切?/strong><br /><br />1 切换到横?br /><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onSaveInstanceState<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onPause<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onStop<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onDestroy<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onCreate<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onStart<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onRestoreInstanceState<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onResume<br /><br /></span>2 切换到竖屏,销毁了(jin)两次<br /><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onSaveInstanceState<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onPause<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onStop<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onDestroy</span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onCreate<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onStart<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onRestoreInstanceState<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onResume<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onSaveInstanceState<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onPause<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onStop<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onDestroy<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onCreate<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onStart<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onRestoreInstanceState<br /></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #ffffff; ">onResume</span><br /><br /><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #f5fafe; "><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; ">3 修改AndroidManifest.xmlQ把该Activityd android:configChanges="orientation"Q切横屏Q只销毁一ơ?/p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; ">onSaveInstanceState<br />onPause<br />onStop<br />onDestroy<br />onCreate<br />onStart<br />onRestoreInstanceState<br />onResume</p></span>4 <span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #f5fafe; ">再切回竖屏,发现不会(x)再打印相同信息,但多打印?jin)一行onConfigChanged<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; ">onSaveInstanceState<br />onPause<br />onStop<br />onDestroy<br />onCreate<br />onStart<br />onRestoreInstanceState<br />onResume<br />onConfigurationChanged</p></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #f5fafe; "><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; ">5 更改 android:configChanges="orientation" Ҏ(gu) android:configChanges="orientation|keyboardHidden"Q切横屏Q就只打印onConfigChanged</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; ">onConfigurationChanged</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; ">6 切回竖屏</p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; ">onConfigurationChanged<br />onConfigurationChanged</p></span><span id="wmqeeuq" class="Apple-style-span" style="font-family: Arial, ?hu)? line-height: 26px; background-color: #f5fafe; "><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; ">ȝQ?/p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; ">1、不讄Activity的android:configChangesӞ切屏?x)重新调用各个生命周期,切横屏时会(x)执行一ơ,切竖屏时?x)执行两?/p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; ">2、设|Activity的android:configChanges="orientation"Ӟ切屏q是?x)重新调用各个生命周期,切横、竖屏时只会(x)执行一?/p><p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; ">3、设|Activity的android:configChanges="orientation|keyboardHidden"Ӟ切屏不会(x)重新调用各个生命周期Q只?x)执行onConfigurationChangedҎ(gu)</p></span><br /><br /><br /><br /><img src ="http://www.aygfsteel.com/lincode/aggbug/358768.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/lincode/" target="_blank">lincode</a> 2011-09-16 10:32 <a href="http://www.aygfsteel.com/lincode/archive/2011/09/16/358768.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Դ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ĭ</a>| <a href="http://" target="_blank">պ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ǡ</a>| <a href="http://" target="_blank">ո</a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ԫ</a>| <a href="http://" target="_blank">е</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ԫ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ԫ</a>| <a href="http://" target="_blank">ͼƬ</a>| <a href="http://" target="_blank">׶</a>| <a href="http://" target="_blank">ͨ</a>| <a href="http://" target="_blank">ϲ</a>| <a href="http://" target="_blank">IJ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ͬ</a>| <a href="http://" target="_blank">찲</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">˹</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ֽ</a>| <a href="http://" target="_blank">ֵ</a>| <a href="http://" target="_blank"></a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>