Reolink Updates Learn More
Meet Reolink at IFA 2025! Learn More
Reolink Q&A Learn More
Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
@Reolink-Edificio-Castagna_969979572822233 Reolink please implement this here is example code where app dosnt need to be ooen for doorbell call screen to pop upimport android.Manifest;import android.content.pm.PackageManager;import android.os.Bundle;import android.util.Log;import android.view.View;import android.widget.Button;import android.widget.Toast;import androidx.appcompat.app.AppCompatActivity;import androidx.core.app.ActivityCompat;import androidx.core.content.ContextCompat;public class DoorbellCallActivity extends AppCompatActivity { private static final String TAG = "DoorbellCallActivity"; private static final int PERMISSION_REQUEST_CODE = 100; private boolean isTwoWayAudioEnabled = false; private Button twoWayAudioButton; private Button recordButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_doorbell_call); // Check for null after findViewById() is a critical safety measure. twoWayAudioButton = findViewById(R.id.btn_two_way_audio); recordButton = findViewById(R.id.btn_record); // Initialize video stream startVideoStream(); if (twoWayAudioButton != null) { twoWayAudioButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Check permissions before toggling microphone if (checkAudioPermission()) { toggleTwoWayAudio(); } else { requestAudioPermission(); } } }); } else { Log.e(TAG, "Button R.id.btn_two_way_audio not found in layout."); } if (recordButton != null) { recordButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Start recording only if permissions are granted if (checkStorageAndCameraPermissions()) { startRecording(); } else { requestStorageAndCameraPermissions(); } } }); } else { Log.e(TAG, "Button R.id.btn_record not found in layout."); } } // --- Lifecycle Management (CRITICAL MISTAKE CORRECTION) --- @Override protected void onPause() { super.onPause(); // Stop audio and video processing to save battery and resources stopVideoStream(); if (isTwoWayAudioEnabled) { disableTwoWayAudio(); } stopRecording(); // Stop recording if ongoing } @Override protected void onDestroy() { super.onDestroy(); // Release any long-held resources or streaming clients here // (The stop methods will be called in onPause, but this is a final cleanup) } // --- Permission Handling (CRITICAL MISTAKE CORRECTION) --- private boolean checkAudioPermission() { return ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED; } private void requestAudioPermission() { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.RECORD_AUDIO}, PERMISSION_REQUEST_CODE); } private boolean checkStorageAndCameraPermissions() { return ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED && ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED; } private void requestStorageAndCameraPermissions() { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE); } @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); if (requestCode == PERMISSION_REQUEST_CODE) { // Simple check: if at least one permission was granted if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { // Permission granted, retry action or update UI Toast.makeText(this, "Permission granted. Try again.", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(this, "Permission denied. Audio/Recording functions unavailable.", Toast.LENGTH_LONG).show(); } } } // --- Core Functionality --- private void startVideoStream() { Log.i(TAG, "Video stream initialized and started."); // Pseudo-code to initialize and display the live video feed } private void stopVideoStream() { Log.i(TAG, "Video stream stopped and resources released."); // Pseudo-code to stop and release video resources } private void toggleTwoWayAudio() { isTwoWayAudioEnabled = !isTwoWayAudioEnabled; if (isTwoWayAudioEnabled) { enableTwoWayAudio(); } else { disableTwoWayAudio(); } // Update the button text/icon to reflect the new state (UI update) if (twoWayAudioButton != null) { twoWayAudioButton.setText(isTwoWayAudioEnabled ? "Audio ON" : "Audio OFF"); } } private void enableTwoWayAudio() { Log.i(TAG, "Two-way audio activated (microphone enabled)."); // Activate microphone and allow two-way audio streaming } private void disableTwoWayAudio() { Log.i(TAG, "Two-way audio disabled (microphone muted)."); // Disable microphone for one-way audio only } private void startRecording() { Log.i(TAG, "Video recording started."); // Pseudo-code to start recording the video feed } private void stopRecording() { Log.i(TAG, "Video recording stopped."); // Pseudo-code to stop and finalize the video recording }}
Welcome Back!
Hi there! Join the Commnunity to get all the latest news, tips and more!