android平台手电筒开发源代码,AndroidManifest.xml文件的入口是startapp,这个文件没上传上来,大家可以自己写。

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文件   悦德财富:https://www.yuedecaifu.com

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>

android平台手电筒开发源代码的更多相关文章

  1. Android平台的开发环境的发展演变

    因为之前学习java语言的时候安装过了eclipse,所以想在eclipse上搭建android平台,在参照知乎上大神们的意见,发现了AS强大的代码提示.实时预览和搜索匹配等出色功能,最后还是选择在A ...

  2. 作业1.3——Android平台的开发环境的发展演变

    一开始的打算是在eclipse的基础上搭建Android平台,在ADT.SDK上兜兜转转,听过一些前车之鉴后,还是选择了Android studio.因为之前安装过eclipse,就省去了JDK下载和 ...

  3. kotlin, 一种新的android平台一级开发语言

    最近看到一则科技新闻, 大致内容是google将kotlin语言作为android应用开发的一级语言, 与java并驾齐驱, 这是一个开发界的大事件大新闻, 连google的亲儿子go语言也没有这种待 ...

  4. Android平台Native开发与JNI机制详解

    源文链接: http://mysuperbaby.iteye.com/blog/915425 一个Native Method就是一个Java调用非Java代码的接口.一个Native Method是这 ...

  5. 调研Android平台的开发环境的发展演变

    ·  安卓是以linux为基础的开放源码操作系统.因为安卓的开源等原因,所以现在市场上会有大量的APP可供使用,且各个方面都功能强大. ·  也许是因为开源的原因,安卓过于碎片化.每个APP互相独立. ...

  6. cocos2dx3.2 android平台搭建开发环境纠错备忘录

    平台:win32 + android cocos2d版本号:3.2 搭建cocos2d-x android 常见问题: 问题1: Android platform not specified, sea ...

  7. 《React Native 精解与实战》书籍连载「Android 平台与 React Native 混合开发」

    此文是我的出版书籍<React Native 精解与实战>连载分享,此书由机械工业出版社出版,书中详解了 React Native 框架底层原理.React Native 组件布局.组件与 ...

  8. dp和px,那些不得不吐槽的故事——Android平台图

    http://blog.sina.com.cn/s/blog_6499f8f101014ipq.html 一个优秀的手机软件,不仅要有精巧的功能,流畅的速度,让人赏心悦目的UI也往往是用户选择的重要理 ...

  9. 基于Android 平台简易即时通讯的研究与设计[转]

    摘要:论文简单介绍Android 平台的特性,主要阐述了基于Android 平台简易即时通讯(IM)的作用和功能以及实现方法.(复杂的通讯如引入视频音频等可以考虑AnyChat SDK~)关键词:An ...

随机推荐

  1. QT对话框模式与非模式

    QT模态对话框及非模态对话框 非模态对话框(Modeless Dialog)的概念不是模态对话框就是在其没有被关闭之前,用户不能与同一个应用程序的其他窗口进行交互,直到该对话框关闭.对于在模态来显示对 ...

  2. PHP开发者常犯的MySQL错误

    PHP开发者常犯的MySQL错误   数据库是WEB大多数应用开发的基础.如果你是用PHP,那么大多数据库用的是MYSQL也是LAMP架构的重要部分. PHP看起来很简单,一个初学者也可以几个小时内就 ...

  3. linux 下 `dirname $0`

    [`],学名叫“倒引号”, 如果被“倒引号”括起来,  表示里面需要执行的是命令.比如 `dirname $0`,  就表示需要执行   dirname $0  这个命令 [“”] , 被双引号括起来 ...

  4. 垂直居中,水平居中html例子

    <!DOCTYPE html> <html lang="en"> <head> <title>Vertical Centering ...

  5. Jsp-Servlet 那一大堆事儿--1

    为毛全局变量声明时初始化在try内不能用? import javax.servlet.http .*; import java.io.*; import javax.servlet.*; import ...

  6. IoC 之 2.1 IoC基础(壹)

    2.1.1  IoC是什么 Ioc-Inversion of Control,即"控制反转",不是什么技术,而是一种设计思想.在Java开发中,Ioc意味着将你设计好的对象交给容器 ...

  7. ASP.NET页面与IIS底层交互和工作原理详解

    转载自:http://www.cnblogs.com/lidabo/archive/2012/03/13/2393200.html 第一回: 引言 我查阅过不少Asp.Net的书籍,发现大多数作者都是 ...

  8. img下出现几像素空白的问题

    先看一个例子和效果,应该就会明白我的问题了. <meta http-equiv="Content-Type" content="text/html; charset ...

  9. HTML5自学笔记[ 2 ]新增表单控件和表单属性

    新增<input>属性type="email",自动验证,若输入不为邮箱,则不能提交. 新增<input>属性type="tel",在移 ...

  10. HDUOJ-----(1162)Eddy's picture(最小生成树)

    Eddy's picture Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)To ...