zxing QR扫描仪不仅仅工作棒棒糖5.1版

时间:2017-08-07 10:33:35

标签: android android-fragments android-5.0-lollipop android-5.1.1-lollipop

我在android应用程序中完成了QR扫描程序的实现。它确实在6.0和其他一些操作系统版本中工作,但是当我点击QR扫描仪没有获得句柄意图时它在棒棒糖5.1版本中崩溃了。

代码:

     public  void aadahrScan() {
            Intent intent = new Intent("com.google.zxing.client.android.SCAN");
            startActivityForResult(intent, 0);
        }

     @Override
        public void onActivityResult(int requestCodeTools, int resultCodeTools, Intent intentTools) {
            if (requestCodeTools == 0 && intentTools != null) {
                requestCodeTools(resultCodeTools, intentTools);
            }
        }

Error:



  E/AndroidRuntime: FATAL EXCEPTION: main
   Process: com.boon.inthree, PID: 6034
                                                                    android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.google.zxing.client.android.SCAN }
                                                                        at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1799)
                                                                        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1508)
                                                                        at android.app.Activity.startActivityForResult(Activity.java:3829)
                                                                        at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50)
                                                                        at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79)
                                                                        at android.support.v4.app.ActivityCompatJB.startActivityForResult(ActivityCompatJB.java:30)
                                                                        at android.support.v4.app.ActivityCompat.startActivityForResult(ActivityCompat.java:146)
                                                                        at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:937)
                                                                        at android.support.v4.app.FragmentActivity$HostCallbacks.onStartActivityFromFragment(FragmentActivity.java:1047)
                                                                        at android.support.v4.app.Fragment.startActivityForResult(Fragment.java:959)
                                                                        at android.support.v4.app.Fragment.startActivityForResult(Fragment.java:948)
                                                                        at com.boon.inthree.PersonalInformation.aadahrScan(PersonalInformation.java:263)
                                                                        at com.boon.inthree.PersonalInformation$4.onClick(PersonalInformation.java:251)
                                                                        at android.view.View.performClick(View.java:4788)
                                                                        at android.view.View$PerformClick.run(View.java:19923)
                                                                        at android.os.Handler.handleCallback(Handler.java:739)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                        at android.os.Looper.loop(Looper.java:135)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:5401)
                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                        at java.lang.reflect.Method.invoke(Method.java:372)
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:919)
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:71

清单:

<?xml version="1.0" encoding="utf-8"?>

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".SplashClass"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>



    </activity>
    <activity
        android:name=".Login"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.AppCompat.NoActionBar" />
    <activity
        android:name=".MainActivity"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.AppCompat.NoActionBar"
        android:windowSoftInputMode="stateHidden" />
    <activity
        android:name=".ProductActivity"
        android:icon="@drawable/icon"
        android:screenOrientation="portrait"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" />
    <activity
        android:name=".ProductDeteils"
        android:screenOrientation="portrait"
        android:label="@string/app_name" />
    <activity
        android:name=".Checkout"
        android:screenOrientation="portrait"
        android:label="@string/app_name" />
    <activity
        android:name=".ProCheckout"
        android:screenOrientation="portrait"
        android:label="@string/app_name" />
    <activity
        android:name=".QuickActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateHidden|adjustResize" />
    <activity
        android:name=".FilterActivity"
        android:label="@string/app_name" />
    <activity
        android:name=".SyncActivity"
        android:screenOrientation="portrait"
        android:label="@string/app_name" />
    <activity
        android:name=".DashActivity"
        android:screenOrientation="portrait"
        android:label="@string/app_name" />
    <activity
        android:name=".DashOrderReview"
        android:screenOrientation="portrait"
        android:label="" />
    <activity
        android:name=".Thankyou"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.AppCompat" />
    <activity
        android:name=".ConformCheckout"
        android:label=""
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar" />
    <activity
        android:name=".RetailereKyc"
        android:label=""
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar"
        android:windowSoftInputMode="adjustResize" >

        </activity>

我添加了清单文件,但我也提供了访问摄像机所需的所有权限

请事先解决此问题

1 个答案:

答案 0 :(得分:0)

将此添加到您的canActivate(): Observable<boolean> { return this.auth.authState .take(1) .map(authState => !!authState) .do(auth => !auth ? this.router.navigate(['/login']) : true); }

AndroidManifest