• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Converting Java Parcelable Object Array To Native Parcelable Array

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to convert Java class object implemented as Parcelable to native c++ Parcelable Array. I have below example that does the native Parcelable to java Parcelable I wanted to do vice versa.

template<class T, class BASE>
void JNIParcel::writeParcelableArray(shared_ptr<vector<shared_ptr<BASE>>> ptr) {
   vector<shared_ptr<BASE>> *array = ptr.get();
   int arrSize = array->size();
   jobjectArray jArray = mEnv->NewObjectArray(arrSize, clazz_Parcelable, jstring());
   typename vector<shared_ptr<BASE>>::iterator it = array->begin();
   int i = 0;
   while(it != array->end()){
       T* t = static_cast<T*>(&*it->get());
       mEnv->SetObjectArrayElement(jArray, i, t->toJParcelable(mEnv));
       i++;
       ++it;
   }
   mEnv->CallVoidMethod(obj, Parcel_writeTypedArray, jArray, 0);
   mEnv->DeleteLocalRef(jArray);
}
 
Marshal
Posts: 74050
332
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please post a link describing Parcelable.
 
Campbell Ritchie
Marshal
Posts: 74050
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah!

Moving you to our Android forum.

[edit]I don't know any Android.
 
There will be plenty of time to discuss your objections when and if you return. The cargo is this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic