Sending Broadcast Intents --> ERROR

0 Kaloyan Dragiev · December 31, 2014
Hi ! l want help .. when l run my project and type something (the code is same as  bucky in Android App Development for Beginners - 37 - Sending Broadcast Intents  ) and ERROR --> 


12-31 16:19:39.146    2298-2298/com.example.admin.intents E/AndroidRuntime? FATAL EXCEPTION: main
    Process: com.example.admin.intents, PID: 2298
    java.lang.IllegalStateException: Could not execute method of the activity
            at android.view.View$1.onClick(View.java:4007)
            at android.view.View.performClick(View.java:4756)
            at android.view.View$PerformClick.run(View.java:19749)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
     Caused by: java.lang.reflect.InvocationTargetException
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at android.view.View$1.onClick(View.java:4002)
            at android.view.View.performClick(View.java:4756)
            at android.view.View$PerformClick.run(View.java:19749)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
     Caused by: java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.EditText
            at com.example.admin.intents.Approve.onClick(Approve.java:23)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at android.view.View$1.onClick(View.java:4002)
            at android.view.View.performClick(View.java:4756)
            at android.view.View$PerformClick.run(View.java:19749)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)

Post a Reply

Replies

Oldest  Newest  Rating
0 Pere Garau Burguera · December 31, 2014
I think the error is that you're trying to cast a RelativeLayout into an EditText (That's what it says there i think). Make sure you cast the RelativeLayout correctly as a RelativeLayout, that's probably when you are referencing it by 
RelativeLayout whatever = (EditText) findViewById(R.id.whatever);

and you have to put

RelativeLayout whatever = (RelativeLayout) findViewById(R.id.whatever);


If it's not because of this, paste your code here and we will'll probably see what's going on! 
  • 1

Java / Android Development

126,566 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator