Usage of sendBroadcast()

Posted by Vidhya on Stack Overflow See other posts from Stack Overflow or by Vidhya
Published on 2011-02-03T06:15:02Z Indexed on 2011/02/03 7:25 UTC
Read the original article Hit count: 502

Filed under:
|
|

sendBroadcast() - Should it be called inside Activity? I am trying to call sendBroadcast() from my method of utility-class which doesn't extend Activity. I am getting compilation error as below

The method sendBroadcast(Intent) is undefined for the type MyWrapperClass MyWrapperClass.java

Here is the code snippet:

abstract class MyWrapperClass {

    public static void sendData()
         {
             Intent intent = new Intent ("com.proj.utility.mgr",null);

             intent.putExtra("example","Broadcasting "); 

            sendBroadcast(intent);

         }
    }

Is there any concept behind using sendBroadcast call inside my class. There is no issue in using sendBroadcast() inside Activity. Can someone here help me to resolve it? Or Any other suggestions are invited to return data from utility class to application asynchronously. Thanks in advance.

© Stack Overflow or respective owner

Related posts about java

Related posts about android