没有安装后摄像头,工厂模式测试直接提示无法连接照相机,而不是跳转到前摄像头

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012966861/article/details/80169489
在CameraUtil.java中添加
import android.widget.Toast;

public static boolean isWindEmode(Activity currentActivity){
    Intent intent=currentActivity.getIntent();
	String action=intent.getAction();
	boolean isFromEmode=intent.getBooleanExtra("FromEm",false);
	if(isFromEmode){
	    Toast.makeText(currentActivity,R.string.emode_cannot_connect_camera_new,
		             Toast.LENGTH_LONG).show();
	    return true;
	}
	return false;
}

在CameraActivity.java中方法onCreate()中super.onCreate(state);语句下添加
if(CameraUtil.getCameraFacingIntentExtras(this)==-1 && CameraUtil.isWindEmode(this)){
    finish();
	return;
}
//如果手机没有获取到后摄像头并且打开活动的intent携带的信息表明该intent来自工厂模式
//则销毁当前活动,跳出方法

猜你喜欢

转载自blog.csdn.net/u012966861/article/details/80169489
今日推荐