WEB开发网
开发学院手机开发Android 开发 Android很有用的代码片段 阅读

Android很有用的代码片段

 2010-09-21 02:12:00 来源:WEB开发网   
核心提示:shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(fd));shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject);shareIntent.putExtra(Intent.EXTRA_TEXT, body);回目

shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(fd));

shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject);

shareIntent.putExtra(Intent.EXTRA_TEXT, body);

回目录7:注册一个BroadcastReceiver

registerReceiver(mMasterResetReciever, new IntentFilter(”OMS.action.MASTERRESET”));

private BroadcastReceiver mMasterResetReciever = new BroadcastReceiver() {

public void onReceive(Context context, Intent intent){

String action = intent.getAction();

if(”oms.action.MASTERRESET”.equals(action)){

RecoverDefaultConfig();

}

}

};

回目录8:定义ContentObserver,监听某个数据表

private ContentObserver mDownloadsObserver = new DownloadsChangeObserver(Downloads.CONTENT_URI);

private class DownloadsChangeObserver extends ContentObserver {

public DownloadsChangeObserver(Uri uri) {

super(new Handler());

}

@Override

public void onChange(boolean selfChange) {}

}

回目录9:获得 手机UA

public String getUserAgent()

{

String user_agent = ProductProperties.get(ProductProperties.USER_AGENT_KEY, null);

return user_agent;

}

回目录10:清空手机上Cookie

CookieSyncManager.createInstance(getApplicationContext());

CookieManager.getInstance().removeAllCookie();

回目录11:建立GPRS连接

//Dial the GPRS link.

private boolean openDataConnection() {

// Set up data connection.

DataConnection conn = DataConnection.getInstance();

if (connectMode == 0) {

ret = conn.openConnection(mContext, “cmwap”, “cmwap”, “cmwap”);

} else {

ret = conn.openConnection(mContext, “cmnet”, “”, “”);

}

}

回目录12:PreferenceActivity 用法

Tags:Android 有用 代码

编辑录入:coldstar [复制链接] [打 印]
赞助商链接