2011-04-08 21 views
0

在我的應用程序中,我想捕獲一張圖像,我希望它可以在另一個活動中查看。 我的相機編碼只適用於在SD卡中捕獲和存儲圖像,當我添加一些額外的代碼來將捕獲的圖像從一個活動移動到其他相機不工作時。在將圖像從相機捕獲移動到其他活動中的問題android

在logcat中顯示以下錯誤 04-08 17:28:43.771:錯誤/ AndroidRuntime(8717):java.lang.RuntimeException:無法啓動活動ComponentInfo {com.resting.gis/com.resting。 gis.Camera}:android.content.ActivityNotFoundException:無法找到顯式的活動類{com.resting.gis/View};你有沒有在你的AndroidManifest.xml中聲明這個活動?

但觀活動清單文件

以下被提及是我的代碼來捕捉圖像

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); 
         doFileUpload(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(); 
      } 

請幫我找到我要去的地方錯了

回答

1

這是可能的你還沒有在AndroidManifest.xml中聲明第二個活動。 所有活動必須在那裏聲明才能被訪問。

如果你已經這樣做了,那麼我建議試圖創建一個不同的,不太成問題的方式。

new Intent(this, com.resting.gis.View.class); 

第一個參數是要使用的上下文。第二個是要啓動的Activity類。當它在你的應用程序中時,這是迄今爲止最簡單,最不容易出錯的啓動一個活動的方式。我假定com.resting.gis.View是第二個活動類的名稱。

http://developer.android.com/guide/topics/manifest/manifest-intro.html

相關問題