位置: 编程技术 - 正文
推荐整理分享14个简单有用的android源码,适合初学者(简单又实用的),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:简单又实用的单词,有没有超简单的,简单又实用的单词,简单实用的app,有没有超简单的,简单又好用,简单又好用,简单又实用的,内容如对您有帮助,希望把文章链接给更多的朋友!
1:查看是否有存储卡插入
2:让某个Activity透明
在OnCreate 中不设Layout,然后this.setTheme(R.style.Theme_Transparent);
3:获取屏幕宽高
4:发送短信5:发送彩信
[java] view plaincopyprint?StringBuilder sb = new StringBuilder(); sb.append(” sb.append(fd.getAbsoluteFile()); Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(”mmsto”, number, null)); // Below extra datas are all optional. intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_SUBJECT, subject); intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY, body); intent.putExtra(Messaging.KEY_ACTION_SENDTO_CONTENT_URI, sb.toString()); intent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE, composeMode); intent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT, exitOnSent); startActivity(intent);7:发送Mail
[java] view plaincopyprint?mime = “img/jpg”; shareIntent.setDataAndType(Uri.fromFile(fd), mime); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(fd)); shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject); shareIntent.putExtra(Intent.EXTRA_TEXT, body);8:注册一个 BroadcastReceiver
[java] view plaincopyprint?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(); } } };9:定义ContentObserver,监听某个数据表
[java] view plaincopyprint?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) {} }:获得 手机UA
[java] view plaincopyprint?public String getUserAgent() { String user_agent = ProductProperties.get(ProductProperties.USER_AGENT_KEY, null); return user_agent; }:清空手机上Cookie
[java] view plaincopyprint?CookieSyncManager.createInstance(getApplicationContext()); CookieManager.getInstance().removeAllCookie();:建立GPRS 连接
[java] view plaincopyprint?private boolean openDataConnection() { DataConnection conn = DataConnection.getInstance(); if (connectMode == 0) { ret = conn.openConnection(mContext, “cmwap”, “cmwap”, “cmwap”); } else { ret = conn.openConnection(mContext, “cmnet”, “”, “”); } }:PreferenceActivity 用法
[java] view plaincopyprint?public class Setting extends PreferenceActivity{ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); } }Setting.xml:
[html] view plaincopyprint?android:key=”seting2″ android:title=”@string/seting2″ android:summary=”@string/seting2″/> android:key=”seting1″ android:title=”@string/seting1″ android:summaryOff=”@string/seting1summaryOff” android:summaryOn=”@stringseting1summaryOff”/>:通过 HttpClient从指定server获取数据
[java] view plaincopyprint? DefaultHttpClient httpClient = new DefaultHttpClient(); HttpGet method = new HttpGet(“ HttpResponse resp; Reader reader = null; try { // AllClientPNames.TIMEOUT HttpParams params = new BasicHttpParams(); params.setIntParameter(AllClientPNames.CONNECTION_TIMEOUT, ); httpClient.setParams(params); resp = httpClient.execute(method); int status = resp.getStatusLine().getStatusCode(); if (status != HttpStatus.SC_OK) return false; // HttpStatus.SC_OK; return true; } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (reader != null) try { reader.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }【mclin】手把手叫你在Eclipse里添加Android开发功能(附:完整离线版Android_SDK和Android_ADT下载) 还在使用旧版本的Android_SDK吗?那你就Out了。你还在为更新SDK得到网址被拒绝而烦恼吗?那么现在就是你幸福的时刻了,截止年5月日完整版SDK现在
Eclipse出现java heap space解决方法 javaheapspace解决方法在开发androidapplications时runapk时有时会出现弹出javaheapspace的提示,然后eclipse直接就挂了。在网上搜索了各种方法依然没有解决这个问
Android中与ViewRoot相关的一些概念 1、View和ViewRootViewRoot从名称上来理解乎是View树的根,这很容易让人产生误解。因为ViewRoot并不属于View树的一份子。从源码实现上来看,ViewRoot和View对象
标签: 简单又实用的
本文链接地址:https://www.jiuchutong.com/biancheng/382262.html 转载请保留说明!下一篇:【mclin】手把手叫你在Eclipse里添加Android开发功能(附:完整离线版Android_SDK和Android_ADT下载)
友情链接: 武汉网站建设