hasSystemFeature(PackageManager.FEATURE_CAMERA) return false on Android things? - camera

On Android things that is running on Raspberry-Pi
I tried to check if the camera available.. And it return false.
I use a camera device with a usb plug.(Camera has a usb port that can connect to the board)
I already put these in the manifest
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-permission android:name="android.permission.CAMERA" />
The code to check the camera
getApplication().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA) // return false
I tried to access the camera with this...
Camera c = Camera.open() // return null
In the setting, there is a camera preview that allow us to see the video that is being captured from the camera and I can see it.
Now how can I access the camera?
EDIT
I tried using a camera with CSI-2 interface, but it still doesn't work.

Related

Video in full Screen not working in Android react-native-video

<Video
source={{ uri: "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" }}
resizeMode="cover"
repeat
controls
fullscreen = {this.state.fullscreen}
fullscreenOrientation = {"landscape"}
//onBuffer={this.onBuffer} // Callback when remote video is buffering
//onError={this.videoError} // Callback when video cannot be loaded
style={styles.backgroundVideo}
/>
I am using this above code and in the Android manifest orientation in portrait. I am click on the full screen state has been changes according to it. But it just exit in a second. As i am getting a little fluctuation and maybe the app is showing full screen and then exit from full screen. But i am not able to see it. Or you can say full screen is not working. As in the IOS it is working properly. I tried multiple from github but not able to achieve it.

Webrtc disable track doesn't turn off webcam

I am trying to implement a toggle video feature using webRTC. Refer to the following code:
<video id="remote" autoPlay></video>
<button onclick="toggleVideo()">Toggle video</button>
let localVideo = document.querySelector('#local');
const toggleVideo = () => {
localVideo.srcObject.getVideoTracks()[0].enabled = !localVideo.srcObject.getVideoTracks()[0].enabled
}
This turns off video as well as webcam indicator in firefox but not in chrome. Chrome only turns off the video.
According to MDN docs,
If the MediaStreamTrack represents the video input from a camera, disabling the track by setting enabled to false also updates device activity indicators to show that the camera is not currently recording or streaming. For example, the green "in use" light next to the camera in iMac and MacBook computers turns off while the track is muted in this way.
MDN docs
Is there any other workaround?

Black screen for video when testing on iOS simulator

I am trying to show a video using the react-native-video plugin. When testing on the device the video is working but on the iOS simulator it's showing black screen (Testing on simulator is faster and easy for me). Someone having the same issue. Here is my code:
<Video
source={{ uri: 'url' }} // Can be a URL or a local file.
ref={(ref) => { this.player = ref; }} // Store reference
rate={1.0} // 0 is paused, 1 is normal.
volume={1.0} // 0 is muted, 1 is normal.
muted={false} // Mutes the audio entirely.
paused={this.state.paused} // Pauses playback entirely.
resizeMode="cover" // Fill the whole screen at aspect ratio.
repeat={false} // Repeat forever.
playInBackground={false} // Audio continues to play when app entering background.
playWhenInactive={false} // [iOS] Video continues to play when control or notification center are shown.
progressUpdateInterval={250.0} // [iOS] Interval to fire onProgress (default to ~250ms)
onLoadStart={this.loadStart} // Callback when video starts to load
onLoad={this.setDuration} // Callback when video loads
onProgress={this.setTime} // Callback every ~250ms with currentTime
onEnd={this.onEnd} // Callback when playback finishes
onError={this.videoError} // Callback when video cannot be loaded
onBuffer={this.onBuffer} // Callback when remote video is buffering
style={styles.backgroundVideo}
/>
Simulator is designed to assist you in designing, rapidly prototyping, and testing your app, but it should never serve as your sole platform for testing. One reason is that not all apps are available in the simulator. For example, the Camera app is available only on hardware devices and cannot be replicated in the simulator.
The simulator won't use your computer's camera, so anytime you are using the camera for anything, it will just default to a black screen.
More Info: https://developer.apple.com/library/content/documentation/IDEs/Conceptual/iOS_Simulator_Guide/GettingStartedwithiOSSimulator/GettingStartedwithiOSSimulator.html
Your code is fine but you can't play the video in any simulator, you need run the app in real device either android or ios.

App doesn't run correctly from ToastNotification action

I'm trying to make a very simple demo to show how to work with Background Tasks and Toast Notifications in UWP. I've a simple task, which is triggered on network connection change and his work is to show a simple notification. It's of course registered in OS, selected in manifest and this task works well.
I've created a package and installed the app in my laptop to try if it run even in the moment when the app isn't launched. Task works as well.
The only problem is, that when I click on "Run app" button in notification, I want to launch app running in foreground. It starts app, but the only thing I can see is splash screen of my app and nothing else happened. I saw MSDN tutorial to this notification and my XML is almost the same.
My XML notification's content:
<toast launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<text>Test notification</text>
<text>This is a simple toast notification</text>
<image placement="AppLogoOverride" src="../Assets/icon.png"/>
</binding>
</visual>
<actions>
<action activationType="foreground" content="Run App" arguments="check" />
</actions>
<audio src="ms-winsoundevent:Notification.SMS" />
</toast>
UPDATE
The only modified part in App.xaml.cs:
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.ToastNotification)
{
var toastArgs = (ToastNotificationActivatedEventArgs)args;
ToastArg = toastArgs.Argument;
}
}
You need to invoke the initialization of your app (things inside OnLaunch method) from OnActivated. Remember to check if your app is running or not when initialization.

Titanium Mobile Android: Memory not released when app is closed

We have developed an app using Titanium Mobile. When we first run the app in an Android device it uses around 25MB of memory. But every time we exit the app by using the device back button and then relaunch the app, the memory usage goes up by 10MB. So if we exit and relaunch the app 5 times, the app ends up using 50MB of extra memory, for a total usage of 75MB. If we launch the app a few more times, the app will simply not start, and the following error is thrown:
Uncaught Error: Failed to load resource, Java exception was thrwon.
Source = assets.readAsset(assetPath);
We initially thought it was a problem of our app, so we develop a simple app to test the issue. This test app just creates a window and adds a label to it. The app.js is the following:
function createView() {
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff',
exitOnClose: true
});
var label1 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 1',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
win1.add(label1);
win1.open();
}
createView();
Well, the test app has the same problem as our original app. The first time it is launched it consumes 14MB of memory. After 5 restarts (using the device back button) it is consuming 21MB (150% of the inital memory).
We have also tried the sample app that is generated when you create a project in Titanium and the Kitchen Sink app developed by Titanium. The results are the same.
Our tests are done using Titanium 3.0.0.GA with two different devices:
HTC Desire Z - Android 2.3
Samsung Galaxy 2 - Android 4.0
We have searched for a solution to this problem with no results. We do not want to believe this is the normal behaviour of Titanium, because if so, Titanium is simply not an option for us. Has anyone found any solution/workaround for this issue?
Thanks in advance
UPDATE: added tiapp.xml of test app
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
<id>com.cloudship.titanium.mobile.test</id>
<name>titanium-mobile-test</name>
<version>1.0</version>
<publisher>Javier</publisher>
<url>http://</url>
<description>not specified</description>
<copyright>2013 by Javier</copyright>
<icon>appicon.png</icon>
<persistent-wifi>false</persistent-wifi>
<prerendered-icon>false</prerendered-icon>
<statusbar-style>default</statusbar-style>
<statusbar-hidden>false</statusbar-hidden>
<fullscreen>false</fullscreen>
<navbar-hidden>true</navbar-hidden>
<analytics>true</analytics>
<guid>18e506f3-02d4-4fb7-84b7-ff8d4c1fac82</guid>
<property name="ti.ui.defaultunit" type="string">system</property>
<iphone>
<orientations device="iphone">
<orientation>Ti.UI.PORTRAIT</orientation>
</orientations>
<orientations device="ipad">
<orientation>Ti.UI.PORTRAIT</orientation>
<orientation>Ti.UI.UPSIDE_PORTRAIT</orientation>
<orientation>Ti.UI.LANDSCAPE_LEFT</orientation>
<orientation>Ti.UI.LANDSCAPE_RIGHT</orientation>
</orientations>
</iphone>
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<application android:debuggable="true"/>
<supports-screens android:anyDensity="true"/>
</manifest>
</android>
<mobileweb>
<precache/>
<splash>
<enabled>true</enabled>
<inline-css-images>true</inline-css-images>
</splash>
<theme>default</theme>
</mobileweb>
<modules/>
<deployment-targets>
<target device="iphone">false</target>
<target device="ipad">false</target>
<target device="blackberry">false</target>
<target device="android">true</target>
<target device="mobileweb">false</target>
</deployment-targets>
<sdk-version>3.0.0.GA</sdk-version>
</ti:app>
It is a bug in Titanium 3.0.0.GA. See jira ticket here. Fortunately it has been fixed in 3.0.2.
Answer was given in Titanium Q&A
i'm also developing Titanium. I checked my app and I'm not experiencing this problems on Android 2.2.2 on an HTC Desire. The app is closed correctly.
Can you test with the following code:
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff',
exitOnClose: true
});
var label1 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 1',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
win1.add(label1);
win1.open();
so remove the surrounding function.
this is solution to memory woes..please go through this thread
https://developer.appcelerator.com/question/116867/this-is-a-solution-to-your-memory-woes