日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android平台手电筒开发源代码

發(fā)布時間:2024/4/17 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android平台手电筒开发源代码 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
android平臺手電筒開發(fā)源代碼,AndroidManifest.xml文件的入口是startapp,這個文件沒上傳上來,大家可以自己寫。 1. [代碼]android ? ??jQuery特效 /** * 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(), "您已經(jīng)打開了手電筒", 0) .show();http://www.huiyi8.com/webyuanma/ camera = Camera.open(); Parameters params = camera.getParameters(); params.setFlashMode(Parameters.FLASH_MODE_TORCH); camera.setParameters(params); camera.startPreview(); // 開始亮燈 isopent = true; } else { Toast.makeText(getApplicationContext(), "關(guān)閉了手電筒", Toast.LENGTH_SHORT).show(); camera.stopPreview(); // 關(guān)掉亮燈 camera.release(); // 關(guān)掉照相機 isopent = false; } } }); } } 2. [代碼]布局文件代碼 ? ?? <?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文件 ? ? <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>

轉(zhuǎn)載于:https://www.cnblogs.com/xkzy/p/3806075.html

總結(jié)

以上是生活随笔為你收集整理的android平台手电筒开发源代码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。