Khi nhấp chuột người dùng trên máy ảnh, nó mở màn hình kế tiếp sau vài giây nó ném Fail to connect to camera service
Android Fail để kết nối với dịch vụ camera
và nó nói cannot connect to camera
Đây là mã của tôi:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View viewLoad = LayoutInflater.from(CameraActivity.this).inflate(R.layout.camera, null);
setContentView(viewLoad);
Bundle bundle = this.getIntent().getExtras();
seletctedRetailer = bundle.getString("RetailerName");
retailerCode = bundle.getString("RetailerCode");
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
Bundle b = new Bundle();
b.putString("Activity", "RetailerOrderSActivity");
b.putString("RetailerName", seletctedRetailer);
b.putString("RetailerCode", retailerCode);
cameraIntent.putExtras(b);
getParent().getParent().setTitle("Image Capture");
startActivityForResult(cameraIntent,CAMERA_PIC_REQUEST);
vale +=1;
Button imgMCancel =(Button)findViewById(R.id.imgMCancel);
imgMCancel.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent i = new Intent(getBaseContext(), CameraMainActivity.class);
Bundle bundle = new Bundle();
bundle.putString("Activity", "CameraMainActivity");
bundle.putString("RetailerName", seletctedRetailer);
bundle.putString("RetailerCode", retailerCode);
i.putExtras(bundle);
View vi = SalesActivityGroup.group.getLocalActivityManager().startActivity("CameraMainActivity", i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
SalesActivityGroup.group.replaceView(vi);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == CAMERA_PIC_REQUEST) {
System.out.println("====YES======");
Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
ImageView image = (ImageView) findViewById(R.id.imageView1);
image.setImageBitmap(thumbnail);
}
}
Đây là bố cục của tôi:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/header"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="75dp"
android:layout_width="fill_parent">
<Button android:layout_width="wrap_content"
android:text="Cancel"
android:textColor="#FFFFFF"
android:background="@drawable/btn_red"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="150dp"
android:id="@+id/imgMCancel"
>
</Button>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/buttonClick"
android:text="Make Photo"
android:textColor="#FFFFFF"
android:background="@drawable/btn_red"
android:layout_gravity="center">
</Button>
</LinearLayout>
Đây là tập tin AndroidManifest.xml của tôi
<activity android:name=".sales.CameraActivity" android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden" android:clearTaskOnLaunch="false">
<intent-filter>
<action android:name="android.media.action.IMAGE_CAPTURE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Tôi đã làm điều này theo liên kết này http://mobile.tutsplus.com/tutorials/android/android-sdk-quick-tip-launching-the-camera/
Xin hãy giúp tôi là những gì một ứng dụng issue.My chứa Tab ActivityGroup.
Thanks in advance ..
Tôi vừa mới khởi động lại thiết bị và mọi thứ hoạt động sau đó. – jwBurnside