I'm trying to open the device camera an activate immediately the LED light of that device (android/iOS).
I've tried the appcelerator ti.media events but didn't work, neither this module: Ti.Light.
Found this on this link activate-iphone-4-led-light
Hey guys!
For the flash stuff you have to check the property:
Ti.Media.cameraFlashMode (case sensitive)
To change it you can use Ti.Media.setCameraFlashMode(PARAM) .
PARAM could be: Ti.Media.CAMERA_FLASH_OFF , Ti.Media.CAMERA_FLASH_ON,
Ti.Media.CAMERA_FLASH_AUTO
Unfortunately you can’t start the led and use it as a torch, you can
only control the camera flash handling (on, off, auto) while taking a
photo.
There is any module that allow to use the led light all the time? I just need this while the camera is opened.
UPDATE 1#:
I’m trying to use your ts.camera widget, that have the embed camera and flash methods:
github - ts.camera
gittio - ts.camera
But there is no method switchFlashlight() in “pw.custom.androidcamera” module, this widget works?
github - Ti-Android-CameraView
gittio - pw.custom.androidcamera
UPDATE 2#:
In order to find a workaroud, I've added this flashlight module, and I'm trying to call it before or after showing the camera, but I think that it's not possible to have 2 camera activities at the same time.
This is my index.js file:
if(OS_ANDROID) {
flash = require('dk.napp.flashlight');
if(!flash.isFlashLightOn()) flash.turnFlashLightOn();
camera = require('pw.custom.androidcamera');
view = camera.createCameraView();
}
I'm getting this error:
[DEBUG] : CameraViewProxy: Camera not available
[ERROR] : CameraViewProxy: Camera is null. Make sure
[ERROR] : CameraViewProxy: <uses-permission android:name="android.permission.CAMERA" />
[ERROR] : CameraViewProxy: is in you tiapp.xml file.
This is my tiapp.xml file:
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.FLASHLIGHT"/>
<uses-feature android:name="android.hardware"/>
<uses-feature android:name="android.hardware.camera"/>
<uses-feature android:name="android.hardware.camera2"/>
<uses-feature android:name="android.hardware.camera2.params"/>
<uses-feature android:name="android.hardware.camera.flash"/>
<uses-feature android:name="android.hardware.camera.autofocus"/>
These two modules might do the job:
http://gitt.io/search?q=flash
Although it could well be that activating the device camera will override the control over the flash light.
Related
My team follows this example for our browser configuration on Saucelabs:
https://github.com/saucelabs/testcafe-browser-provider-ios
To be exact, this is what we have in our code:
"test-ipad": "testcafe 'saucelabs:iPad Pro (9.7-inch) Simulator#13.3' ourService.js --speed 0.5"
But now we are facing a problem that we need to run the iPad in the vertical orientation.
Saucelabs says this can be configured:
https://support.saucelabs.com/hc/en-us/articles/225105867-Running-Mobile-Tests-in-Both-Landscape-and-Portrait-Mode
But I cannot find it anything I can read about testcafe-browser-provider-saucelabs.
Anyone knows how to add the device orientation parameter in that line of code?
Try setting the SAUCE_CAPABILITIES_OVERRIDES_PATH option to specify the path to the file that contains overrides for capabilities. In that file, you can set the desired configuration. See SauceLabs Test Configuration for details.
Please, help me to solve the proplem with app crash. I use react-native-youtube and everything works as expected except of one moment: after navigating to another screen and returning back - the app crashes without eny error in logs. Screens are placed in different stacks (doesn't sure if it means something).
Does anyone know what can be the reason of such error?
This is a WebView library issue and the fix is to set its opacity to 0.99.
<YoutubePlayer
play={false}
videoId={videoId}
webViewStyle={{opacity: 0.99}}. <==== add this
/>
<YoutubePlayer
play={false}
videoId={videoId}
resumePlayAndroid={false} <-- this helps (back crash)
/>
Unfortunately none of the above worked for me with react-navigation v6 but I've found a workaround.
To webViewProps, you can pass androidLayerType which has 3 possible values:
none (no video is rendered)
software (I also got no video on test device)
hardware (this setting is actually rendering the video layer but also causing the crash)
If you first pass software and then switch it to hardware as soon as the video is ready for rendering then there is no crash anymore.
const [isReadyForRender, setIsReadyForRender] = useState(false);
function onReady() {
setIsReadyForRender(true)
}
<YoutubePlayer
height={height}
play={playing}
videoId={videoId}
onReady={onReady}
webViewStyle={{opacity: 0.99, display: isReadyForRender ? 'flex' : 'none'}}
webViewProps={{androidLayerType: isReadyForRender ? 'hardware' : 'software'}}
/>
Using Worklight 6.2 and the new ActionSender API, I'd like to show the actionbar in the main CordovaActivity of my hybrid app.
That's in order to manage it by Javascript code, through the new API.
The problem is that getActionBar() returns null, even adding the holo theme and a layout to this activity.
Does somebody have a snippet of code to show me the how to do that?
Regards
Giuseppe
The blog post has been revised to include the missing pieces. Follow the instructions again, it will now work.
The missing pieces were related to the below:
Make sure that in your AndroidManifest, the activity doesn't have a theme without a title bar:
<activity
android:name=".HybridActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:launchMode="singleTask"
android:screenOrientation="sensor"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
^ last line should be removed.
>
Add a preference to Cordova configuration (res/xml/config.xml) to make the title bar be shown:
<preference name="ShowTitle" value="true" />
I am trying to write a custom camera application in android.
For that I need to open the camera application.
for that i am tring following code..
Camera camera = Camera.open();
but is showing error like
method open undefined for type Camera
i did as suggested here http://developer.android.com/reference/android/hardware/Camera.html#open(int)
any suggestion..
Thanks,
Ravindra Gupta
You most likely imported the wrong camera class at the top of your source file, which is android.graphics.Camera.
You need android.hardware.Camera instead.
Thanks
I think you have not added the camera permission. See below - you need to add this in your manifest;
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
Check your imports. I had a similar problem and the Camera object Eclipse chose for me was: import android.graphics.Camera; instead it should be: import android.hardware.Camera;
If none of the above work:
check to see if you are requesting camera permission manually. Newer Android permissions (API > 23) are set at runtime, not install time.
See: https://developer.android.com/training/permissions/requesting.html
Please create a variable like this:
android.hardware.Camera camera ;
and then try open method :
camera = camera.open();
// this is working on my android studio
I have Faced the same problem till i reached that older versions of android will work properly until Android Marshmallow so it needs a runtime permission in order to proceed and show the camera ...
you can read about it in this link https://developer.android.com/training/permissions/requesting.html
for me i used a 3rd party library to do all this stuff for me from this link and all resolved ..
https://android-arsenal.com/details/1/2804
Hope it helps
I have faced a lot of issues while using integrating camera native/camera2 api. The code was bulky. To avoid complexity and compatibility issues google provide new CameraX api in new android jetpack library. See the google provided documentation https://developer.android.com/training/camerax. There is also a Kotlin based library i found on github https://github.com/robertlevonyan/CameraXDemo. You can get more clearity with less code.
Waged right!!!
A permission request is required. And I found the right code. he works.
I advise you to look at this article to initially connect the camera:
https://habr.com/ru/post/112272/
enter image description here
if(ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MainActivity.this, new String[] {Manifest.permission.CAMERA}, 15); }
Below method executes on call for set Toast, but doesnot display any Toast after time elasped.
Is any more setting required for Windows 8 Metro app Toast notification
int scheduledToastCounter = 1;
public void Set_Future_Toast()
{
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
XmlNodeList stringElements = toastXml.GetElementsByTagName("text");
stringElements.Item(0).AppendChild(toastXml.CreateTextNode("Scheduled Toast"));
DateTimeOffset displayTime = DateTimeOffset.UtcNow.AddSeconds(3);
ScheduledToastNotification scheduledToast = new ScheduledToastNotification(toastXml, displayTime);
scheduledToast.Id = "Future_" + this.scheduledToastCounter++;
ToastNotifier notifier = ToastNotificationManager.CreateToastNotifier();
notifier.AddToSchedule(scheduledToast);
int scheduledToastCount = notifier.GetScheduledToastNotifications().Count;
}
}
You should set toast capable to yes in app package.
Be sure that you checked the box in the App's config file to enable Notifications.
The property settings of your object notifier told you why the toast can't be displayed:
0: Enabled, All notifications raised by this app can be displayed.
1: DisabledForApplication, The user has disabled notifications for this app.
2: DisabledForUser, The user or administrator has disabled all notifications for this user on this computer.
3: DisabledByGroupPolicy, An administrator has disabled all notifications on this computer through group policy. The group policy setting overrides the user's setting.
4: DisabledByManifest, This app has not declared itself toast capable in its package.appxmanifest file. This setting is found on the manifest's Application UI page, under the Notification section. For an app to send toast, the Toast Capable option must be set to "Yes".
http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.notifications.notificationsetting.aspx
You can change directly your Package.appxmanifest from code page :
add ToastCapable to the VisualElements Tag
<VisualElements ToastCapable="true">
Some times the screen of the Package.appxmanifest dosen't have the option to change it:
Need set small icon for notifications!!!
Have you tried to make the application Toast Capable? check this thread: Toast notification isn't working?
An interesting issue I ran into is I was using toast with images. I had the images in a dependent assembly with copy to output directory. Scheduling toast just failed silently. Ondemand toast failed with an HRESULT of E_FAIL (no other information). When I finally copied the images into the main project (with copy to output directory) then they started working.