problem in moving the image from camera capture to other activity in android
in my app i want to capture an image and i want it to be viewed in another activity. the coding for my camera works properly only for capturing and storing the image in sdcard, when i added some extra codes to move the captured image from one activity to other the camera is not working.
in logcat the following error is shown 04-08 17:28:43.771: ERROR/AndroidRuntime(8717): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.resting.gis/com.resting.gis.Camera}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.resting.gis/View}; have you declared this activity in your AndroidManifest.xml?
but the View activity is been mentioned in manifest file
Following is my code to capture the image
protected static final int TAKE_RECEIPT = 0;
private Uri imageCaptureUri;
private String filename;
private Runnable submitReceiptRunnable = new Runnable()
{
public void run()
{
publishReceipt();
}
private void publishReceipt()
{
}
};
private ProgressDialog progressDialog;
OutputStream outStream;
Intent myIntent;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.camera);
takePictureFromCamera();
}
private void takePictureFromCamera()
{
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
imageCaptureUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "tmp_receipt_"
+ String.valueOf(System.currentTimeMillis()) + ".jpg"));
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageCaptureUri);
intent.putExtra("return-data", true);
startActivityForResult(intent, TAKE_RECEIPT);
String path = String.format("/sdcard/%d.jpg",System.currentTimeMillis());
try
{
outStream = new FileOutputStream(path);
doF开发者_运维技巧ileUpload(path);
Log.e("Camera",""+outStream);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
Intent i=new Intent();
i.setClassName("com.resting.gis","View");
i.putExtra("image", path);
startActivity(i);
}
private void takeReceiptCallback(int resultCode, Intent data)
{
if (resultCode == Activity.RESULT_OK)
{
submitReceipt();
}
}
private void submitReceipt()
{
Thread thread = new Thread(null, submitReceiptRunnable);
thread.start();
// progressDialog = ProgressDialog.show(this, "Please wait...", "Publishing receipt ...", true);
}
private String getBase64Receipt() {
try {
InputStream inputStream = getContentResolver().openInputStream(imageCaptureUri);
// byte[] bytes = CommonUtil.getBytesFromInputStream(inputStream);
// return Base64.encodeBytes(bytes);//(selectedImage.getPath().getBytes());
}
catch (IOException e)
{
Log.e("getbase64Reciept", ""+e);
}
return null;
}
private void publishReceipt()
{
String receipt = getBase64Receipt();
}
pls help me to find where i am going wrong
It's possible that you have not declared the second activity in your AndroidManifest.xml. All activities must be declared there in order to be accessible.
If you have done that, then I suggest trying to create the intent a different, less problematic way.
new Intent(this, com.resting.gis.View.class);
the first parameter is the context to use. The second is the Activity class to be started. When it's inside of your app, this is by far the easiest and least error prone way to start an activity. I made the assumption that com.resting.gis.View was the name of your second activity class.
http://developer.android.com/guide/topics/manifest/manifest-intro.html
精彩评论