Open Im10Anish opened 5 years ago
Hi , i am trying to use webview on android , i have succeess getting the allow camera request from app but cam is not opened can you help
Have you give the camera permission in the android manifest file?
On Sun, 17 Mar 2019, 03:31 webleb, notifications@github.com wrote:
Hi , i am trying to use webview on android , i have succeess getting the allow camera request from app but cam is not opened can you help
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/muaz-khan/RTCMultiConnection/issues/721#issuecomment-473596225, or mute the thread https://github.com/notifications/unsubscribe-auth/Ag0p1N11UXNXQONpX0GV4DaqPWnysLemks5vXWmygaJpZM4aXuUT .
yes
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.appName">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RESOURCE_VIDEO_CAPTURE" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
=============================================================================================
apply plugin: 'com.android.application'
android { compileSdkVersion 28 defaultConfig { applicationId "com.pixelgame686.snakepixelgame" minSdkVersion 15 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } }
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' compile 'pub.devrel:easypermissions:0.2.0' compile 'io.pristine:libjingle:9694@aar' compile 'me.kevingleason:pnwebrtc:1.0.6@aar' }
=============================================================================================
package com.pixelgame686.snakepixelgame;
import android.Manifest; import android.support.v7.app.AppCompatActivity; import android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback; import android.support.v4.app.Fragment; import android.os.Bundle; import android.os.Build;
import android.annotation.TargetApi;
import android.webkit.PermissionRequest; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.webkit.WebChromeClient;
import android.content.DialogInterface; import android.app.AlertDialog; import android.widget.Toast; import android.util.Log; import android.support.annotation.NonNull;
import pub.devrel.easypermissions.EasyPermissions;
public class MainActivity extends AppCompatActivity {
private String TAG = "TEST";
private PermissionRequest mPermissionRequest;
private static final int REQUEST_CAMERA_PERMISSION = 1;
private static final String[] PERM_CAMERA = {Manifest.permission.CAMERA};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView webView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = webView.getSettings();
//webView.setWebViewClient(new WebViewClient());
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setAllowFileAccessFromFileURLs(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebChromeClient(new WebChromeClient() {
// Grant permissions for cam
@Override
public void onPermissionRequest(final PermissionRequest request) {
Log.i(TAG, "onPermissionRequest");
mPermissionRequest = request;
final String[] requestedResources = request.getResources();
for (String r : requestedResources) {
if (r.equals(PermissionRequest.RESOURCE_VIDEO_CAPTURE)) {
// In this sample, we only accept video capture request.
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this)
.setTitle("Allow Permission to camera")
.setPositiveButton("Allow", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
mPermissionRequest.grant(new String[]{PermissionRequest.RESOURCE_VIDEO_CAPTURE});
Log.d(TAG,"Granted");
}
})
.setNegativeButton("Deny", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
mPermissionRequest.deny();
Log.d(TAG,"Denied");
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
break;
}
}
}
@Override
public void onPermissionRequestCanceled(PermissionRequest request) {
super.onPermissionRequestCanceled(request);
Toast.makeText(MainActivity.this,"Permission Denied",Toast.LENGTH_SHORT).show();
}
});
if(hasCameraPermission()){
webView.loadUrl("https://");
}
}
private boolean hasCameraPermission() {
return EasyPermissions.hasPermissions(MainActivity.this, PERM_CAMERA);
}
}
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.appName">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RESOURCE_VIDEO_CAPTURE" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
=============================================================================================
apply plugin: 'com.android.application'
android { compileSdkVersion 28 defaultConfig { applicationId "com.pixelgame686.snakepixelgame" minSdkVersion 15 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } }
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' compile 'pub.devrel:easypermissions:0.2.0' compile 'io.pristine:libjingle:9694@aar' compile 'me.kevingleason:pnwebrtc:1.0.6@aar' }
=============================================================================================
package com.pixelgame686.snakepixelgame;
import android.Manifest; import android.support.v7.app.AppCompatActivity; import android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback; import android.support.v4.app.Fragment; import android.os.Bundle; import android.os.Build;
import android.annotation.TargetApi;
import android.webkit.PermissionRequest; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.webkit.WebChromeClient;
import android.content.DialogInterface; import android.app.AlertDialog; import android.widget.Toast; import android.util.Log; import android.support.annotation.NonNull;
import pub.devrel.easypermissions.EasyPermissions;
public class MainActivity extends AppCompatActivity {
private String TAG = "TEST";
private PermissionRequest mPermissionRequest;
private static final int REQUEST_CAMERA_PERMISSION = 1;
private static final String[] PERM_CAMERA = {Manifest.permission.CAMERA};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView webView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = webView.getSettings();
//webView.setWebViewClient(new WebViewClient());
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setAllowFileAccessFromFileURLs(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebChromeClient(new WebChromeClient() {
// Grant permissions for cam
@Override
public void onPermissionRequest(final PermissionRequest request) {
Log.i(TAG, "onPermissionRequest");
mPermissionRequest = request;
final String[] requestedResources = request.getResources();
for (String r : requestedResources) {
if (r.equals(PermissionRequest.RESOURCE_VIDEO_CAPTURE)) {
// In this sample, we only accept video capture request.
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this)
.setTitle("Allow Permission to camera")
.setPositiveButton("Allow", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
mPermissionRequest.grant(new String[]{PermissionRequest.RESOURCE_VIDEO_CAPTURE});
Log.d(TAG,"Granted");
}
})
.setNegativeButton("Deny", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
mPermissionRequest.deny();
Log.d(TAG,"Denied");
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
break;
}
}
}
@Override
public void onPermissionRequestCanceled(PermissionRequest request) {
super.onPermissionRequestCanceled(request);
Toast.makeText(MainActivity.this,"Permission Denied",Toast.LENGTH_SHORT).show();
}
});
if(hasCameraPermission()){
webView.loadUrl("https://");
}
}
private boolean hasCameraPermission() {
return EasyPermissions.hasPermissions(MainActivity.this, PERM_CAMERA);
}
}
ignore test i upload a file
text*
why you didn't pass the URL here:
webView.loadUrl("https://");
And, what's happening when you hit URL from the web, camera working there perfectly? try the URL in the mobile browser too... and share the output
Hi From mobile browser is working perfectly maybe we miss some webrtc library or something
Hi , you ca share with me your webview code and i can check from my end
Hi , add me skype:inf.dealer@hotmail.com
Hi mauz, when i am opening video chat url from web browser it's working absolutely fine. But when the same url link opens in mobile apk using webview() it's creating one more stream which is blank it shows at left top corner it's also getting stored with blank stream. On web, two stream one local and another is remote but on apk three streaming gets starts.