android之旅1:background && hello world
来源:互联网 发布:大连理工大学网络设置 编辑:程序博客网 时间:2024/05/16 19:16
android之旅1:background && hello world
dex的作用是减少文件,把JVM下的多个CLASS文件压成一个提高效率;寄存器架构,提高手机端效率。
OnCreate(){ setContentView(R.layout.main_activity);}
manifest.xml
<manifest package="com.xx.xxx" --- app唯一标识> <uses-permission android:name="android.permission.CALL_PHONE"></manifest><application> <activity> ....... </activity></application>
模拟部署过程
重要文件夹
- data/app 安装的软件区
- data/data 所有程序对应的自己的数据保存区
电话拨号器
- 布局管理器
<RelativeLayout android:paddingLeft="10hp" android:paddingTop="20hp"></RelativeLayout>
- 代码
OnCreate(){ setContentView(R.layout.activity_main); Button bt = findViewById(R.id.bt_call); bt.setOnClickListener(new MyListener());}class MyListener implements OnClickListener{ public void onClick(View v){ EditText et = (EditText)findViewById(R.id.et); String phone = et.getText().toString(); /* 1.创建意图实例 2.设置意图的动作(Intent.ACTION_CALL) 3.设置意图的数据(Uri.parse(xxxx)) 4.startActivity 开启动作,实际是启动一个Activity,Intent数据传递 */ Intent intent = new Intent(); intent.setAction(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:"+phone)); startActivity(intent); }}
短信发送器
- 布局与manifest
<EditText android:hint="请输入短信内容" android:line="5" ---- 显示5行 android:gravity="top" ---- 内容靠上对齐 android:inputType="phone" ---- 数字和*#/><uses-permission android:name="android.permission.SEND_SMS"/>
- 代码
public void OnCreate(){ setContentView(R.layout.activity_main);}public void Send(View v){ EditText et_phone = (EditText)findViewById(R.id.et_phone); .... // 获取界面上的num和content .... // 短信实例单例,这个和电话拨号器不同是直接有API调用,不用启动activity SmsManager sm = SmsManager.getDefault(); // 拆分长短信 ArrayList<String> smss = sm.divideMessage(content); for(String ss:smss) { //后面两个null是广播,发送成功与否和对方接受成功与否,后面看 sm.sendTextMessage(phone, null, ss, null, null); }}
事件写法
- 如果事件大家都有,那么一般通过implements实现,区分见下面的代码
- 如果定义了android:onClick=”ABCd”,那么context中必须要定义一个如下方法
public void ABCd(View v){ int id = v.getId(); switch(id){ case ... ....; }}
0 0
- android之旅1:background && hello world
- android之Hello World!
- Android之Hello World
- android之hello world
- android(hello world)-1
- Hello world 之Android版
- 2.Android之Hello World
- android ndk之hello world
- android初学之Hello World
- android NDK 之Hello world
- Android-NDK-之Hello-World
- ios开发之旅(1) hello world
- Android 开发之旅:又见Hello World!
- Android 开发之旅:又见Hello World!
- Android开发之“hello World”的实现
- Android NDK开发之Hello world篇
- Qt for Android之Hello World
- android开发hello world之诚信版
- SimpleDateFormat与Calendar的24小时制与12小时制
- 修改CEdit的字体和颜色
- 项目开发笔记-2015.12.21-swift
- 代码之谜(三)- 运算符
- 代码之谜(四)- 浮点数(从惊讶到思考)
- android之旅1:background && hello world
- strdup()
- android 4.0 Menu的一些问题(学习笔记)
- 代码之谜(五)- 浮点数(谁偷了你的精度?)
- 不要因为别人伤害了你而去伤害别人
- hdu1025 Constructing Roads In JGShining's Kingdom
- git 的学习1
- python 我的学习历程 笔记和资源
- PAT乙级 查验身份证(15)