In your AndroidManifest.xml, under your receiver, you should also create an <intent-filter> with your custom action. Then create an Intent using the constructor "Intent (String action)" (by passing your custom action), and send the broadcast.
I found here a simple example which might help: http://www.androidcompetencycenter.com/2009/01/basics-of-android-part-ii-intent-receivers/ Bye, YuviDroid On Sat, Dec 4, 2010 at 1:17 PM, Peter Webb <[email protected]> wrote: > I have a wallpaper app on the market. I have almost finished a > customisation application for it, which I want to sell. Because it is > a wallpaper, I can't use a launch intent. > > I have now spent many days trying to simply pass a custom intent using > BroadcastReceiver. I can't find a single example on the net of doing > this between two different applications. In desperation I post my best > guess as to what should work, although I have tried many permutations. > Stepping through with the debugger and I find the sendBroadcast is > executed but nothing is ever received. > > Any help on where I am wrong, or to some code that I can use as an > example, may stop me going crazy: > > My sender has the following on a button click: > > Intent intent = new Intent(); > intent.setClassName("pack.name", > "pack.name.rtestactivity"); > sendBroadcast(intent); > > My receiver has the following manifest: > > <?xml version="1.0" encoding="utf-8"?> > <manifest xmlns:android="http://schemas.android.com/apk/res/android" > package="pack.name" > android:versionCode="1" > android:versionName="1.0"> > <application android:icon="@drawable/icon" android:label="@string/ > app_name"> > <activity android:name=".rtestactivity" > android:label="@string/app_name"> > <intent-filter> > <action android:name="android.intent.action.MAIN" /> > <category > android:name="android.intent.category.LAUNCHER" /> > </intent-filter> > </activity> > <receiver android:name="rtestactivity$AlarmReceiver"></receiver> > </application> > > </manifest> > > and the following Java: > > package pack.name; > import android.app.Activity; > import android.content.BroadcastReceiver; > import android.content.Context; > import android.content.Intent; > import android.os.Bundle; > import android.view.View; > import android.view.View.OnClickListener; > import android.widget.Button; > import android.widget.Toast; > > public class rtestactivity extends Activity { > /** Called when the activity is first created. */ > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > // set up a button to show mysemaphore value > final Button button = (Button) findViewById(R.id.Button01); > button.setOnClickListener(new OnClickListener() > { > public void onClick(View v) { > Toast.makeText(rtestactivity.this, mysemaphore, > Toast.LENGTH_SHORT).show(); > } > }); > > } > > public static String mysemaphore ="not received"; > > public static class AlarmReceiver extends BroadcastReceiver{ > @Override > public void onReceive(Context context, Intent intent){ > { > mysemaphore = "Received"; > } > > } > } > } > > Always the same. Whatever I do, the receiver is not called - the > debugger steps through the sendintent, but nothing seems to happen. > > I write in desperation. > > Thankyou for any help you can provide. > > > -- > 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]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- YuviDroid Check out Launch-X <http://android.yuvalsharon.net/launchx.php> (a widget to quickly access your favorite apps and contacts!) http://android.yuvalsharon.net -- 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

