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

On Wed, Jul 29, 2009 at 7:26 PM, Mark Murphy <[email protected]>wrote:

>
> Sudeep Jha wrote:
> > 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.
>
> 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
>
> >
>


-- 
Warm Regards,
Sudeep

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to