Allove Team 致力于移动应用的开发和服务(Android,J2ME,iphone,ophone)
2010年04月14日作者:izxm11分享人生

5 条评论

图片分享[2010-04-14]

hey,这是我今天分享的图片

2010年04月9日作者:izxm11分享人生

4 条评论

contacts2操作通讯录方法(一)

android2.x使用的通讯录数据库数据做了很多物理结构上的改动,经过翻墙查看官方文档之后受益良多,今天小议以下向通讯录插入联系人的方法
首先向RawContacts.CONTENT_URI执行一个空值插入,目的是获取系统返回的rawContactId 这时后面插入data表的依据,只有执行空值插入,才能使插入的联系人在通讯录里面可见,例如下面的代码

  1. ContentValues values = new ContentValues();       
  2.          Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values);
  3.          long rawContactId = ContentUris.parseId(rawContactUri);
  4.  
  5.          values.clear();
  6.          values.put(Data.RAW_CONTACT_ID, rawContactId);
  7.          values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
  8.          values.put(StructuredName.GIVEN_NAME, "Sullivan");
  9.          values.put(StructuredName.FAMILY_NAME, "Mike");
  10.          getContentResolver().insert(Data.CONTENT_URI, values);
  11.         
  12.          values.clear();
  13.          values.put(Data.RAW_CONTACT_ID, rawContactId);
  14.          values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
  15.          values.put(Phone.NUMBER, "13989297343");
  16.          values.put(Phone.TYPE,Phone.TYPE_HOME);
  17.          getContentResolver().insert(Data.CONTENT_URI, values);

按照这种传统的方法插入时每次只能插入元数据,就是某一种类型的一个值

  1. /**
  2.      * 传统插入方法 每次只能插入元数据,就是某一种类型的一个值
  3.      * 插入之后ContentValues需要被清空才能执行下一次插入数据操作
  4.      */
  5.     public void insert_traditional() {
  6.         ContentValues values = new ContentValues();
  7.         Uri rawContactUri = getContentResolver().insert(
  8.                 RawContacts.CONTENT_URI, values);
  9.         long rawContactId = ContentUris.parseId(rawContactUri);
  10.  
  11.         values.clear();
  12.         values.put(Data.RAW_CONTACT_ID, rawContactId);
  13.         values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
  14.         values.put(StructuredName.GIVEN_NAME, "Sullivan");
  15.         values.put(StructuredName.FAMILY_NAME, "Mike");
  16.         getContentResolver().insert(Data.CONTENT_URI, values);
  17.  
  18.         values.clear();
  19.         values.put(Data.RAW_CONTACT_ID, rawContactId);
  20.         values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
  21.         values.put(Phone.NUMBER, "13989297343");
  22.         values.put(Phone.TYPE, Phone.TYPE_HOME);
  23.         getContentResolver().insert(Data.CONTENT_URI, values);
  24.  
  25.     }

android官方同时介绍了另外一种新的批量插入的方法

下载: batch.java
  1. /**
  2.      * 批量插入通讯数据 相对传统方法 更适合通讯录的导入操作
  3.      * RawContacts.CONTENT_URI中 插入这个值
  4.      * 是为了触发contacts表的某个函数 可以初始化和插入数据 使之能够在通讯看到
  5.      * 插入StructuredName.DISPLAY_NAME 时格式为family name和given name中间 以空格隔开
  6.      * 就不需要再插入family_name和given_name
  7.      * 此方法相对传统方法来说在大量插入数据库比较节省时间
  8.      * 批量插入方法需要一个库来支持Lists对象
  9.      * 项目地址为http://code.google.com/p/google-collections/downloads/list
  10.      * 我使用的是google-collect-1.0.jar
  11.      */   
  12.     public void insert_batch() {
  13.         try {
  14.             ArrayList<contentprovideroperation> ops = Lists.newArrayList();
  15.             int rawContactInsertIndex = ops.size();
  16.             ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
  17.                     .withValue(RawContacts.DIRTY, "1")
  18.                     .build());
  19.  
  20.             ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
  21.                     .withValueBackReference(Data.RAW_CONTACT_ID,
  22.                             rawContactInsertIndex).withValue(Data.MIMETYPE,
  23.                             StructuredName.CONTENT_ITEM_TYPE).withValue(
  24.                             StructuredName.DISPLAY_NAME, "朱Sullivan")
  25.                     .build());
  26.            
  27.             ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
  28.                     .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex)
  29.                     .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
  30.                     .withValue(Phone.NUMBER, "13989297343")
  31.                     .withValue(Phone.TYPE, Phone.TYPE_HOME).build());
  32.             getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
  33.         } catch (RemoteException e) {
  34.             // TODO Auto-generated catch block
  35.             e.printStackTrace();
  36.         } catch (OperationApplicationException e) {
  37.             // TODO Auto-generated catch block
  38.             e.printStackTrace();
  39.         }
  40.     }
  41. </contentprovideroperation>

但是批处理方法有个不足之处就是,目前不支持MIMETYPE里面的NOTE,WEBSITE和NICKNAME的批量插入,这几个还需要用传统方法去操作

Android 程序获取、设置铃声和音量

通过程序获取android系统手机的铃声和音量。同样,设置铃声和音量的方法也很简单!

AudioManager mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
//通话音量

int max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_VOICE_CALL );
int current = mAudioManager.getStreamVolume( AudioManager.STREAM_VOICE_CALL );
Log.d(“VIOCE_CALL”, “max : ” + max + ” current : ” + current);
//系统音量

max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_SYSTEM );
current = mAudioManager.getStreamVolume( AudioManager.STREAM_SYSTEM );
Log.d(“SYSTEM”, “max : ” + max + ” current : ” + current);
//铃声音量

max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_RING );
current = mAudioManager.getStreamVolume( AudioManager.STREAM_RING );
Log.d(“RING”, “max : ” + max + ” current : ” + current);
//音乐音量

max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_MUSIC );
current = mAudioManager.getStreamVolume( AudioManager.STREAM_MUSIC );
Log.d(“MUSIC”, “max : ” + max + ” current : ” + current);
//提示声音音量

max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_ALARM );
current = mAudioManager.getStreamVolume( AudioManager.STREAM_ALARM );
Log.d(“ALARM”, “max : ” + max + ” current : ” + current);
设置音量的方法也很简单,AudioManager提供了方法:
public void setStreamVolume(int streamType, int index, int flags)
其中 streamType 有内置的常量,去文档里面就可以看到

2010年03月28日作者:秦 涛分享人生

1 Comments

iphone 实行http post  及多线程编程

#import "FirstUIAppDelegate.h"
@implementation FirstUIAppDelegate
@synthesize window;

- (void)applicationDidFinishLaunching:(UIApplication *)application {

// Override point for customization after application launch
//[self postdata];
[self setupThread];
[window makeKeyAndVisible];
}
-(void)setupThread{

[NSThread detachNewThreadSelector:@selector(postdata)toTarget:self withObject:nil];
}

- (void)dealloc {
[window release];
[super dealloc];
}

-(void)postdata{
NSLog(@"TEST");

NSURL *url;
NSMutableURLRequest *urlRequest;
NSMutableData *postBody = [NSMutableData data];

url = [NSURL URLWithString:@"http://allove.org"];
urlRequest = [[[NSMutableURLRequest alloc] initWithURL:url] autorelease];
[urlRequest setHTTPMethod:@"POST"];

NSString *udid = @"phong=15871485145&amp;psw=23";
[postBody appendData:[udid dataUsingEncoding: NSUTF8StringEncoding allowLossyConversion:YES]];

[urlRequest setHTTPBody:postBody];

NSData *returnData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:nil error:nil];
if(returnData)
{
NSString *result = [[NSString alloc] initWithData:returnData encoding:NSASCIIStringEncoding];
NSLog(@"result=======&gt;%@",result);
}
else
{
NSLog(@"Wrong Connetion!");
}
}
@end
2010年03月27日作者:秦 涛分享人生

5 条评论

http://wap.io

Windows Android Palm.Iphone Ophone

2010年03月14日作者:izxm11[开发及软件]Android

0 Comments

android 传感器

传感器类型分为:方向,加速度,光线。磁场,临近性,温度
准确性分为高,中,低,不可靠四种。不知道不可靠这种准确性是用来做什么的
还有采样率貌似是不确定的,依靠设备的本身的特性

作为与外界交互的一个窗口, 与传感器相关的接口,可以开发出很多有特色的,有趣的app出来。

2010年03月5日作者:秦 涛分享人生

5 条评论

blog

手机写blog,还是不方便,

2010年02月17日作者:孙建[分享世界]Anything

3 条评论

更新Feed地址

不知道为何Feedsky在抽风还是怎么地? 导致我最近访问总是出问题,再烧录一个,原来的FeedSky继续有用。这一个Feed用FeedBurner,应该比较保险了吧?

废话少说,小二,上地址!

来勒~~~: http://feeds.feedburner.com/Allove_Blog

同时亦可以在右边的边栏找到订阅按钮,走你!

2010年02月14日作者:秦 涛分享人生

2 条评论

万恶的春晚

好雷人哦,

返回顶部