Download:
https://drive.google.com/file/d/0B61XQUA2tgEBTWhBYTNOci1jRlE/view?usp=sharing
1.新增 LibraryProject到eclipce中
File -> New -> Project -> Android -> Android Projects From Existing Code -> Next
3.移動www資料夾到assets下
6.移動新的AndroidManifest.xml覆蓋原本的AndroidManifest.xml
https://drive.google.com/file/d/0B61XQUA2tgEBTWhBYTNOci1jRlE/view?usp=sharing
1.新增 LibraryProject到eclipce中
File -> New -> Project -> Android -> Android Projects From Existing Code -> Next
點選LibraryProject
copy to workspace也打勾
|
CaptureActivity按左鍵點選Properties
點選android把isLibrary打勾
2. Do it step by step !New project |
Name your project |
Done |
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import org.apache.cordova.*;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import org.apache.cordova.*;
public
class
MainActivity
extends
DroidGap {
/** Called when the activity is first created. */
@Override
public
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
}
}
修改後 |
記得將com.example.*的*改成自己的專案名稱 |
7.在src資料夾按右鍵,選擇new package創立com.phonegap.plugins.barcodescanner
8.移動BarcodeScanner.java到com.phonegap.plugins.barcodescanner這個package下
9.在專案點選右鍵 選取properties 點選android
點add 選取captureactivity
9.config.xml和AndroidManifest.xml增加了:
config.xml:
<
plugin
name
=
"Device"
value
=
"org.apache.cordova.Device"
/>
<!-- Used to initialize cordova class -->
<
plugin
name
=
"Camera"
value
=
"org.apache.cordova.CameraLauncher"
/>
<
plugin
name
=
"BarcodeScanner"
value
=
"com.phonegap.plugins.barcodescanner.BarcodeScanner"
/>
AndroidManifest.xml:
<
activity
android:name
=
"org.apache.cordova.DroidGap"
android:label
=
"@string/app_name"
android:configChanges
=
"orientation|keyboardHidden"
>
<
intent-filter
></
intent-filter
>
</
activity
>
<!-- ZXing activities -->
<
activity
android:name
=
"com.google.zxing.client.android.CaptureActivity"
android:screenOrientation
=
"landscape"
android:clearTaskOnLaunch
=
"true"
android:configChanges
=
"orientation|keyboardHidden"
android:theme
=
"@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode
=
"stateAlwaysHidden"
android:exported
=
"false"
>
<
intent-filter
>
<
action
android:name
=
"com.phonegap.plugins.barcodescanner.SCAN"
/>
<
category
android:name
=
"android.intent.category.DEFAULT"
/>
</
intent-filter
>
</
activity
>
<
activity
android:name
=
"com.google.zxing.client.android.encode.EncodeActivity"
android:label
=
"@string/share_name"
>
<
intent-filter
>
<
action
android:name
=
"com.phonegap.plugins.barcodescanner.ENCODE"
/>
<
category
android:name
=
"android.intent.category.DEFAULT"
/>
</
intent-filter
>
</
activity
>
<
activity
android:name
=
"com.google.zxing.client.android.HelpActivity"
android:label
=
"@string/share_name"
>
<
intent-filter
>
<
action
android:name
=
"android.intent.action.VIEW"
/>
<
category
android:name
=
"android.intent.category.DEFAULT"
/>
</
intent-filter
>
</
activity
>
還有
<
uses-permission
android:name
=
"android.permission.CAMERA"
/>
參考連結:
https://mayukhsaha.wordpress.com/2013/07/09/barcode-qr-code-scanner-and-encoder-using-phonegap-android-and-eclipse/