Intent broadcasting not working

by Sudeep Jha » Wed, 29 Jul 2009 20:32:25 GMT


Sponsored Links
 In an application main activity I have the following code:

  public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button button=(Button)findViewById(R.id.Button);
        button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
*            Intent intent = new Intent("com.example.broadcast");
            Intent.putExtra("example","Broadcasting ");
            sendBroadcast(intent);*
        }
    });

Here is the broadcastreceiver code:
public class CustomBroadCast extends BroadcastReceiver {
    /**
     * @see android.content.BroadcastReceiver#onReceive(Context,Intent)
     */
    @Override *
        public void onReceive(Context context, Intent intent) {
        Log.i("INFORMATION","Broadcasting message");
        String dummyText = intent.getStringExtra(**"example");
        Toast.makeText(context, dummyText , Toast.LENGTH_SHORT).show();*
    }
}

In manifest file of CustomBroadCast class apllication:
*       <receiver android:name=".CustomBroadCast">
            <intent-filter>
                <action android:name="com.example.broadcast" />
            </intent-filter>
        </receiver>*

This is not working.What I am missing here?please help.[?]

-- 
Warm Regards,
Sudeep

--~--~---------~--~----~------------~-------~--~----~



Intent broadcasting not working

by Mark Murphy » Wed, 29 Jul 2009 21:57:13 GMT


 


I don't see anything obviously wrong, so here are some things to look at:

1. Make sure you have your <receiver> in the proper place in the
manifest. It should be a child of <application> and a peer of any
<activity> or related component elements.

2. I am not certain if a Toast will work from a BroadcastReceiver. If
you are concerned that your Log statement might not be being logged, try
bumping it to warning (Log.w) or error (Log.e).

3. Check LogCat for warnings. For example, if Android cannot find your
BroadcastReceiver for some reason, you will get a warning in LogCat, not
an error.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android App Developer Training:  http://commonsware.com/training.html 

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Intent broadcasting not working

by Sudeep Jha » Thu, 30 Jul 2009 13:59:20 GMT


 Still no broadcasting.Can anybody give me an example code on broadcasting an
intent from an activity to call another application?







-- 
Warm Regards,
Sudeep

--~--~---------~--~----~------------~-------~--~----~



Intent broadcasting not working

by Desu Vinod Kumar » Thu, 30 Jul 2009 17:52:26 GMT


 i

Only Toast widget will work for broadcast reciever is it possible to show
the images or any other thing we can't place..

On Thu, Jul 30, 2009 at 11:29 AM, Sudeep Jha <sudeep.neti...@gmail.com>wrote:



--
Regards
-------------------
Desu Vinod Kumar
vinny.s...@gmail.com
09176147148

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. get the package/class name by code

hi guys,

how can I use sdk to get the package/class name of a specific apk
file,
eg: I have a test.apk, and I want to know the package name and class
name by API when I write a android program

thanks!


-- 

2. Thx to Om wilber (was:ngemis invite google wave T_T)

big thx to om wilber

untuk invite google wave nya

lg blajar cara pake nya dulu nih

#I'm Waving using Google Wave

2009/11/13 Yudith Kurniawan <kurniawan.yud...@gmail.com>:

--~--~---------~--~----~------------~-------~--~----~
=========================
Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to id-android@googlegroups.com

To request to subscribe to this group:

Click  

3. installing Android 1.6+ on headless Linux server

4. New device best practices (donut vs. eclair, etc)

5. UTF encoding of SMS

6. startForeground Backwards compatability

7. Midomi on Android