12

我想在不允许登录 google 帐户的设备上安装 google play 服务的 android-vision 部分。传统上,通过 play store 下载 android-vision 库作为对 google play 服务的更新。

据此包名应该是com.google.android.gms.vision.barcode。我使用 adb 列出了安装在我的根节点设备上的所有包,这些包已经下载了条形码扫描库,并且该包不在列表中。我希望自己拉包然后分发它。

感谢您的时间和精力。

4

3 回答 3

3

对于任何谷歌服务,您应该在控制台注册您的添加应用程序。

如果您不想添加您的应用程序,那么您可以使用任何第三方 API 来获取条形码。

https://github.com/zxing/zxing

于 2016-08-23T13:58:51.537 回答
2

您可以使用第三方库实现com.journeyapps:zxing-android-embedded:3.5.0

使用这个库,您也可以轻松集成 QR 码和条码阅读器,而无需使用谷歌帐户登录。

我的条形码阅读器代码:

    package com.example.elanwrap.qr_code_elan;

    import android.content.Intent;
    import android.net.Uri;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.Toast;
    import com.google.zxing.integration.android.IntentIntegrator;
    import com.google.zxing.integration.android.IntentResult;

    import static android.widget.Toast.LENGTH_LONG;

    public class MainActivity extends AppCompatActivity {

        Button button;
        //CREATING OBJECT
        private IntentIntegrator qrCode;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            button = (Button) findViewById(R.id.button);

            qrCode = new IntentIntegrator(this);

            button.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                   //  start the Scan here
                    qrCode.initiateScan();
                }
            });
        }

        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            IntentResult intentResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
            super.onActivityResult(requestCode, resultCode, data);
            if (intentResult != null) {
             //passing result to another Activity.
            //    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(intentResult.getContents() + ""));
                Intent browserIntent = new Intent(this, Result_activity.class );
                browserIntent.putExtra("rah",(intentResult.getContents()+""));
                startActivity(browserIntent);



            } else {
                Toast.makeText(getApplicationContext(), " Empty Result ", Toast.LENGTH_SHORT).show();
            }
        }
    }

和:

package com.example.elanwrap.qr_code_elan;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.TextView;
import android.widget.Toast;

public class Result_activity extends Activity {
    TextView textView;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.result_activity);
        textView=(TextView)findViewById(R.id.details);
        Intent intent = getIntent();
        String str = intent.getStringExtra("rah");
        textView.setText(str);
        Toast.makeText(this, str, Toast.LENGTH_SHORT).show();
    }
}
于 2018-06-26T08:24:14.823 回答
1

第 1 步:尝试将此库包含在基于应用程序的 gradle 文件中

执行com.google.android.gms:play-services-vision:11.0.2

执行info.androidhive:barcode-reader:1.1.2

第 2 步:通过参考链接创建您的扫描布局

于 2018-06-28T11:22:43.667 回答