内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

利用Android怎么實現(xiàn)一個二維碼生成功能-創(chuàng)新互聯(lián)

利用Android怎么實現(xiàn)一個二維碼生成功能?很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。

成都創(chuàng)新互聯(lián)長期為上千余家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊從業(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ù)。擁有10年豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。

1.在project的build.gradle添加如下代碼:

allprojects {
  repositories {
    maven { 
      url 'https://jitpack.io'
     }
  }
}

2.在build.gradle添加依賴:

dependencies {
  compile 'com.github.goodboy321:Scan-Zxing:1.0'
}

布局:

<EditText
  android:id="@+id/et"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:hint="輸入內(nèi)容,生成二維碼"
  android:text="http://www.baidu.com" />

<Button
  android:background="@color/colorAccent"
  android:id="@+id/btn2"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:text="生成二維碼" />

<Button
  android:layout_marginTop="10dp"
  android:background="@color/colorPrimaryDark"
  android:id="@+id/btn1"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:text="掃碼(識別相冊中二維碼)" />

<ImageView
  android:id="@+id/image"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="center_horizontal" />

<ImageView
  android:id="@+id/image_callback"
  android:layout_marginTop="10dp"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_gravity="center_horizontal" />

主方法:

public void onClick(View view) {
  switch (view.getId()) {
    case R.id.btn1:
      Intent intent = new Intent(mContext, CaptureActivity.class);
      startActivityForResult(intent, REQUEST);
      break;
    case R.id.btn2:
      image.setVisibility(View.VISIBLE);
      //隱藏掃碼結(jié)果view
      imageCallback.setVisibility(View.GONE);

      String content = et.getText().toString().trim();
      Bitmap bitmap = null;
      try {
        bitmap = BitmapUtils.create2DCode(content);//根據(jù)內(nèi)容生成二維碼
        tvResult.setVisibility(View.GONE);
        image.setImageBitmap(bitmap);
      } catch (Exception e) {
        e.printStackTrace();
      }
      break;
   }
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  if (requestCode == REQUEST) {
    image.setVisibility(View.GONE);
    imageCallback.setVisibility(View.VISIBLE);

    String result = data.getStringExtra(CaptureActivity.SCAN_QRCODE_RESULT);
    Bitmap bitmap = data.getParcelableExtra(CaptureActivity.SCAN_QRCODE_BITMAP);

    if(bitmap != null){
      imageCallback.setImageBitmap(bitmap);//現(xiàn)實掃碼圖片
    }
  }

看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識有進(jìn)一步的了解或閱讀更多相關(guān)文章,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對創(chuàng)新互聯(lián)的支持。

文章標(biāo)題:利用Android怎么實現(xiàn)一個二維碼生成功能-創(chuàng)新互聯(lián)
文章起源:http://www.rwnh.cn/article6/cedeog.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站內(nèi)鏈定制網(wǎng)站、外貿(mào)建站移動網(wǎng)站建設(shè)、面包屑導(dǎo)航、服務(wù)器托管

廣告

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

成都定制網(wǎng)站網(wǎng)頁設(shè)計
云林县| 玉门市| 青浦区| 毕节市| 惠州市| 北海市| 阳朔县| 三亚市| 防城港市| 琼海市| 周口市| 金阳县| 琼结县| 万山特区| 嘉善县| 金湖县| 左权县| 广水市| 毕节市| 上栗县| 新乡市| 望谟县| 澄江县| 南昌县| 汉阴县| 贵德县| 林州市| 闸北区| 邵武市| 饶河县| 海兴县| 西昌市| 广东省| 崇信县| 六盘水市| 鸡西市| 洛阳市| 泽州县| 新乡县| 阳谷县| 怀集县|