android E/eglCodecCommon 錯誤處理方式
android studio 模擬器 api 22
錯誤訊息,重複出現
E/eglCodecCommon: **** ERROR unknown type 0x0 (glSizeof,73)
E/eglCodecCommon: glUtilsParamSize: unknow param 0x00000b44
處理方式
You can solve this by adding android:hardwareAccelerated="false" in AndroidManifest.xml
2017年8月1日
2016年12月19日
關於條碼掃描Zxing,需要掃描時直立顯示:
關於條碼掃描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;
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月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();
2016年11月14日
Android studio測試問題 測試會出現安裝兩個相同APP
Android studio測試問題 測試會出現安裝兩個相同APP
問題出現在AndroidManifest.xml寫入2個Activity<intent-filter>
只要刪除底下紅色字體代碼即可以修正錯誤,正常測試。
AndroidManifest.xml
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SetupActivityListSample"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
2016年10月4日
Android Studio You can also reset/revoke a specific permissions using
Android Studio
You can also reset/revoke a specific permissions using
adb shell pm grant com.your.flashlight android.permission.CAMERA
adb shell pm revoke com.your.package android.permission.CAMERA
adb shell pm grant android.permission.CAMERA
adb shell pm reset-permissions
you should also add C:/android-sdk/platform-tools to you environment path
2016年3月19日
Android Studio API Level Change
Android Studio API Level Change
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.justin.jacky.myapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.justin.jacky.myapplication"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
訂閱:
文章 (Atom)