This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Machine Learning with R: Expert techniques for predictive modeling and have Brett Lantz on-line!
See this thread for details.
Win a copy of Machine Learning with R: Expert techniques for predictive modeling this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Converting Java Parcelable Object Array To Native Parcelable Array

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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: 65821
250
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please post a link describing Parcelable.
 
Campbell Ritchie
Marshal
Posts: 65821
250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah!

Moving you to our Android forum.

[edit]I don't know any Android.
 
These are not the droids you are looking for. Perhaps I can interest you in a tiny ad?
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!