-1

I'm working on a school project, I have a java server (pc) and an android client; I want to use my phone's camera as webcam on pc, so i want to make an android app that work in background and send the camera view to the pc server; I have made the connection between client and server with socket, in the client main I start a service that manage the connection thread, in this thread I should start the camera service (I still don't know if the camera class work, I'm using this code that i found in other questions: https://gist.github.com/RoundSparrow/142b840ca86ba7a46639f23c5c0d195b) in the manifest i have:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />

and

<service android:enabled="true" android:name=".MyService" />
<service android:enabled="true" android:name=".MyCamera" />

I tried start the camera service with: startService(new Intent(getBaseContext(),MyCamera.class)); but it say that startService and getBaseContext() cannot ber resolved; i changed it in Service S; S.startService(new Intent(getBaseContext(),MyCamera.class)); so I resolved the stastService error, but i don't know how to resolve the getBaseContext one (i tried with null context or S or S.getBaseContext() but it call nullpointer exception and crash);

how I have to start the camera service(or what i need to add in the camera code)?
there is someone that already worked on something similar and can give me some help?

silvio
  • 1
  • 5

1 Answers1

1

You added camera permission ? if not add this :

<uses-permission android:name="android.permission.CAMERA" /> <uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera.autofocus" />

Also look https://developer.android.com/reference/android/hardware/Camera for more information. Good Luck.

NecroMancer
  • 616
  • 11
  • 17