Wenn der Benutzer, klicken Sie auf die Kamera zu verbinden, es beim nächsten Bildschirm öffnen nach wenigen Sekunden Fail to connect to camera service
Android Fail Kamera Service
wirft und sagen, es cannot connect to camera
Dies ist mein Code:
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);
}
}
Das ist mein Layout:
<?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>
Das ist mein AndroidManifest.xml Datei
<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>
Ich habe dies nach diesem Link http://mobile.tutsplus.com/tutorials/android/android-sdk-quick-tip-launching-the-camera/
Bitte helfen Sie mir, was ist ein issue.My Anwendung enthalten Registerkarte Aktivitätsgruppe.
Vielen Dank im Voraus ..
Ich landete nur das Gerät neu starten und alles hat danach funktioniert. – jwBurnside