سؤال

أحاول إرسال صورة الكاميرا من وجهة إلى وجهة أخرى لعرضها.حاليا أحاول استخدام الطريقة التالية،

بمجرد التقاط الصورة

     protected void onActivityResult(int requestCode, int resultCode, Intent data) {  

     super.onActivityResult(requestCode, resultCode, data);  
     switch(requestCode)
     {
         case CAMERA_RECEIPTREQUEST:  
         if(resultCode== Activity.RESULT_OK)
         {
         BitmapFactory.Options options = new BitmapFactory.Options();
         options.inSampleSize = 8;
         //ImageView jpgView = (ImageView)findViewById(R.id.imageView1);
         Bitmap receipt = BitmapFactory.decodeFile(photo.toString(),options);  

         Intent imagepass = new Intent(Activity1.this,Activity2.class);
         imagepass.putExtra("imagepass", imagepass);
         startActivity(imagepass);

في النشاط الثاني

      @Override
      public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.receiptreview);   
        //creating view ids
        createViewIds();  

        Bitmap receiptimage = (Bitmap) getIntent().getExtras().getParcelable("imagepass");
        receipt.setImageBitmap(receiptimage); 
    } 

لكنه يظهر خطأ StackOverFlow،

        at java.util.HashMap$EntrySet.iterator(HashMap.java:944)
        at android.os.Parcel.writeMapInternal(Parcel.java:486)
        at android.os.Bundle.writeToParcel(Bundle.java:1552)
        at android.os.Parcel.writeBundle(Parcel.java:502)
        at android.content.Intent.writeToParcel(Intent.java:5477)

لست متأكدًا مما إذا كنت أحاول استخدام طريقة خاطئة أم لا. أبحث عن بعض العينات أو الحلول لهذا الأمر.

شكرا لمساعدتكم يا رفاق.

هل كانت مفيدة؟

المحلول

يستخدم

         Bitmap receipt = BitmapFactory.decodeFile(photo.toString(),options);  

         Intent imagepass = new Intent(Activity1.this,Activity2.class);
         imagepass.putExtra("imagepass", receipt );
         startActivity(imagepass);

بدلاً من

        Bitmap receipt = BitmapFactory.decodeFile(photo.toString(),options);  

         Intent imagepass = new Intent(Activity1.this,Activity2.class);
         imagepass.putExtra("imagepass", imagepass);
         startActivity(imagepass);

أنت تقوم بتمرير imagepass لمثيل Intent imagepass.putExtra("imagepass", imagepass); حتى تمر Bitmap المثال في imagepass.putExtra("imagepass", receipt );

يحرر:

لتمرير الصور (الصور النقطية) بين الأنشطة في android، راجع هذه المشاركات:

كيف يمكنك تمرير الصور (الصور النقطية) بين أنشطة Android باستخدام الحزم؟

كيف يمكنني تمرير كائن نقطي من نشاط إلى آخر

نصائح أخرى

من ما أستطيع أن أرى تمريرك النية نفسها لتكون إرسالها.حاول: giveacodicetagpre. قد تعمل

، لا تزال جديدة في Android نفسي.

يمكننا أن نحاول طريقة أخرى لتحويل الصورة إلى صفيف بايت ثم اجتياز صفيف البايت من خلال النية وفي النشاط الذي يتم فيه استدعاء علينا تحويل صفيف البايت إلى النقطات

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top