1

I have a userObject Class(made it parcelable for following implementation) and I wrote the below code in my service. Just want to know, is there any other efficient/easy way then Android Parcelable in which I need not to make my class Parcelable?

  public  final static String PAR_KEY = "par_key";
userObject currentUser = new userObject(uid,uname,role,status,avatarUrl,profileUrl);
                                Intent Connect = new Intent("onChatConnect");//add action
                                Bundle mBundle = new Bundle();
                                mBundle.putParcelable(PAR_KEY, currentUser);
                                Connect.putExtras(mBundle);
                                LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(Connect); 
  • Not for a broadcast. Broadcasts don't always go to the same process, they're built to be an IPC mechanism. That means the class needs to be serialized. Which means a Parsable in Android. – Gabe Sechan Jul 01 '15 at 00:09
  • so is there anyway other then broadcast in which I can send the events with object of a class? –  Jul 01 '15 at 00:13
  • Via the binder or via aidl. But neither are pretty to use. See http://stackoverflow.com/questions/10547577/how-can-a-remote-service-send-messages-to-a-bound-activity for an example of using a bound service and the binder. – Gabe Sechan Jul 01 '15 at 00:17

0 Answers0