<del id="d4fwx"><form id="d4fwx"></form></del>
      <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

            <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
          • 怎么在Android中實現(xiàn)掃描和生成二維碼-創(chuàng)新互聯(lián)

            這篇文章主要介紹了怎么在Android中實現(xiàn)掃描和生成二維碼的相關(guān)知識,內(nèi)容詳細易懂,操作簡單快捷,具有一定借鑒價值,相信大家閱讀完這篇怎么在Android中實現(xiàn)掃描和生成二維碼文章都會有所收獲,下面我們一起來看看吧。

            創(chuàng)新互聯(lián)公司長期為近1000家客戶提供的網(wǎng)站建設(shè)服務(wù),團隊從業(yè)經(jīng)驗10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為平果企業(yè)提供專業(yè)的網(wǎng)站設(shè)計、成都網(wǎng)站制作,平果網(wǎng)站改版等技術(shù)服務(wù)。擁有十多年豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。

            MainActivity.java


            public class MainActivity extends AppCompatActivity {
            
             private ImageView mImageView;
            
             @Override
             protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
            
              Button button =findViewById(R.id.btn);
              mImageView =findViewById(R.id.img);
              button.setOnClickListener(new View.OnClickListener() { //點擊按鈕掃描二維碼
               @Override
               public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this,CaptureActivity.class);
            
            
                startActivityForResult(intent,2);
               }
              });
            
             }
            
             @Override
             protected void onActivityResult(int requestCode, int resultCode, Intent data) {
              super.onActivityResult(requestCode, resultCode, data);
              if (requestCode==200&& resultCode==RESULT_OK){
            
               if (data!=null){
                String content = data.getStringExtra(Constant.CODED_CONTENT);
                if (TextUtils.isEmpty(content)){
            
                 Toast.makeText(MainActivity.this, "您的輸入為空!", Toast.LENGTH_SHORT).show();
                 return;
            
                }
            
                Bitmap logo = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
                try {
                 Bitmap bitmap = CodeCreator.createQRCode(content, 400, 400, logo);
                 mImageView.setImageBitmap(bitmap);
                } catch (WriterException e) {
                 e.printStackTrace();
                }
            
                Toast.makeText(MainActivity.this,"掃描"+content,Toast.LENGTH_SHORT).show();
            
            
               }
              }
             }
            }

            activity.main.xml

            <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:app="http://schemas.android.com/apk/res-auto"
             xmlns:tools="http://schemas.android.com/tools"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             tools:context=".MainActivity"
             android:orientation="vertical">
            
             <Button
              android:id="@+id/btn"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="掃一掃"/>
            
             <ImageView
              android:id="@+id/img"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              />
            
            </android.support.constraint.ConstraintLayout>

            需要配置的權(quán)限

            <uses-permission android:name="android.permission.INTERNET"/>
             <uses-permission android:name="android.permission.CAMERA"></uses-permission>
             <uses-permission android:name="android.permission.VIBRATE" />
             <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
             <uses-feature android:name="android.hardware.camera" />
             <uses-feature android:name="android.hardware.camera.autofocus" />
             <uses-permission android:name="android.permission.FLASHLIGHT" />

            build.gradle

            minSdkVersion 16  //配置16
            implementation'com.github.yuzhiqiang1993:zxing:2.2.1' //依賴

            外部build.gradle

            allprojects {
             repositories {
              google()
              jcenter()
              maven { url 'https://jitpack.io' } //加這行代碼
             }
            }

            關(guān)于“怎么在Android中實現(xiàn)掃描和生成二維碼”這篇文章的內(nèi)容就介紹到這里,感謝各位的閱讀!相信大家對“怎么在Android中實現(xiàn)掃描和生成二維碼”知識都有一定的了解,大家如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

            標(biāo)題名稱:怎么在Android中實現(xiàn)掃描和生成二維碼-創(chuàng)新互聯(lián)
            分享網(wǎng)址:http://www.jbt999.com/article46/ceoghg.html

            成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)定制網(wǎng)站、網(wǎng)站改版、靜態(tài)網(wǎng)站、網(wǎng)頁設(shè)計公司、ChatGPT

            廣告

            聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:[email protected]。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

            網(wǎng)站建設(shè)網(wǎng)站維護公司

              <del id="d4fwx"><form id="d4fwx"></form></del>
              <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

                    <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
                  • 中国性爱在线观看 | 美女高潮喷水网站 | 日韩精品电影无码 | 91AV在线观看爱 | 看黄色免费片 |