關於條碼掃描Zxing,需要掃描時直立顯示:
android提供的SDK(android.hardware.Camera)裡大概不能正常的使用直立顯示(portrait layout)加載照相機,當用直立顯示模式加載照相機時會產生以下情況:
1.照相機成像左傾90度(傾斜);
2.照相機成像長寬比例不對(失比)。
基本上解決辦法如下:
1、在AndroidManifest.xml裡面配置一下 ,使CaptureActivity属性為portrait:android:screenOrientation="portrait"
2、如果只是單純的想改變照相機成像的方向,只需要在com.google.zxing.client.android.camera下的 CameraConfigurationManager類別中增加方法
protected void setDisplayOrientation(Camera camera, int angle) {
Method downPolymorphic;
try {
downPolymorphic = camera.getClass().getMethod("setDisplayOrientation", new Class[] { int.class });
if (downPolymorphic != null)
downPolymorphic.invoke(camera, new Object[] { angle });
} catch (Exception e1) { }
}
然後在方法void setDesiredCameraParameters(Camera camera){}中調用, setDisplayOrientation(camera, 90); 具體位置在camera.setParameters(parameters);語句前面。
3、改變完方向你會發現方向改變可可分辨率會變得很低,接下來就是優化了
1)首先在類別CameraManager.java中把
rect.left = rect.left * cameraResolution.x / screenResolution.x;
rect.right = rect.right * cameraResolution.x / screenResolution.x;
rect.top = rect.top * cameraResolution.y / screenResolution.y;
rect.bottom = rect.bottom * cameraResolution.y / screenResolution.y;
替換成
rect.left = rect.left * cameraResolution.y / screenResolution.x;
rect.right = rect.right * cameraResolution.y / screenResolution.x;
rect.top = rect.top * cameraResolution.x / screenResolution.y;
rect.bottom = rect.bottom * cameraResolution.x / screenResolution.y;
(2)然後是在DecodeHandler類別中的方法private void decode(byte[] data,int width,int height){}中添加
byte[] rotatedData = new byte[data.length];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++)
rotatedData[x * height + height - y - 1] = data[x + y * width];
(3)再就是CameraConfigurationManager類別中的方法void initFromCameraParameters(Camera camera){}中添加如下代碼:
Point screenResolutionForCamera = new Point();
screenResolutionForCamera.x = screenResolution.x;
screenResolutionForCamera.y = screenResolution.y;
// preview size is always something like 480*320, other 320*480
if (screenResolution.x < screenResolution.y) {
screenResolutionForCamera.x = screenResolution.y;
screenResolutionForCamera.y = screenResolution.x;
2016年12月19日
2016年12月10日
JackyAndJustin Android App 隱私權政策
JackyAndJustin Android App Privacy Policy
Information that may be collected from you
When you use this app, you do not need to enter your personal information (such as your name, ID number, email address, etc.). You will not acquire your personal information without your knowledge, unless you know in advance.
Third-party website
This service may include links to third party services or other third party websites that include the retailer with whom you deal. Please note that this policy applies only to personal information we collect through our services and we are not responsible for the personal information that third parties may collect, store and use through their websites or services. You should always read through the privacy policies of every web site you visit.
This policy change
We may from time to time make changes to this policy for a variety of reasons, for example, to reflect changes in laws and regulations or changes in industry specifications and technology.
If you have any questions or comments about this policy, please contact us.
隱私權政策
可能向您收集之資訊
您使用此APP時,並不需要輸入個人資料 (例如姓名、身分證字號、電子郵件地址等 ) ,除非事先告知,此APP不會在您不知情的狀況下,取得您個人資料。
第三方網站
本服務可能包含連至第三方服務或第三方其他網站之連結,這個第三方包括與您進行交易的零售商。請注意,本政策僅適用於我方透過服務收集的個人資訊,我方不對第三方可能透過其網站或服務收集、存儲及使用的個人資訊負有責任。您應始終仔細閱讀每個您瀏覽網站的隱私權政策。
本政策的變更
我方可能因各種原因而需不時對本政策進行變更,例如,為了反應法律與法規的變更或行業規範與技術發展的改變。
如果您對本政策有任何問題或意見,請聯絡我們。
Information that may be collected from you
When you use this app, you do not need to enter your personal information (such as your name, ID number, email address, etc.). You will not acquire your personal information without your knowledge, unless you know in advance.
Third-party website
This service may include links to third party services or other third party websites that include the retailer with whom you deal. Please note that this policy applies only to personal information we collect through our services and we are not responsible for the personal information that third parties may collect, store and use through their websites or services. You should always read through the privacy policies of every web site you visit.
This policy change
We may from time to time make changes to this policy for a variety of reasons, for example, to reflect changes in laws and regulations or changes in industry specifications and technology.
If you have any questions or comments about this policy, please contact us.
隱私權政策
可能向您收集之資訊
您使用此APP時,並不需要輸入個人資料 (例如姓名、身分證字號、電子郵件地址等 ) ,除非事先告知,此APP不會在您不知情的狀況下,取得您個人資料。
第三方網站
本服務可能包含連至第三方服務或第三方其他網站之連結,這個第三方包括與您進行交易的零售商。請注意,本政策僅適用於我方透過服務收集的個人資訊,我方不對第三方可能透過其網站或服務收集、存儲及使用的個人資訊負有責任。您應始終仔細閱讀每個您瀏覽網站的隱私權政策。
本政策的變更
我方可能因各種原因而需不時對本政策進行變更,例如,為了反應法律與法規的變更或行業規範與技術發展的改變。
如果您對本政策有任何問題或意見,請聯絡我們。
2016年12月8日
Android 使用Snackbar跟CoordinatorLayout
Android 使用Snackbar跟CoordinatorLayout
build.gradle
dependencies {
compile 'com.android.support:design:24.2.1'
}
activity_main.xml布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:onClick="createSnackbar"
android:text="@string/snackbar_test_button_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
MainActivity
container = (CoordinatorLayout) findViewById(R.id.container);
Snackbar.make(container, "This is explanation: Please give us permission", Snackbar.LENGTH_LONG)
.setAction("OK", new View.OnClickListener() {
@Override
public void onClick(View view) {
requestExternalStoragePermission();
}
}).show();
build.gradle
dependencies {
compile 'com.android.support:design:24.2.1'
}
activity_main.xml布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:onClick="createSnackbar"
android:text="@string/snackbar_test_button_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
MainActivity
container = (CoordinatorLayout) findViewById(R.id.container);
Snackbar.make(container, "This is explanation: Please give us permission", Snackbar.LENGTH_LONG)
.setAction("OK", new View.OnClickListener() {
@Override
public void onClick(View view) {
requestExternalStoragePermission();
}
}).show();
訂閱:
文章 (Atom)