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 text string from HTTP Connection

I've got an app that I'm working on, and I need to call a coldfusion
URL (something like http://corpapps.company.com/STG_PhoneStart.cfm)
whose page should show just a text string (in this case a list of
departments separated with semicolons like AIS - *AA*; AUTOMATION -
*GB*; BACKSITES - *HF*;). It's been a long time since I've done any
work in java and I've never done anything with android before.

The premise is that I'll need to make three calls out to the web. One
to populate the department list, one to search the directory for a
results screen, and one to search from the results screen for a
details page. I know the logic to parse the text given on the page
after I have it as a string, that's not much of an issue. The problem
I'm having is I don't know how to connect to the pages to get the
information in the first place.

Basically, First screen is a layout with EditTexts for fname, lname,
location, phone, and a Spinner for departments (which aren't in the
searchscreen.xml, but need to be dynamic). Search button and clear
button. When you click search button, it takes the parts that have
been filled in and uses those to form the URL for the second search,
which returns another text string which I will use to make the results
page (three columns, NAME, PHONE NUMBER, LOCATION), and you can select
a person from that page, and it'll make one more call (to get more
details like email, assistant, etc.) and then use it to make the
details page.

All I need is to know how to have my Search button make the next
screen come up and connect to the URL to get the results so I can fill
the columns on the page.

Any help?

-- 

2. In app payments, how to give a user a managed item for free

Hi,

Is there any way to give a user an "item" that usually is sold using
in-app billing?
I'm using the in-app billing system to enable users to upgrade and
remove ads from the application, hence the "item" is managed. I would
like to be able to give some users this upgrade for free, how can I do
this?

I know I could ask them to pay for it and then make a refund, but I
guess that would make the "item" disappear from their owned list...



-- 

3. Custom Component : A Table grid with 2 scrollviews and one canvas.

4. Eclipse 3.6.1 Classic - ADT plugin install stuck half way

5. Gallery of pictures with zoom and recognition of gestures

6. How can I change the Font of a particular world in a string stored in a database file sql.xml

7. EAS_Prepare failed? MediaPlayer