Google Play Multiplayer Room not Creating - google-play-services

I have trying to follow the ButtonClicker example. My main activity extends AndroidApplication because I am working with libgdx but I cannot seem to create the room. The code stops after I call "Games.RealTimeMultiplayer.create(getApiClient(), roomBuilder.build())"
I think my problem is somewhere with the getApiClient()
Would love some help understanding what am I doing wrong
See code:
in my OnCreate()
mHelper = new GameHelper(this, 2);
When I use anything else other than 2 for the 2nd param the game does not even load
protected GoogleApiClient getApiClient() {
Log.d(TAG, "getApiClient() " + mHelper.getApiClient());
return mHelper.getApiClient();
}
calling quick game
private void startQuickGame(){
Log.d(TAG, "StartQuickGame()");
//1st param is Minimum players, 2nd param is maximum and 3rd is exclusivebitmask???
Bundle am = RoomConfig.createAutoMatchCriteria(1, 4, 0);
RoomConfig.Builder roomBuilder = RoomConfig.builder(this);
roomBuilder.setMessageReceivedListener(this);
roomBuilder.setRoomStatusUpdateListener(this);
roomBuilder.setAutoMatchCriteria(am);
Games.RealTimeMultiplayer.create(getApiClient(), roomBuilder.build());
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Log.d(TAG, " startQuickGame()" + "createRoom called");
}
I tried creating the Game Helper object using "GameHelper.CLIENT_ALL" and I got the following error:
03-11 09:34:24.083: E/MoreInfoHPW_ViewGroup(15954): Parent view is not a TextView
03-11 09:34:24.083: D/Launcher(1234): onTrimMemory. Level: 20
03-11 09:34:24.083: D/STATUSBAR-IconMerger(950): checkOverflow(1368), More:false, Req:false Child:6
03-11 09:34:24.103: W/PopupManager(15954): You have not specified a View to use as content view for popups. Falling back to the Activity content view which may not work properly in future versions of the API. Use setViewForPopups() to set your content view.
03-11 09:34:24.103: D/AndroidRuntime(15954): Shutting down VM
03-11 09:34:24.103: W/dalvikvm(15954): threadid=1: thread exiting with uncaught exception (group=0x41b13898)
03-11 09:34:24.103: E/AndroidRuntime(15954): FATAL EXCEPTION: main
03-11 09:34:24.103: E/AndroidRuntime(15954): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.crazyEagle/com.crazyEagle.MainActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
03-11 09:34:24.103: E/AndroidRuntime(15954): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
03-11 09:34:24.103: E/AndroidRuntime(15954): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
03-11 09:34:24.103: E/AndroidRuntime(15954): at android.app.ActivityThread.access$700(ActivityThread.java:159)
03-11 09:34:24.103: E/AndroidRuntime(15954): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
03-11 09:34:24.103: E/AndroidRuntime(15954): at android.os.Handler.dispatchMessage(Handler.java:99)
03-11 09:34:24.103: E/AndroidRuntime(15954): at android.os.Looper.loop(Looper.java:137)
03-11 09:34:24.103: E/AndroidRuntime(15954): at android.app.ActivityThread.main(ActivityThread.java:5419)
03-11 09:34:24.103: E/AndroidRuntime(15954): at java.lang.reflect.Method.invokeNative(Native Method)
03-11 09:34:24.103: E/AndroidRuntime(15954): at java.lang.reflect.Method.invoke(Method.java:525)
03-11 09:34:24.103: E/AndroidRuntime(15954): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
03-11 09:34:24.103: E/AndroidRuntime(15954): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
03-11 09:34:24.103: E/AndroidRuntime(15954): at dalvik.system.NativeStart.main(Native Method)
03-11 09:34:24.103: E/AndroidRuntime(15954): Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
03-11 09:34:24.103: E/AndroidRuntime(15954): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:320)
03-11 09:34:24.103: E/AndroidRuntime(15954): at android.app.Activity.requestWindowFeature(Activity.java:3338)
03-11 09:34:24.103: E/AndroidRuntime(15954): at com.crazyEagle.MainActivity.onCreate(MainActivity.java:150)
03-11 09:34:24.103: E/AndroidRuntime(15954): at android.app.Activity.performCreate(Activity.java:5372)
03-11 09:34:24.103: E/AndroidRuntime(15954): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
03-11 09:34:24.103: E/AndroidRuntime(15954): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
03-11 09:34:24.103: E/AndroidRuntime(15954): ... 11 more

Was missing in the manifest
meta-data android:value="#string/app_id" android:name="com.google.android.gms.appstate.APP_ID"

Related

Failure of an application in Weblogic 12

I have deployed a GWT application in Weblogic 10. It's working fine, but when I deploy it in Weblogic 12, the RPC call is failing showing an error "Failed while dispatching RPC call".
This is the error we are getting, but we have no final classes:
java.lang.VerifyError: Cannot inherit from final class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:385)
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:344)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:302)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:64)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:180)
at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:43)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at com.google.gwt.user.server.rpc.SerializationPolicyLoader.loadFromStream(SerializationPolicyLoader.java:196)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.loadSerializationPolicy(RemoteServiceServlet.java:93)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.doGetSerializationPolicy(RemoteServiceServlet.java:352)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.getSerializationPolicy(RemoteServiceServlet.java:206)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.prepareToRead(ServerSerializationStreamReader.java:505)
at com.google.gwt.user.server.rpc.RPC.decodeRequest(RPC.java:240)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:263)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:305)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:751)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:238)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3376)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3346)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2230)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2146)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2124)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1564)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:312)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:264)
error:
The call failed on server, see the Server logs (500 error)

java.lang.NullPointerException when using Facebook Module on Android

Using the latest Facebook (v2.12) module with Trigger.io (platform v2.2.14), attempting to "Login with Facebook" causes the app to crash and shows the following in the log:
07-20 12:10:46.834: E/AndroidRuntime(7013): FATAL EXCEPTION: main
07-20 12:10:46.834: E/AndroidRuntime(7013): Process: com.myapp, PID: 7013
07-20 12:10:46.834: E/AndroidRuntime(7013): java.lang.RuntimeException: Unable to resume activity {com.myapp/com.facebook.LoginActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setVisibility(int)' on a null object reference
07-20 12:10:46.834: E/AndroidRuntime(7013): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2986)
07-20 12:10:46.834: E/AndroidRuntime(7013): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3017)
07-20 12:10:46.834: E/AndroidRuntime(7013): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
07-20 12:10:46.834: E/AndroidRuntime(7013): at android.app.ActivityThread.access$800(ActivityThread.java:151)
07-20 12:10:46.834: E/AndroidRuntime(7013): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
07-20 12:10:46.834: E/AndroidRuntime(7013): at android.os.Handler.dispatchMessage(Handler.java:102)
07-20 12:10:46.834: E/AndroidRuntime(7013): at android.os.Looper.loop(Looper.java:135)
07-20 12:10:46.834: E/AndroidRuntime(7013): at android.app.ActivityThread.main(ActivityThread.java:5254)
07-20 12:10:46.834: E/AndroidRuntime(7013): at java.lang.reflect.Method.invoke(Native Method)
07-20 12:10:46.834: E/AndroidRuntime(7013): at java.lang.reflect.Method.invoke(Method.java:372)
07-20 12:10:46.834: E/AndroidRuntime(7013): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
07-20 12:10:46.834: E/AndroidRuntime(7013): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
07-20 12:10:46.834: E/AndroidRuntime(7013): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setVisibility(int)' on a null object reference
07-20 12:10:46.834: E/AndroidRuntime(7013): at com.facebook.LoginActivity$2.onBackgroundProcessingStarted(Unknown Source)
07-20 12:10:46.834: E/AndroidRuntime(7013): at com.facebook.AuthorizationClient.notifyBackgroundProcessingStart(Unknown Source)
07-20 12:10:46.834: E/AndroidRuntime(7013): at com.facebook.AuthorizationClient.access$2(Unknown Source)
07-20 12:10:46.834: E/AndroidRuntime(7013): at com.facebook.AuthorizationClient$GetTokenAuthHandler.tryAuthorize(Unknown Source)
07-20 12:10:46.834: E/AndroidRuntime(7013): at com.facebook.AuthorizationClient.tryCurrentHandler(Unknown Source)
07-20 12:10:46.834: E/AndroidRuntime(7013): at com.facebook.AuthorizationClient.tryNextHandler(Unknown Source)
07-20 12:10:46.834: E/AndroidRuntime(7013): at com.facebook.AuthorizationClient.authorize(Unknown Source)
07-20 12:10:46.834: E/AndroidRuntime(7013): at com.facebook.AuthorizationClient.startOrContinueAuth(Unknown Source)
07-20 12:10:46.834: E/AndroidRuntime(7013): at com.facebook.LoginActivity.onResume(Unknown Source)
07-20 12:10:46.834: E/AndroidRuntime(7013): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1257)
07-20 12:10:46.834: E/AndroidRuntime(7013): at android.app.Activity.performResume(Activity.java:6076)
07-20 12:10:46.834: E/AndroidRuntime(7013): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2975)
I have double-checked App ID, Key Hash, and relevant settings on Facebook, but the error keeps occurring. Has anyone experienced the same issue and how did you fix it?
Trigger.io Facebook Module v2.13 fixed the login issues on Android.

RecycleView getting NullPointerException for Android support v7 recycleview

java.lang.NullPointerException at
android.support.v4.view.ViewCompat$ICSViewCompatImpl.setAccessibilityDelegate(ViewCompat.java:834)
at
android.support.v4.view.ViewCompat.setAccessibilityDelegate(ViewCompat.java:1169)
at
android.support.v7.widget.RecyclerView$Recycler.addViewHolderToRecycledViewPool(RecyclerView.java:3900)
at
android.support.v7.widget.RecyclerView$Recycler.recycleCachedViewAt(RecyclerView.java:3843)
at
android.support.v7.widget.RecyclerView$Recycler.recycleViewHolderInternal(RecyclerView.java:3880)
at
android.support.v7.widget.RecyclerView$Recycler.recycleView(RecyclerView.java:3804)
at
android.support.v7.widget.RecyclerView$LayoutManager.removeAndRecycleViewAt(RecyclerView.java:5529)
at
android.support.v7.widget.LinearLayoutManager.recycleChildren(LinearLayoutManager.java:1139)
at
android.support.v7.widget.LinearLayoutManager.recycleViewsFromStart(LinearLayoutManager.java:1180)
at
android.support.v7.widget.LinearLayoutManager.recycleByLayoutState(LinearLayoutManager.java:1244)
at
android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1268)
at
android.support.v7.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1102)
at
android.support.v7.widget.LinearLayoutManager.scrollVerticallyBy(LinearLayoutManager.java:959)
at
android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:3062)
at
android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574) at
android.view.Choreographer.doFrame(Choreographer.java:543) at
android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733) at
android.os.Handler.dispatchMessage(Handler.java:95) at
android.os.Looper.loop(Looper.java:136) at
android.app.ActivityThread.main(ActivityThread.java:5017) at
java.lang.reflect.Method.invokeNative(Native Method) at
java.lang.reflect.Method.invoke(Method.java:515) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at
dalvik.system.NativeStart.main(Native Method)

Spinner using ArrayAdapter, crash the app

I'm trying to make a spinner with an ArrayAdapter but the application crash, i didn't find the solution on other post so i hope you can help me :).
My string array in res/values/strings.xml
<string-array name="functionF">
<item>Lucas</item>
<item>Paul</item>
</string-array>
My spinner_layout in res/layout/spinner_layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Spinner
android:id="#+id/function_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
My code
private Spinner spinnerFunction;
spinnerFunction = (Spinner) findViewById(R.id.function_spinner);
ArrayAdapter<CharSequence> adapter1 = ArrayAdapter.createFromResource(this,R.array.functionF, R.layout.spinner_layout);
adapter1.setDropDownViewResource(R.layout.spinner_layout);
spinnerFunction.setAdapter(adapter1);
And here is crash error:
07-21 05:58:55.296: E/AndroidRuntime(2544): FATAL EXCEPTION: main
07-21 05:58:55.296: E/AndroidRuntime(2544): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ben.wizzer/com.ben.wizzer.Friends}: java.lang.NullPointerException
07-21 05:58:55.296: E/AndroidRuntime(2544): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
07-21 05:58:55.296: E/AndroidRuntime(2544): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
07-21 05:58:55.296: E/AndroidRuntime(2544): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-21 05:58:55.296: E/AndroidRuntime(2544): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
07-21 05:58:55.296: E/AndroidRuntime(2544): at android.os.Handler.dispatchMessage(Handler.java:99)
07-21 05:58:55.296: E/AndroidRuntime(2544): at android.os.Looper.loop(Looper.java:137)
07-21 05:58:55.296: E/AndroidRuntime(2544): at android.app.ActivityThread.main(ActivityThread.java:5103)
07-21 05:58:55.296: E/AndroidRuntime(2544): at java.lang.reflect.Method.invokeNative(Native Method)
07-21 05:58:55.296: E/AndroidRuntime(2544): at java.lang.reflect.Method.invoke(Method.java:525)
07-21 05:58:55.296: E/AndroidRuntime(2544): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
07-21 05:58:55.296: E/AndroidRuntime(2544): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-21 05:58:55.296: E/AndroidRuntime(2544): at dalvik.system.NativeStart.main(Native Method)
07-21 05:58:55.296: E/AndroidRuntime(2544): Caused by: java.lang.NullPointerException
07-21 05:58:55.296: E/AndroidRuntime(2544): at android.widget.ArrayAdapter.createFromResource(ArrayAdapter.java:430)
07-21 05:58:55.296: E/AndroidRuntime(2544): at com.ben.wizzer.Friends.onCreate(Friends.java:174)
07-21 05:58:55.296: E/AndroidRuntime(2544): at android.app.Activity.performCreate(Activity.java:5133)
07-21 05:58:55.296: E/AndroidRuntime(2544): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-21 05:58:55.296: E/AndroidRuntime(2544): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
07-21 05:58:55.296: E/AndroidRuntime(2544): ... 11 more
your spinner layout should be only TextView like this:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:padding="10dp"/>
the TextView layout it's for the string array but you can use default android layou:
String [] strArr = getResources().getStringArray(R.array.functionF);
ArrayAdapter<String> adapter1 = new ArrayAdapter<Categories>(getActivity(),android.R.layout.simple_list_item_1,strArr);
spinnerFunction.setAdapter(categoriesAdapter);
if you inside a fragment, use getActivity().getResources().getStringArray(R.array.functionF);

Without sending calendar obj, it will work fine.. Then How to pass Calendar object from one activity to another?

we can pass String as
Intent returnIntent = new Intent();
returnIntent.putExtra("SelectedRadio", selectedRadio);
But if I want to pass Calendar object then how to pass it from one activity
to another?
Thanks in advance.
This is my First Activity:
public class MyCalendar extends Activity {
public Calendar myCal;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_calendar);
goCal= (ImageButton)findViewById(R.id.imageButton1);
myCal = Calendar.getInstance();
goCal.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Intent i = new Intent(MyCalendar.this, MainActivity.class);
i.putExtra("calendar", myCal);
startActivity(i);
});
}
}
This is my second Activity:
public class MainActivity extends Activity {
Intent myIntent;
Calendar today = (Calendar) myIntent.getExtras().getSerializable("calendar");
...
}
what is my fault. Why my app closed when i click goCal button. pls help me.. I am a new one..
my logcat:
01-09 18:55:50.338: W/dalvikvm(4252): threadid=1: thread exiting with uncaught exception (group=0xb5f41288)
01-09 18:55:50.338: E/AndroidRuntime(4252): FATAL EXCEPTION: main
01-09 18:55:50.338: E/AndroidRuntime(4252): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.mycalendar/com.example.mycalendar.MainActivity}: java.lang.NullPointerException
01-09 18:55:50.338: E/AndroidRuntime(4252): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
01-09 18:55:50.338: E/AndroidRuntime(4252): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
01-09 18:55:50.338: E/AndroidRuntime(4252): at android.app.ActivityThread.access$600(ActivityThread.java:130)
01-09 18:55:50.338: E/AndroidRuntime(4252): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
01-09 18:55:50.338: E/AndroidRuntime(4252): at android.os.Handler.dispatchMessage(Handler.java:99)
01-09 18:55:50.338: E/AndroidRuntime(4252): at android.os.Looper.loop(Looper.java:137)
01-09 18:55:50.338: E/AndroidRuntime(4252): at android.app.ActivityThread.main(ActivityThread.java:4745)
01-09 18:55:50.338: E/AndroidRuntime(4252): at java.lang.reflect.Method.invokeNative(Native Method)
01-09 18:55:50.338: E/AndroidRuntime(4252): at java.lang.reflect.Method.invoke(Method.java:511)
01-09 18:55:50.338: E/AndroidRuntime(4252): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
01-09 18:55:50.338: E/AndroidRuntime(4252): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
01-09 18:55:50.338: E/AndroidRuntime(4252): at dalvik.system.NativeStart.main(Native Method)
01-09 18:55:50.338: E/AndroidRuntime(4252): Caused by: java.lang.NullPointerException
01-09 18:55:50.338: E/AndroidRuntime(4252): at com.example.mycalendar.MainActivity.<init>(MainActivity.java:44)
01-09 18:55:50.338: E/AndroidRuntime(4252): at java.lang.Class.newInstanceImpl(Native Method)
01-09 18:55:50.338: E/AndroidRuntime(4252): at java.lang.Class.newInstance(Class.java:1319)
01-09 18:55:50.338: E/AndroidRuntime(4252): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
01-09 18:55:50.338: E/AndroidRuntime(4252): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
01-09 18:55:50.338: E/AndroidRuntime(4252): ... 11 more
Without sending calendar obj, it will work fine.. Then How to pass Calendar object from one activity to another?
we know Calander implements Serializable interface so, you can send it as a extra in the intent.
Intent i=new Intent(context,Home.class);
Calendar c=Calendar.getInstance();
i.putExtra("calobject", c);
startActivity(i);
and you can get it using this code
Calendar cal=(Calendar) getIntent().getSerializableExtra("calobject");
Here is the screenshot of debugged code it goes smoothly without any exception
I hope this will help you
Since Calendar implements Serializable you can simply do the following:
Calendar cal;
<calendar initialization>
intent.putExtra("calendar", cal);
Then for retrieving:
Calendar cal;
cal = (Calendar) intent.getSerializableExtra("calendar");