android平台手电筒开发源代码
来源:互联网 发布:2016年破获的网络诈骗 编辑:程序博客网 时间:2024/05/16 11:30
android平台手电筒开发源代码,AndroidManifest.xml文件的入口是startapp,这个文件没上传上来,大家可以自己写。
标签: Android
代码片段(3)
1. [代码]android
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* name : 手电筒主界面
* author : ycgpp@126.com
* date : 2012-12-21 15:50:17
*/
package
com.android.app;
import
android.app.Activity;
import
android.hardware.Camera;
import
android.hardware.Camera.Parameters;
import
android.os.Bundle;
import
android.view.View;
import
android.widget.TextView;
import
android.widget.Toast;
public
class
Main
extends
Activity {
private
boolean
isopent =
false
;
private
Camera camera;
@Override
protected
void
onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super
.onCreate(savedInstanceState);
View view = View.inflate(
this
, R.layout.main,
null
);
setContentView(view);
TextView img_but = (TextView) findViewById(R.id.main_img);
img_but.setOnClickListener(
new
View.OnClickListener() {
@Override
public
void
onClick(View v) {
// TODO Auto-generated method stub
if
(!isopent) {
Toast.makeText(getApplicationContext(),
"您已经打开了手电筒"
,
0
)
.show();
camera = Camera.open();
Parameters params = camera.getParameters();
params.setFlashMode(Parameters.FLASH_MODE_TORCH);
camera.setParameters(params);
camera.startPreview();
// 开始亮灯
isopent =
true
;
}
else
{
Toast.makeText(getApplicationContext(),
"关闭了手电筒"
,
Toast.LENGTH_SHORT).show();
camera.stopPreview();
// 关掉亮灯
camera.release();
// 关掉照相机
isopent =
false
;
}
}
});
}
}
2. [代码]布局文件代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?xml version=
"1.0"
encoding=
"utf-8"
?>
<LinearLayout xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<TextView
android:id=
"@+id/main_img"
android:layout_width=
"fill_parent"
android:layout_height=
"fill_parent"
android:background=
"@drawable/main_body"
>
</TextView>
</LinearLayout>
3. [代码]AndroidManifest.xml文件 跳至 [1] [2] [3] [全屏预览]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<manifest xmlns:android=
"http://schemas.android.com/apk/res/android"
package
=
"com.android.app"
android:versionCode=
"1"
android:versionName=
"1.0"
>
<uses-sdk
android:minSdkVersion=
"8"
android:targetSdkVersion=
"15"
/>
<application
android:icon=
"@drawable/ic_launcher"
android:label=
"@string/app_name"
android:theme=
"@style/AppTheme"
>
<activity android:name=
".AppStart"
>
<intent-filter>
<action android:name=
"android.intent.action.MAIN"
/>
<category android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<activity android:name=
".Main"
>
</activity>
</application>
<!-- 摄像头、手电筒 -->
<uses-permission android:name=
"android.permission.CAMERA"
/>
<uses-permission android:name=
"android.permission.FLASHLIGHT"
/>
<uses-feature android:name=
"android.hardware.camera"
/>
<uses-feature android:name=
"android.hardware.camera.autofocus"
/>
<uses-feature android:name=
"android.hardware.camera.flash"
/>
</manifest>
0 0
- android平台手电筒开发源代码
- android平台手电筒开发源代码
- android平台手电筒开发源代码
- 基于Android平台开发的手电筒Light
- Android 手电筒源代码
- [安卓开发] Android 自己做双向手电筒 源代码
- android 手电筒开发
- Android手电筒开发
- Android手电筒开发
- Android 开发 打开手电筒
- Android开发----------- 手电筒改进版本
- Android开发 手电筒封装类
- 手电筒开发
- android手电筒
- Android手电筒
- Android手电筒
- android 手电筒
- android手电筒
- Hibernate加载配置文件的两种方法
- UML用例图总结
- Remove Element -LeetCode
- 使用开源库zlib压缩和解压文件
- 可记住用户名密码的登陆界面(基于对SharedPreferences的应用)
- android平台手电筒开发源代码
- 二叉树
- 重建二叉树
- Android设置透明、半透明等效果
- 【我们都爱Paul Hegarty】斯坦福IOS8公开课个人笔记30 ScrollView Demo实战
- week14_2.cpp
- ECMA-262,第 5 版。最新 JavaScript 规范 了解 ECMAScript 规范的历史,查看它的众多重要新特性和新概念。
- [转]IOS如何访问通讯录
- NSString常用方法