小编ben*_*eni的帖子

控制相机以纵向拍摄照片不会旋转最终图像

我正在尝试控制Android相机在肖像应用程序中拍照,但是当我保存图片时,它是在风景中.我用setCameraDisplayOrientation()方法将图像旋转了90个等级 ,但是不起作用.

然后我发现这个职位,但TAG_ORIENTATIONIS 0(不确定).如果我捕获此值并应用旋转值,则也不起作用.

我如何拍摄肖像并以良好的方向保存?

    /** Initializes the back/front camera */
private boolean initPhotoCamera() {
    try {
        camera = getCameraInstance(selected_camera);

        Camera.Parameters parameters = camera.getParameters();
   //           parameters.setPreviewSize(width_video, height_video);
   //           parameters.set("orientation", "portrait");
   //           parameters.set("rotation", 1);
   //           camera.setParameters(parameters);


        checkCameraFlash(parameters);

   //            camera.setDisplayOrientation( 0);
        setCameraDisplayOrientation(selected_camera, camera);


        surface_view.getHolder().setFixedSize(width_video, height_video);


        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width_video, height_video);
        surface_view.setLayoutParams(lp);

        camera.lock();

        surface_holder = surface_view.getHolder();
        surface_holder.addCallback(this);
        surface_holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

        setPreviewCamera();

    } catch (Exception e) {
        Log.v("RecordVideo", "Could not initialize the Camera");
        return false;
    }
    return true; …
Run Code Online (Sandbox Code Playgroud)

android android-camera android-orientation

57
推荐指数
4
解决办法
5万
查看次数

如何在Android中安装应用程序而没有系统应用程序?

我想获得菜单屏幕中显示的所有应用程序.但是,现在我只获得用户安装的应用程序或所有应用程序(包括系统应用程序).

我目前的代码是:

    final PackageManager pm = getActivity().getPackageManager();
    List<PackageInfo> apps = pm.getInstalledPackages(PackageManager.GET_META_DATA);

    ArrayList<PackageInfo> aux = new ArrayList<PackageInfo>();

    for (int i = 0; i < apps.size(); i++) {
        if (apps.get(i).versionName != null && ((apps.get(i).applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 1)) {
            aux.add(apps.get(i)); 
        }
Run Code Online (Sandbox Code Playgroud)

使用此代码,我可以获得用户安装的应用程序,如果我评论'if'指令,我将获得系统应用程序.

所以,我想让用户安装应用程序和应用程序,如联系人,图库等.

更新:

    final PackageManager pm = getActivity().getPackageManager();
    Intent intent = new Intent(Intent.ACTION_MAIN, null);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    List<ResolveInfo> apps = pm.queryIntentActivities(intent, PackageManager.GET_META_DATA);
Run Code Online (Sandbox Code Playgroud)

android

20
推荐指数
3
解决办法
3万
查看次数

如何在保存前使用PIL调整新上传的图像大小?

我想以800px的高度和宽度调整新图像的大小并保存它们.应用程序不得存储真实图像.有帮助吗?

这是我的代码,它保存原始图像,而不是调整大小的照片:

models.py:

class Photo(models.Model):        
    photo = models.ImageField(upload_to='photos/default/')


    def save(self):

        if not self.id and not self.photo:
            return            

        super(Photo, self).save()

        image = Image.open(self.photo)
        (width, height) = image.size

        "Max width and height 800"        
        if (800 / width < 800 / height):
            factor = 800 / height
        else:
            factor = 800 / width

        size = ( width / factor, height / factor)
        image.resize(size, Image.ANTIALIAS)
        image.save(self.photo.path)
Run Code Online (Sandbox Code Playgroud)

django django-models python-imaging-library

16
推荐指数
2
解决办法
2万
查看次数

Android Gradle中每个风味的代码路径

我有2个buildTypes(调试,发布)和2个productFlavors(product1,product2).我想为每个buildType和productFlavors定义一个buildConfigField.buildConfigField是从服务器下载数据的应用程序的URL,它会针对每个productFlavor和buildTypes进行更改.

我现在有:

buildTypes {
    debug {
        debuggable true
    }
    release {
        debuggable false
    }
}
productFlavors {
    product1 {
        buildConfigField STRING, "URL_BASE",  '"https://api1.release.com"'

    }
    product2 {
        buildConfigField STRING, "URL_BASE", '"https://api2.release.com"'

    }
}
Run Code Online (Sandbox Code Playgroud)

但是我想要这样的东西:

buildTypes {
    debug {
        debuggable true
    }
    release {
        debuggable false
    }
}
productFlavors {
    product1 {
        debug {
            buildConfigField STRING, "URL_BASE",  '"https://api1.debug.com"'
        }
        release {
            buildConfigField STRING, "URL_BASE",  '"https://api1.release.com"'
    }
    product2 {
        debug {
            buildConfigField STRING, "URL_BASE", '"https://api2.debug.com"'
            }
        release {
            buildConfigField STRING, "URL_BASE", '"https://api2.release.com"'
        } …
Run Code Online (Sandbox Code Playgroud)

android gradle build.gradle android-gradle-plugin

13
推荐指数
3
解决办法
2155
查看次数

每个风格和构建类型的签名配置必须不同

我在同一个 Android Studio 项目中有两个不同的应用程序。我有两种口味“flavor1”和“flavor2”,具有三种不同的构建类型“staging”、“debug”和“release”

问题是我需要为每个应用程序使用不同的密钥存储。

现在我有了这个,但它只能使用相同的密钥存储进行签名。

signingConfigs {
    release {
        def Properties props = new Properties()
        def propFile = new File('./signing.properties')
        if (propFile.canRead()) {
            props.load(new FileInputStream(propFile))

            if (props != null && props.containsKey('STORE_FILE')
                    && props.containsKey('STORE_PASSWORD')
                    && props.containsKey('KEY_ALIAS')
                    && props.containsKey('KEY_PASSWORD')) {
                android.signingConfigs.release.storeFile = file(props.getProperty('STORE_FILE'))
                android.signingConfigs.release.storePassword = props.getProperty('STORE_PASSWORD')
                android.signingConfigs.release.keyAlias = props.getProperty('KEY_ALIAS')
                android.signingConfigs.release.keyPassword = props.getProperty('KEY_PASSWORD')
            } else {
                println 'signing.properties found but some entries are missing'
                android.buildTypes.release.signingConfig = null
            }
        } else {
            println 'signing.properties not found'
            android.buildTypes.release.signingConfig = null
        }
    }
} 

buildTypes …
Run Code Online (Sandbox Code Playgroud)

android gradle

11
推荐指数
1
解决办法
5945
查看次数

如何调试原生Android应用程序?

我已经安装了Sequoyah Android Native Support,现在,我可以执行调试模式.我在哪里调用本机方法的同一行一个断点,所以当我执行调试Java模式中,蚀在此行中停止时,我执行"NDK-GDB"和我午餐C/C++调试模式,我看到控制台做了些什么.但是,我怎么能把C断点?因为我的C代码是.so库,所以我不能在这个文件中放置断点.我有一个JNI floder,其中有.c和.h文件,但是当我放置断点时不要停止.Eclipse日志识别断点,但打印错误.

break-insert com_example_pruebaffmpeg_MainActivity.c:4323 error,msg ="没有加载符号表.使用\"file \"命令."

android android-ndk

7
推荐指数
1
解决办法
2836
查看次数

为什么我的签名apk崩溃了?

我签了一个带有我创建的标志的应用程序.我已经在我的手机上安装了这个apk,这没关系,但是当我试图打开应用程序崩溃(没有显示任何活动)时,它并没有让我看到日志的可能性(这个对话框)没有报告按钮)

问题是我签署了应用程序的标志.我已经测试了其他标志,应用程序打开完美.我无法发布有关标志创建的任何信息,但只有我可以说我已经使用过:

别名中的字母和_字符

字母,数字和 - 密码中的字符

50年

和名字的信件

其他领域是空白的.

主要问题是该应用程序是在谷歌播放中发布的,那么如何发布新签名的apk而不取消发布此应用程序并创建新应用程序?

android

7
推荐指数
4
解决办法
1万
查看次数

如何在Google Map V2中的标记中偏移气球视图?

单击标记时,会出现一个气球.但是在标记和气球之间有太大的空间,所以我怎么能减少这个距离?这就像使用中的setBalloonBottomOffset方法V1 Google Map.

custom balloon是这堂课:

public class CustomInfoWindowAdapter implements InfoWindowAdapter {

    private final View mWindow;
    private final View mContents;

    public CustomInfoWindowAdapter(Activity activity) {
        LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        mWindow = inflater.inflate(R.layout.ballon, null);
        mContents = inflater.inflate(R.layout.ballon, null);
    }

    @Override
    public View getInfoWindow(Marker marker) {
        render(marker, mWindow);
        return mWindow;
    }

    @Override
    public View getInfoContents(Marker marker) {
        render(marker, mContents);
        return mContents;
    }

    private void render(Marker marker, View view) {
        String title = marker.getTitle();
        TextView titleUi = ((TextView) …
Run Code Online (Sandbox Code Playgroud)

android android-maps-v2

6
推荐指数
1
解决办法
3057
查看次数

当我返回到片段时,ViewPager为空白

我有具有两个片段的视图寻呼机的片段AroundMeFragment MapFragmentListFragment.当我第一次在这个片段中输入时,一切正常,但当我点击一个项目进入一个新片段中的详细视图,然后返回到AroundMeFragment时,视图为空,没有绘制任何项目.并且,如果我退出此片段并再次输入片段为空白.

当我从细节片段返回到AroundMeFragment时,如何才能看到片段的内容?

ArouundMeFragment:

public ArroundMeFragment() {
}

public static Fragment newInstance(Bundle bundle) {
    ArroundMeFragment f = new ArroundMeFragment();
    f.setArguments(bundle);
    return f;
}

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    this.activity = activity;
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    sectionShowed = MAP_VIEW_ARROUND_ME;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.arround_me_main_layout, container, false);

    mViewPager = (ViewPager) v.findViewById(R.id.viewPager);

    if (fragments == null) {
        fragments = new ArrayList<Fragment>();

        fragments.add(MapMainFragment.newInstance());

        Bundle bundle …
Run Code Online (Sandbox Code Playgroud)

android fragment android-viewpager

6
推荐指数
2
解决办法
5102
查看次数

Camera Server死机 - 某些设备仍然存在错误100

我正在尝试用前后摄像头开发录像机.该应用程序可以在后部(默认)和前置摄像头之间切换.当应用程序激活前置摄像头,然后我按下录制按钮,应用程序进入错误方法,然后我释放并启动摄像头和录制,但错误仍然存​​在.任何的想法?更新:我更新了onError方法,使用下面的代码,我认为我没有很好地发布和初始化相机,因为当应用程序执行此方法时,表面支架是黑色的,并没有给我什么相机看到

在这里,我的代码:

onError方法:

 public void onError(MediaRecorder mr, int what, int extra) {
    stopRecording();

    //if Error 100, app must release the Camera object and instantiate a new one.
    if (what == 100) {
        if (error_100  == 2) { //Error 100 persists, change camera
            if (Camera.getNumberOfCameras() <= 1) {
                //No mas camaras para app
            } else {
                if (selected_camera == FRONT_CAMERA) {
                    selected_camera=BACK_CAMERA;
                } else {
                    selected_camera=FRONT_CAMERA;
                }
                selected_camera_button.setEnabled(false);
                Toast.makeText(this, "Initializing other camera", Toast.LENGTH_SHORT).show();
            }

        } else { //No camera init finish …
Run Code Online (Sandbox Code Playgroud)

camera android video-recording

5
推荐指数
0
解决办法
1393
查看次数