last day (14 days later) » 

9:48 AM
0
A: Start and stop TimerTask in android

ChandrakanthDo not call methods in Event_Details_Activity class from another activities. Create a BroadCastReciever in Event_Details_Activity and in onRecieve method call starttime() and stoptime() methods. So whenever you want to call starttime() and stoptime() from outside Event_Details_Activity simply se...

 
I'm using some elements of Event_Details_Activity in my starttime() method. So I need to keep the methods in the same activity. Keeping that in mind, how to call these methods from BroadcastReceiver? @Chandrakanth
 
As I mentioned in the answer...create BroadcastReciever in the activity as inner calss...so you can call activity methods from inner class(BroadcastReciever).
 
Hi. I updated the latest code in which I used Broadcast receiver for calling the methods. But still I'm getting same error @Chandrakanth
 
Can you post your latest logcat and mention where exactly you are getting the exception
 
Done. Line 110 is the onResume method in YoutubePlayerActivity class.
 
9:48 AM
in onResume() the code is clear...It will not give ClassCastException...Once cross check your code and logcat
Hi
 
9:59 AM
I commented the whole code in onResume and onPause but still I got the same error.
 
What exception getting now?
Same ClassCastException or any other?
 
yup same error.
 
Once copy your onResume() here
 
@Override
protected void onResume() {
super.onResume();

Intent intent1 = new Intent("com.sam");
intent1.putExtra("message", "stop");
YoutubePlayerActivity.this.sendBroadcast(intent1);


}
 
Once paste the logcat
 
10:07 AM
FATAL EXCEPTION: main
Process: com.nits.londonclubnights, PID: 11899
java.lang.RuntimeException: Unable to resume activity {com.nits.londonclubnights/com.nits.londonclubnights.YoutubePlayerActivity}: java.lang.ClassCastException: com.nits.application.AppApplication cannot be cast to com.nits.londonclubnights.Event_Details_Activity
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3028)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3063)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2418)
 
In previous code you are type casting Application Context to Event_Details_Activity so it gave Class Cast Exception
But now you removed that code...So it won't give the exception
I am not getting how ClassCast Exception is comming
I am helpless
Once clean your project and try to rebuild the project
 

last day (14 days later) »