本文个人在广东逛街的时候突然想到的...之前就有想写几篇关于打开电话的博客,所以回家到之后就奋笔疾书的写出来发布了
main.xml如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:gravity="center_horizontal" > <Button android:id="@+id/callTelephoneButton" android:layout_width="150dip" android:layout_height="40dip" android:gravity="center" android:text="@string/callTelephone" android:layout_marginTop="50dip" android:textSize="20sp" /> <Button android:id="@+id/browsephotosButton" android:layout_width="150dip" android:layout_height="40dip" android:gravity="center" android:text="@string/browsephotos" android:layout_marginTop="50dip" android:textSize="20sp" /> <Button android:id="@+id/openBrowserButton" android:layout_width="150dip" android:layout_height="40dip" android:gravity="center" android:text="@string/openBrowser" android:layout_marginTop="50dip" android:textSize="20sp" /> <Button android:id="@+id/openCameraButton" android:layout_width="150dip" android:layout_height="40dip" android:gravity="center" android:text="@string/openCamera" android:layout_marginTop="50dip" android:textSize="20sp" /> </LinearLayout>
MainActivity如下:
盈盈月光,我掬一杯最清的;落落余辉,我拥一缕最暖的;灼灼红叶,我拾一片最热的;萋萋芳草,我摘一束最灿的;漫漫人生,我要采撷世间最重的———毅力。
package cn.com.bravesoft.testintent; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.app.Activity; import android.content.Intent; /** * *官方资料: *1 权限设置 * http://developer.android.com/reference/android/Manifest.permission.html *2 系统Intent * http://developer.android.com/reference/android/content/Intent.html#ACTION_CALL */ public class MainActivity extends Activity { private Button mTelephoneButton; private Button mPhotosButton; private Button mBrowserButton; private Button mCameraButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); init(); } private void init(){ mTelephoneButton=(Button) findViewById(R.id.callTelephoneButton); mTelephoneButton.setOnClickListener(new ButtonOnClickListenerImpl()); mPhotosButton=(Button) findViewById(R.id.browsephotosButton); mPhotosButton.setOnClickListener(new ButtonOnClickListenerImpl()); mBrowserButton=(Button) findViewById(R.id.openBrowserButton); mBrowserButton.setOnClickListener(new ButtonOnClickListenerImpl()); mCameraButton=(Button) findViewById(R.id.openCameraButton); mCameraButton.setOnClickListener(new ButtonOnClickListenerImpl()); } private class ButtonOnClickListenerImpl implements OnClickListener{ @Override public void onClick(View v) { switch (v.getId()) { case R.id.callTelephoneButton: //拨打电话 Intent telephoneIntent=new Intent(); telephoneIntent.setAction("android.intent.action.CALL"); telephoneIntent.setData(Uri.parse("tel:"+"150028068")); startActivity(telephoneIntent); break; case R.id.browsephotosButton: //查看图片 Intent galleryIntent=new Intent(); galleryIntent.setAction(Intent.ACTION_GET_CONTENT); galleryIntent.setType("image/*"); startActivity(galleryIntent); break; case R.id.openBrowserButton: //打开浏览器 Intent browserIntent=new Intent(); browserIntent.setAction(Intent.ACTION_VIEW); browserIntent.setData(Uri.parse("http://www.ifeng.com")); startActivity(browserIntent); break; case R.id.openCameraButton: //打开照相机 Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivity(cameraIntent); break; default: break; } } } }
文章结束给大家分享下程序员的一些笑话语录:
话剧:程序员过沟
本剧内容纯属虚构,如有雷同……HEHE……俺也没办法了。
话说某市街道改建,某某软件公司门口横七竖八挖了几条大沟。一群程序员(SDK程序员赵某,VB程序员钱某,VC程序员孙某,DELPHI程序员李某)下班从公司里出来,看到门前的几条沟,于是各显神通……门前第一条沟也就半米来宽,SDK程序员赵某二话没说,轻轻一跃跳了过去,看到其它人纷纷把随身携带的公文包(类库)横在沟上踩着过沟,不屑地说,这么小一条沟,犯得着小题大做用那个吗?看我多么轻松多么洒脱多么……多么……(众人皆怒目横视之……)
接着第二条沟有点宽度。SDK程序员赵某还是还是一马当先,飞跃而起……不好,还差一点才到……幸好凭着多年的(跳远?编程?)经验,单手抓住沟沿,颤巍巍地爬了上来,嘴里还念念有词“高手就是高手啊,虽然差一点就……不过毕竟……HEHE……跳远是过沟的基础嘛,有基础(SDK)就有一切的说……”(众人作瞠目结舌状……)看到别人跳过去了,可自己又跳不了那么远,只好再想办法了……VB程序员钱某,DELPHI程序员李某打开手提,连上手机,开始上网找可供过沟的控件……VC程序员孙某却不慌不忙,打开公文包,把几块衬板拆了下来,然后三下五除二拼成一个简易木桥……“虽然这几个板子(类)做得不怎么样,不过先把这个项目应付过去,有时间我自己做一个好了……”于是踩着板子过了沟。
这时钱某和李某也分别找到了合适的东东。钱某找到的是“钢丝绳.ocx”,安装简单,使用方便,拉出一头,对孙某说“大虾,顺手拉兄弟一把……”,于是把绳子系在沟两边的绿化树木上,踩着钢丝就过了沟。刚刚站稳就四方作揖,“小生这里有礼了”。这时一戴着黄袖圈的老太太跳了出来,抓住钱某,“破坏绿化树木,罚款XXXX元,交钱,交钱,交钱!”(老人家作双枪老太婆怒视伪军状
……钱某被逼无奈,只好边掏钱,边对着后台叫道“导演,我这可是因公牺牲,不给个烈士称号也得报销”,后台一个臭鸡蛋飞出,“叫什么叫,我这个月的粮饷还不知哪里去领呢,都什么时代了,你不下岗都不错了……”)
李某看着刚刚好不容易从台湾拖回来的“铝条.ZIP”