Java Code Examples for android.view.SurfaceView#getHolder()
The following examples show how to use
android.view.SurfaceView#getHolder() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CaptureActivity.java From AndroidWebServ with Apache License 2.0 | 6 votes |
@Override protected void onPause() { if (handler != null) { handler.quitSynchronously(); handler = null; } inactivityTimer.onPause(); ambientLightManager.stop(); cameraManager.closeDriver(); if (!hasSurface) { SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); surfaceHolder.removeCallback(this); } super.onPause(); }
Example 2
Source File: CameraActivity.java From moVirt with Apache License 2.0 | 6 votes |
@Override protected void onPause() { if (handler != null) { handler.quitSynchronously(); handler = null; } cameraManager.closeDriver(); beepManager.close(); inactivityTimer.onPause(); ambientLightManager.stop(); if (!hasSurface) { SurfaceView surfaceView = (SurfaceView) findViewById(R.id.camera_preview); SurfaceHolder surfaceHolder = surfaceView.getHolder(); surfaceHolder.removeCallback(this); } super.onPause(); }
Example 3
Source File: VideoViewerActivity.java From CameraV with GNU General Public License v3.0 | 6 votes |
/** * * Called when the activity is first created. */ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); //prevent screenshots getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE); setContentView(R.layout.videoview); mPreview = (SurfaceView) findViewById(R.id.surface_video); holder = mPreview.getHolder(); holder.addCallback(this); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); extras = getIntent().getExtras(); }
Example 4
Source File: CaptureActivity.java From weex with Apache License 2.0 | 6 votes |
@Override protected void onPause() { if (handler != null) { handler.quitSynchronously(); handler = null; } inactivityTimer.onPause(); ambientLightManager.stop(); beepManager.close(); cameraManager.closeDriver(); // historyManager = null; // Keep for onActivityResult if (!hasSurface) { SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); surfaceHolder.removeCallback(this); } super.onPause(); }
Example 5
Source File: SurfaceGrabberActivity.java From CameraV with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("deprecation") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getLayout()); button = (Button) findViewById(R.id.surface_grabber_button); button.setOnClickListener(this); progress = (TextView) findViewById(R.id.surface_grabber_progress); progress.setText(String.valueOf(baseImages.size())); view = (SurfaceView) findViewById(R.id.surface_grabber_holder); view.setOnClickListener(this); holder = view.getHolder(); holder.addCallback(this); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); }
Example 6
Source File: CaptureFragment.java From vinci with Apache License 2.0 | 6 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { Bundle bundle = getArguments(); View view = null; if (bundle != null) { int layoutId = bundle.getInt(CodeUtils.LAYOUT_ID); if (layoutId != -1) { view = inflater.inflate(layoutId, null); } } if (view == null) { view = inflater.inflate(R.layout.vinci_frag_capture, null); } viewfinderView = (ViewfinderView) view.findViewById(R.id.viewfinder_view); surfaceView = (SurfaceView) view.findViewById(R.id.preview_view); surfaceHolder = surfaceView.getHolder(); return view; }
Example 7
Source File: MainActivity.java From droidel with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mSurfaceView = (SurfaceView) findViewById(R.id.mySurfaceView); mSurfaceHolder = mSurfaceView.getHolder(); mController = new Controller(this); }
Example 8
Source File: MainActivity.java From augmentedreality with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //display setup stuff tv_alt = (TextView) findViewById(R.id.altitudeValue); tv_lat = (TextView) findViewById(R.id.latitudeValue); tv_long = (TextView) findViewById(R.id.longitudeValue); tv_head = (TextView) findViewById(R.id.headingValue); tv_pitch = (TextView) findViewById(R.id.pitchValue); tv_roll = (TextView) findViewById(R.id.rollValue); tv_x = (TextView) findViewById(R.id.xAxisValue); tv_y = (TextView) findViewById(R.id.yAxisValue); tv_z = (TextView) findViewById(R.id.zAxisValue); //we need the sensor manager and the gps manager, the //registration is all in onpause and onresume; mgr = (SensorManager) this.getSystemService(SENSOR_SERVICE); //orientation orient = mgr.getDefaultSensor(Sensor.TYPE_ORIENTATION); //acceleraometer accel = mgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); //gps location information myL = (LocationManager) getSystemService(Context.LOCATION_SERVICE); //setup the location listener. //all the camera preivew information inPreview = false; cameraPreview = (SurfaceView) findViewById(R.id.cameraPreview); previewHolder = cameraPreview.getHolder(); previewHolder.addCallback(this); previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); }
Example 9
Source File: ScanActivity.java From GreenBits with GNU General Public License v3.0 | 5 votes |
@Override protected void onResume() { super.onResume(); cameraThread = new HandlerThread("cameraThread", Process.THREAD_PRIORITY_BACKGROUND); cameraThread.start(); cameraHandler = new Handler(cameraThread.getLooper()); final SurfaceView surfaceView = (SurfaceView) findViewById(R.id.scan_activity_preview); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); }
Example 10
Source File: MainActivity.java From Smartlab with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); surfaceView = (SurfaceView) findViewById(R.id.surfaceView1); surfaceHolder = surfaceView.getHolder(); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); surfaceHolder.addCallback(this); }
Example 11
Source File: LocalPlayer.java From android-MediaRouter with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { // Be sure to call the super class. super.onCreate(savedInstanceState); // Inflate the layout. setContentView(R.layout.sample_media_router_presentation); // Set up the surface view. mPresentationSurfaceView = (SurfaceView)findViewById(R.id.surface_view); SurfaceHolder holder = mPresentationSurfaceView.getHolder(); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); holder.addCallback(SurfaceViewPlayer.this); Log.i(TAG, "Presentation created"); }
Example 12
Source File: ScanIsbnActivity.java From barterli_android with Apache License 2.0 | 5 votes |
/** * Initialize the camera and start scanning for a barcode */ private void startScanningForBarcode() { // CameraManager must be initialized here, not in onCreate(). if (mCameraManager == null) { mCameraManager = new CameraManager(getApplication()); } if (mViewFinderView == null) { mViewFinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); mViewFinderView.setCameraManager(mCameraManager); } showScanner(); final SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); final SurfaceHolder surfaceHolder = surfaceView.getHolder(); if (mHasSurface) { // The activity was paused but not stopped, so the surface still // exists. Therefore // surfaceCreated() won't be called, so init the camera here. initCamera(surfaceHolder); } else { // Install the callback and wait for surfaceCreated() to init the // camera. surfaceHolder.addCallback(this); } }
Example 13
Source File: CameraActivity.java From BluetoothCameraAndroid with MIT License | 5 votes |
@Override public void initViews() { mSurfaceView = (SurfaceView) findViewById(R.id.activity_camera_surface); mSurfaceHolder = mSurfaceView.getHolder(); mSurfaceHolder.addCallback(this); mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); mRecordbutton = findViewById(R.id.record); mRecordbutton.setOnClickListener(this); findViewById(R.id.camera).setOnClickListener(this); }
Example 14
Source File: CameraPreviewView.java From rosjava_android_template with Apache License 2.0 | 5 votes |
private void init(Context context) { SurfaceView surfaceView = new SurfaceView(context); addView(surfaceView); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(new SurfaceHolderCallback()); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); bufferingPreviewCallback = new BufferingPreviewCallback(); }
Example 15
Source File: OverlayDisplayWindow.java From media-samples with Apache License 2.0 | 5 votes |
@Override public void show() { if (!mWindowVisible) { mSurfaceView = new SurfaceView(mContext); Display display = mWindowManager.getDefaultDisplay(); WindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); params.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; params.alpha = WINDOW_ALPHA; params.gravity = Gravity.LEFT | Gravity.BOTTOM; params.setTitle(mName); int width = (int)(display.getWidth() * INITIAL_SCALE); int height = (int)(display.getHeight() * INITIAL_SCALE); if (mWidth > mHeight) { height = mHeight * width / mWidth; } else { width = mWidth * height / mHeight; } params.width = width; params.height = height; mWindowManager.addView(mSurfaceView, params); mWindowVisible = true; SurfaceHolder holder = mSurfaceView.getHolder(); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); mListener.onWindowCreated(holder); } }
Example 16
Source File: ViESurfaceRenderer.java From webrtc-app-mono with BSD 3-Clause "New" or "Revised" License | 4 votes |
public ViESurfaceRenderer(SurfaceView view) { surfaceHolder = view.getHolder(); if(surfaceHolder == null) return; surfaceHolder.addCallback(this); }
Example 17
Source File: Renderer.java From Learning-Java-by-Building-Android-Games-Second-Edition with MIT License | 4 votes |
Renderer(SurfaceView sh){ mSurfaceHolder = sh.getHolder(); mPaint = new Paint(); }
Example 18
Source File: CaptureActivity.java From CodeScaner with MIT License | 4 votes |
@Override protected void onResume() { super.onResume(); // historyManager must be initialized here to update the history preference // CameraManager must be initialized here, not in onCreate(). This is necessary because // we don't // want to open the camera driver and measure the screen size if we're going to show the // help on // first launch. That led to bugs where the scanning rectangle was the wrong size and // partially // off screen. cameraManager = new CameraManager(getApplication()); viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); viewfinderView.setCameraManager(cameraManager); handler = null; setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); beepManager.updatePrefs(); ambientLightManager.start(cameraManager); inactivityTimer.onResume(); decodeFormats = EnumSet.noneOf(BarcodeFormat.class); decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS); decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS); characterSet = null; SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); if (hasSurface) { // The activity was paused but not stopped, so the surface still exists. Therefore // surfaceCreated() won't be called, so init the camera here. initCamera(surfaceHolder); } else { // Install the callback and wait for surfaceCreated() to init the camera. surfaceHolder.addCallback(this); } }
Example 19
Source File: CaptureActivity.java From android-apps with MIT License | 4 votes |
@Override protected void onResume() { super.onResume(); // CameraManager must be initialized here, not in onCreate(). This is necessary because we don't // want to open the camera driver and measure the screen size if we're going to show the help on // first launch. That led to bugs where the scanning rectangle was the wrong size and partially // off screen. cameraManager = new CameraManager(getApplication()); viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); viewfinderView.setCameraManager(cameraManager); resultView = findViewById(R.id.result_view); statusView = (TextView) findViewById(R.id.status_view); handler = null; lastResult = null; resetStatusView(); SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); if (hasSurface) { // The activity was paused but not stopped, so the surface still exists. Therefore // surfaceCreated() won't be called, so init the camera here. initCamera(surfaceHolder); } else { // Install the callback and wait for surfaceCreated() to init the camera. surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } beepManager.updatePrefs(); inactivityTimer.onResume(); Intent intent = getIntent(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); copyToClipboard = prefs.getBoolean(PreferencesActivity.KEY_COPY_TO_CLIPBOARD, true) && (intent == null || intent.getBooleanExtra(Intents.Scan.SAVE_HISTORY, true)); source = IntentSource.NONE; decodeFormats = null; characterSet = null; if (intent != null) { String action = intent.getAction(); String dataString = intent.getDataString(); if (Intents.Scan.ACTION.equals(action)) { // Scan the formats the intent requested, and return the result to the calling activity. source = IntentSource.NATIVE_APP_INTENT; decodeFormats = DecodeFormatManager.parseDecodeFormats(intent); if (intent.hasExtra(Intents.Scan.WIDTH) && intent.hasExtra(Intents.Scan.HEIGHT)) { int width = intent.getIntExtra(Intents.Scan.WIDTH, 0); int height = intent.getIntExtra(Intents.Scan.HEIGHT, 0); if (width > 0 && height > 0) { cameraManager.setManualFramingRect(width, height); } } String customPromptMessage = intent.getStringExtra(Intents.Scan.PROMPT_MESSAGE); if (customPromptMessage != null) { statusView.setText(customPromptMessage); } } else if (dataString != null && dataString.contains(PRODUCT_SEARCH_URL_PREFIX) && dataString.contains(PRODUCT_SEARCH_URL_SUFFIX)) { // Scan only products and send the result to mobile Product Search. source = IntentSource.PRODUCT_SEARCH_LINK; sourceUrl = dataString; decodeFormats = DecodeFormatManager.PRODUCT_FORMATS; } else if (isZXingURL(dataString)) { // Scan formats requested in query string (all formats if none specified). // If a return URL is specified, send the results there. Otherwise, handle it ourselves. source = IntentSource.ZXING_LINK; sourceUrl = dataString; Uri inputUri = Uri.parse(sourceUrl); returnUrlTemplate = inputUri.getQueryParameter(RETURN_URL_PARAM); decodeFormats = DecodeFormatManager.parseDecodeFormats(inputUri); } characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET); } }
Example 20
Source File: VitamioMedia.java From Vitamio-Cordova-Plugin with MIT License | 4 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); if (!io.vov.vitamio.LibsChecker.checkVitamioLibs(this)) return; requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); extras = getIntent().getExtras(); // handle extras if (extras == null) { wrapItUp(RESULT_CANCELED, "Error: No options provided"); } else { if (extras.containsKey("isStreaming")) { isStreaming = extras.getBoolean("isStreaming"); } if (extras.containsKey("shouldAutoClose")) { mShouldAutoClose = extras.getBoolean("shouldAutoClose"); } mMediaType = extras.getString("type"); if (mMediaType == null) mMediaType = MEDIA_TYPE_VIDEO; mMediaPlayer = new MediaPlayer(this); mMediaController = new MediaController(this, !isStreaming); mMediaController.setMediaPlayer(this); mMediaPlayer.setOnBufferingUpdateListener(this); mMediaPlayer.setOnCompletionListener(this); mMediaPlayer.setOnErrorListener(this); mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.setOnVideoSizeChangedListener(this); setVolumeControlStream(AudioManager.STREAM_MUSIC); RelativeLayout relLayout = new RelativeLayout(this); if (extras.containsKey("bgColor")) { try { bgColor = Color.parseColor(extras.getString("bgColor")); } catch (Exception e) { Log.v(TAG, "Error parsing color"); Log.e(TAG, e.toString()); bgColor = DEFAULT_BG_COLOR; } } relLayout.setBackgroundColor(bgColor); RelativeLayout.LayoutParams relLayoutParam = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); relLayoutParam.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); mMediaView = new SurfaceView(this); mMediaView.setLayoutParams(relLayoutParam); relLayout.addView(mMediaView); mProgressBar = new ProgressBar(this); mProgressBar.setIndeterminate(true); mProgressBar.setVisibility(View.VISIBLE); RelativeLayout.LayoutParams pblp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); pblp.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); mProgressBar.setLayoutParams(pblp); relLayout.addView(mProgressBar); mProgressBar.bringToFront(); mMediaController.setAnchorView(relLayout); mMediaController.setEnabled(true); if (mMediaType.equalsIgnoreCase(MEDIA_TYPE_AUDIO)) { mMediaView.setBackgroundColor(bgColor); if (extras.containsKey("bgImage")) { if (extras.containsKey("bgImageScaleType")) { String scaleType = extras.getString("bgImageScaleType"); if (scaleType.equalsIgnoreCase("fit")) { bgImageScaleType = ImageView.ScaleType.FIT_CENTER; } else if (scaleType.equalsIgnoreCase("stretch")) { bgImageScaleType = ImageView.ScaleType.FIT_XY; } else { bgImageScaleType = ImageView.ScaleType.CENTER; } } bgImage = new ImageView(this); new ImageLoadTask(extras.getString("bgImage"), this).execute(null, null); RelativeLayout.LayoutParams bgImageLayoutParam = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); bgImageLayoutParam.addRule(RelativeLayout.CENTER_IN_PARENT); bgImage.setLayoutParams(bgImageLayoutParam); bgImage.setScaleType(bgImageScaleType); relLayout.addView(bgImage); } } setContentView(relLayout, relLayoutParam); holder = mMediaView.getHolder(); holder.addCallback(this); holder.setFormat(PixelFormat.RGBA_8888); } }