我正在使用Firebase后端在Swift中构建一个iOS应用程序.我的应用需要高级搜索选项.我被告知我应该通过这个github链接使用Flashlight/ElasticSearch https://github.com/firebase/flashlight
假设我的应用程序名称是SneakerSearch和我的
Firebase Project_ID is- sneakersearch-az12
Firebase Web_API_Key is- abc123XYZ000...
Firebase App_Url is- gs://sneakersearch-az12.appspot.com
Run Code Online (Sandbox Code Playgroud)
由于我是Heroku和Node.js的新用户,因此我需要一些建议.我以前从未学过,但我已经安装了Heroku工具带,'sudo gem heroku install'已经完成.
我列出了github方向/步骤以及我为每个方向采取的步骤.我需要方向帮助:1,4,5,6,9,10,12和15.
1.Install and run ElasticSearch or add Bonsai service via Heroku
Run Code Online (Sandbox Code Playgroud)
我在Heroku开了帐户.
1.问题:我是否需要创建我的应用程序的名称并在设置我的Heroku帐户后进行部署,还是应该等到第9步?
2.git clone https://github.com/firebase/flashlight
Run Code Online (Sandbox Code Playgroud)
2.我将上面的内容克隆到我的iOS应用程序的项目文件夹中
3.npm install
Run Code Online (Sandbox Code Playgroud)
3.在提示我首先运行"npm init"然后我运行"npm install"
4. edit config.js (see comments at the top, you must set FB_URL and FB_SERVICEACCOUNT at a minimum)
Run Code Online (Sandbox Code Playgroud)
4A.-问题:什么是"FB_SERVICEACCOUNT"?我正在使用Firebase 3,我在控制台的服务帐户上找不到任何内容.除了我已经制作的Firebase swift项目之外,我还必须使用node.js为我的项目设置另一个Firebase帐户吗?
4B.-问题:我在哪里"编辑config.js"并将我的FB_URL和FB_SERVICEACCOUNT设置为?这应该在我的package.json文件中吗?
5.node app.js (run the app)
Run Code Online (Sandbox Code Playgroud)
5.-问题:在终端我运行"node app.js"并得到"throw err; ^".为什么我会收到此错误?
6.curl -X POST http://localhost:9200/firebase
Run Code Online (Sandbox Code Playgroud)
6.-问题:这是为了什么?
7.cd flashlight
Run Code Online (Sandbox Code Playgroud)
7.switched到手电筒目录
8.heroku …Run Code Online (Sandbox Code Playgroud) 我有以下问题:我的手电筒应用程序在我的三星Galaxy S2上工作正常但不幸的是没有在三星Galaxy Nexus上(问题:手电筒忽略按钮点击 - >没有反应,没有光,没有崩溃,也没有例外).我读过"Galaxy Nexus上的LED手电筒可以通过哪种API控制?" 这里在stackoverflow但它没有帮助我,因为我的问题仍然发生.这是我控制灯光的代码片段:
final Button FlashLightControl = (Button)findViewById(R.id.ledbutton);
FlashLightControl.setOnClickListener(new Button.OnClickListener()
{
public void onClick(View arg)
{
if(camera != null)
{
//in case light is on we will turn it off
parameters = camera.getParameters();
parameters.setFlashMode(Parameters.FLASH_MODE_OFF);
camera.setParameters(parameters);
camera.stopPreview();
camera.release();
camera = null;
}
else
{
// light is off - we turn it on
camera = Camera.open();
parameters = camera.getParameters();
parameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
camera.setParameters(parameters);
camera.startPreview();
}
}});
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?为了完整起见 - 这些是我添加到Androidmanifest.xml的权限:
<uses-feature android:name="android.hardware.camera.flash" />
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/> …Run Code Online (Sandbox Code Playgroud) 嗨我正在使用基于位置的应用程序,并希望在后台使用iphone相机手电筒.不幸的是,手电筒只在前台工作,即使代码正在执行,它也会在后台自动关闭闪光灯.
我使用的代码只在前台工作
#import <AVFoundation/AVFoundation.h>
//flashcode
Class captureDeviceClass = NSClassFromString(@"AVCaptureDevice");
if (captureDeviceClass != nil) {
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if ([device hasTorch] && [device hasFlash]){
[device lockForConfiguration:nil];
if (device.torchMode == AVCaptureTorchModeOff)
{
[device setTorchMode:AVCaptureTorchModeOn];
[device setFlashMode:AVCaptureFlashModeOn];
//torchIsOn = YES;
}
else
{
[device setTorchMode:AVCaptureTorchModeOff];
[device setFlashMode:AVCaptureFlashModeOff];
// torchIsOn = NO;
}
[device unlockForConfiguration];
}
}
Run Code Online (Sandbox Code Playgroud) 我正在开发一种功能,可以将手电筒切换为开/关状态。几天前,我们在io2019中看到了来自Google的新库。我想出了一个主意,为什么不使用它。
一段时间后,我看不出有任何可能使用库中唯一的割炬。
即使在官方文档中,我也找不到适合我的任何有用信息,而且,他们中的示例应用程序也不必处理我的案件。
您是否有一些容易实现的想法,或者您知道如何使用CameraX做到这一点?
我担心使用camera或camera2,因为要粘贴的代码量太糟糕了。
友情链接:
[1] https://developer.android.com/training/camerax
[2] https://proandroiddev.com/android-camerax-preview-analyze-capture-1b3f403a9395
[3] https://github.com/android/camera/tree/master/CameraXBasic
[4] https://github.com/android/camera/tree/master/CameraXBasic
CameraX是一个Android Jetpack库,旨在简化相机开发。
我正在尝试编写一个应用程序,当按下按钮时会打开闪光灯.问题是应用程序没有检测到手机上的闪光灯.我在互联网上搜索了很多.当然其他人已经面临这个问题,我也应用了这些解决方案,但它们似乎没有用.我不知道是什么导致了这个问题.在这里发布代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_starting_point);
if(! getApplicationContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)) // checking if flash light is available inn android phone
{
Toast.makeText(StartingPoint.this, "Sorry this app can't work without flash light", Toast.LENGTH_LONG).show();
finish();
}
cam = Camera.open();
param = cam.getParameters();
}
@Override
public void onClick (View v)
{
if(!flashOn)
{
i=0;
flashOn=true;
param.setFlashMode(Parameters.FLASH_MODE_TORCH);
cam.setParameters(param);
cam.startPreview();
}
else{
i=0;
flashOn=false;
param.setFlashMode(Parameters.FLASH_MODE_OFF);
cam.setParameters(param);
cam.stopPreview();
}
Run Code Online (Sandbox Code Playgroud)
}
我也在Android Manifest中添加了这些权限.
<uses-permission android:name="android.permission.FLASHLIGHT"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
Run Code Online (Sandbox Code Playgroud)
问候
我写了一个简单的手电筒应用程序,我在HTC Sensation,Nexus 7,HTC One,Moto X,Galaxy S3,Galaxy S4和Nexus 5上进行了测试.唯一不起作用的是Nexus 5它没有抛出异常,因此找出错误证明是困难的.
这是我一直在使用的代码,但是:
sCamera = Camera.open();
sParameters = sCamera.getParameters();
sParameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
sCamera.setParameters(sParameters);
sCamera.startPreview();
Run Code Online (Sandbox Code Playgroud)
这里是LogCat应该打开LED时发生的屏幕截图:http://i.imgur.com/vXn5PoH.png
我从Nexus 5中提取了闪光模式列表,它说它们是:开,关,自动,火炬和红眼.这些都是预期的.我已经在开启,关闭和火炬之间进行了测试,但是没有任何东西能让灯光闪烁.而且我知道LED没有坏掉,因为其他手电筒应用程序运行正常.
因为我刚开始使用Android编码,所以我犹豫是否发布了我的问题,但现在我正处于无法抗拒的地步.
我有一项服务打开摄像头LED onCreate:
@Override
public void onCreate() {
// make sure we don't sleep
this.pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
this.mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "SleepLED");
this.mTimer = new Timer();
this.mTimerTask = new TimerTask() {
public void run() {
// turn on the LED
setFlashlight(Camera.Parameters.FLASH_MODE_TORCH);
mWakeLock.acquire();
}
};
// Get the notification-service
this.mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
// Display a notification about us starting. We put an icon in the status bar.
showNotification();
// Open camera
this.frontCam = Camera.open();
this.frontCamPara = frontCam.getParameters();
this.frontCam.lock();
// Schedule the …Run Code Online (Sandbox Code Playgroud) 我正在编写一个Android相机应用程序,并试图实现Flash功能,我正在使用SurfaceView,每当我点击闪光按钮切换工作但闪光灯不会来...看到我以下的代码,我已经习惯打开/关闭手电筒.
完整代码: -
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_camera);
preview=(SurfaceView)findViewById(R.id.surface);
previewHolder=preview.getHolder();
previewHolder.addCallback(surfaceCallback);
previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
previewHolder.setFixedSize(getWindow().getWindowManager()
.getDefaultDisplay().getWidth(), getWindow().getWindowManager()
.getDefaultDisplay().getHeight());
btnFlash = (ImageButton) findViewById(R.id.btnFlash);
/*
* First check if device is supporting flashlight or not
*/
hasFlash = getApplicationContext().getPackageManager()
.hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
if (!hasFlash) {
// device doesn't support flash
// Show alert message and close the application
AlertDialog alert = new AlertDialog.Builder(CameraLauncherActivity.this)
.create();
alert.setTitle("Error");
alert.setMessage("Sorry, your device doesn't support flash light!");
alert.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { …Run Code Online (Sandbox Code Playgroud) 我正在开发一种手电筒应用程序,其中一个活动中有一个普通的手电筒,一个活动中有一个闪光灯.现在我正在onCreate of Flashlight活动中获取相机.但是当我想要频闪活动时,我需要释放FlashLight活动所获得的相机.我不想在onPause of FlashLight活动中释放相机,因为即使用户按下主页按钮也会停止相机.我只想在用户进行频闪活动时释放相机,否则他会通过后退按钮退出应用程序.此外,如果用户从频闪活动回到手电筒活动,我想重新获取相机.无论如何他们都是这样做的.
我正在使用react-native-qrcode-scanner,我想要做的是:当用户按下手电筒图标 flashLight 继续时,我这样做了:
<QRCodeScanner
showMarker
onRead={this.onSuccess.bind(this)}
cameraStyle={{ height: SCREEN_HEIGHT }}
cameraProps={{ flashMode: this.state.flashLight ? RNCamera.Constants.FlashMode.on : RNCamera.Constants.FlashMode.off, captureAudio: false }}
Run Code Online (Sandbox Code Playgroud)
相机道具有效,但是当我更改 state.flashLight(true 或 false)时,flashLight 不会改变
任何想法如何根据状态更改相机道具?
flashlight ×10
android ×8
camera ×5
led ×3
java ×2
background ×1
firebase ×1
flash ×1
heroku ×1
ios8 ×1
nexus-5 ×1
node.js ×1
objective-c ×1
react-native ×1
surfaceview ×1
wakelock ×1