赞
踩
- <WebView
- android:id="@+id/webview"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- </WebView>
开启访问安卓原生相机权限,注册一个新活动:
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.yourapp">
-
- <uses-permission android:name="android.permission.CAMERA" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
-
- <application
- ...>
- <activity android:name=".MainActivity">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- <data android:scheme="myapp" />
- </intent-filter>
- </activity>
- </application>
- </manifest>
- import android.content.Intent;
- import android.graphics.Bitmap;
- import android.net.Uri;
- import android.os.Bundle;
- import android.provider.MediaStore;
- import android.webkit.WebSettings;
- import android.webkit.WebView;
- import androidx.appcompat.app.AppCompatActivity;
-
- public class MainActivity extends AppCompatActivity {
-
- private WebView webView;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
-
- webView = findViewById(R.id.webview);
-
- // 处理从相机活动返回的结果
- webView.setWebViewClient(new WebViewClient() {
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。