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. Buying a G1 in the UK

I've just had an interesting chat with someone at t-mobile UK and if you talk 
to one of thier in store sales people they can offer you some tariffs which, in 
total, work out a cheaper way to get a G1 than the advertised ones.

Al.

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

2. the pron

I have install ADT for Eclipse 3.3 (Europa),then create a Android
project.Eclipse show me a problem which tell me that : the selected
wizard could not strated .Reason:Plug-in com.android.ide.eclipse.adt
was unable to load class
com.android.ide.eclipse.adt.project.internal.NewProjectWizard. who can
help me?
thanks
tom

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

3. I got banned at android-internals group ?

4. How to add a ImageButton from layout(xml)

5. I want to make an application for the android, how can I see the current list of android applications? I dont have a G1

6. Who else is thinking this...

7. Issues with GPS application on the actual G1 phone