Android Tutorial-Android Spy Camera Example using android serviceANDROIDKAWE

Android Tutorial-Android Spy Camera Example using android serviceANDROIDKAWE - Welcome to ANDROID KAWE, Ini adalah sebuah blog directory tentang burung,baik itu suara burung ataupun tips perawatan burung.Blog ini adalah situs perangkum otomatis dari pencarian google yang kali ini berjudul Android Tutorial-Android Spy Camera Example using android serviceANDROIDKAWE.Ada ribuan artikel yang sudah terekam ke dalam situs ini,silahkan cari sesuai yang kalian kehendaki,untuk artikel selanjutnya tentang judul diatas bisa kalian baca di bawah ini.

Konten : Android Tutorial-Android Spy Camera Example using android serviceANDROIDKAWE
Judul : Android Tutorial-Android Spy Camera Example using android serviceANDROIDKAWE

lihat juga


Android Tutorial-Android Spy Camera Example using android serviceANDROIDKAWE

Image Clicked in background using android camera service


hi friends,
Today i am going to taught how to create spy camera, basically if you want your smart phone camera clicked image in background with out using any fore ground graphics then you use this concept.
this idea you can use to create security application locker. This is also an example of android service that help to click picture in background.

Requirement to Create Spy Camera:-



1. we have to create an service that run camera application in background.
2.we have to give external storage write and  using camera permission in android manifest file.



Complete Code:
Android Activity code:




package com.apsmind.spycamera;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity1 extends Activity {


 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main_activity1);

startService(new Intent(MainActivity.this, CameraService.class) );

 }

android Service Class : create a class name CameraService.


package com.apsmind.spycamera;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.hardware.Camera;
import android.hardware.Camera.Parameters;

import android.os.IBinder;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.widget.Toast;

public class CameraService extends Service
{
 static int x=0;
      //Camera variables
      //a surface holder
      private SurfaceHolder sHolder;
      //a variable to control the camera
      private Camera mCamera;
      //the camera parameters
      private Parameters parameters;
      /** Called when the activity is first created. */
    @Override
    public void onCreate()
    {
        super.onCreate();
       
    }
    @Override
    public void onStart(Intent intent, int startId) {
      // TODO Auto-generated method stub
      super.onStart(intent, startId);
   
       mCamera = Camera.open();
       SurfaceView sv = new SurfaceView(getApplicationContext());
 

       try {
                  mCamera.setPreviewDisplay(sv.getHolder());
                  parameters = mCamera.getParameters();
                 
                   //set camera parameters
                 mCamera.setParameters(parameters);
                 mCamera.startPreview();
                 mCamera.takePicture(null, null, mCall);
         
            } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }
     
     
       //Get a surface
         sHolder = sv.getHolder();
        //tells Android that this surface will have its data constantly replaced
         sHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }

   
   
    Camera.PictureCallback mCall = new Camera.PictureCallback()
    {

       public void onPictureTaken(byte[] data, Camera camera)
       {
             //decode the data obtained by the camera into a Bitmap
   
             FileOutputStream outStream = null;
                  try{
                   x++;
                      outStream = new FileOutputStream("/sdcard/Image"+x+".jpg");
                      outStream.write(data);
                      outStream.close();
                      mCamera.release();
                      Toast.makeText(getApplicationContext(), "picture clicked", Toast.LENGTH_LONG).show();
                  } catch (FileNotFoundException e){
                      Log.d("CAMERA", e.getMessage());
                  } catch (IOException e){
                      Log.d("CAMERA", e.getMessage());
                  }
   
       }
    };


      @Override
      public IBinder onBind(Intent intent) {
            // TODO Auto-generated method stub
            return null;
      }
}



Android Manifest File :




    package="com.apsmind.spycamera"
    android:versionCode="1"
    android:versionName="1.0" >

            android:minSdkVersion="8"
        android:targetSdkVersion="18" />
   
   
   

            android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
                    android:name="com.apsmind.spycamera.MainActivity"
            android:label="@string/app_name" >
           
               

               
           
       
       
   




To Learn Interesting and Live project Base Android Application Development join Apsmind Technology Pvt Ltd.

http://www.apsmind.com (Training)
http://www.apsmindtech.com  (Development)



Demikianlah Artikel Android Tutorial-Android Spy Camera Example using android serviceANDROIDKAWE

Semoga artikel tentang Android Tutorial-Android Spy Camera Example using android serviceANDROIDKAWE, mudah-mudahan bisa memberi manfaat untuk anda semua.

Anda sedang membaca artikel Android Tutorial-Android Spy Camera Example using android serviceANDROIDKAWE dan artikel ini url permalinknya adalah https://androidkawe.blogspot.com/2016/07/android-tutorial-android-spy-camera.html Semoga artikel ini bisa bermanfaat.Sekali lagi,ini adalah situs auto yang tidak ditulis langsung oleh admin,Kami tidak menjamin akan kebenaran dari artikel yang tertulis.
Back To Top