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. Why is my e-mail being spammed by this group

When I set it up for 1 e-mail a day I started getting 100.  I
unsubscribed 
but the spam continues.

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

2. Feature request : Aggregate view of different calendars

Professionnals usually have an exchange account with outlook /
activesync.

Android will provide an easy access to google calendar.

Let's assume android will at some point provide both with push
technology (MS Activesync is implemented on the iphone, and google
should /*try to */ implement some push mail or calendar for its own
technology too.

The best use would be to have both on a single aggregate view. One
single app that would show at the same time
- exchange calendar
- google calendar

with the option when creating a new meeting / appointment to select if
it's a google or exchange event.

That way users could keep private their private life.. which doesn't
need to be sync'd on the company servers.. and could toggle which
calendars they want to see.. (no need to see business events when one
is on holiday).

Any comments / enhancements ?

Don't know how to get this idea to the right people.... ;)

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

3. text color won't change for TextView.setEnabled(false

4. is there a way to install back the SDK m5-rc15 after upgrading into 0.9 beta

5. More camera misery with SDK 0.9 beta

6. Instrumentation failing with classnotfound on android.test.InstrumentationTestRunner

7. Drag & Drop outside the parent ViewGroup