The broadcast receiver should call a service which will start the activity. See the info below from the android developer site.
*Receiver Lifecycle* *A BroadcastReceiver object is only valid for the duration of the call to onReceive(Context, Intent)<http://developer.android.com/reference/android/content/BroadcastReceiver.html#onReceive(android.content.Context, android.content.Intent)>. Once your code returns from this function, the system considers the object to be finished and no longer active.* *This has important repercussions to what you can do in an onReceive(Context, Intent)<http://developer.android.com/reference/android/content/BroadcastReceiver.html#onReceive(android.content.Context, android.content.Intent)> implementation: anything that requires asynchronous operation is not available, because you will need to return from the function to handle the asynchronous operation, but at that point the BroadcastReceiver is no longer active and thus the system is free to kill its process before the asynchronous operation completes.* *In particular, you may not show a dialog or bind to a service from within a BroadcastReceiver. For the former, you should instead use the NotificationManager<http://developer.android.com/reference/android/app/NotificationManager.html> API. For the latter, you can use Context.startService()<http://developer.android.com/reference/android/content/Context.html#startService(android.content.Intent)> to send a command to the service* On Fri, Jul 29, 2011 at 4:35 AM, baran bartu demirci < [email protected]> wrote: > Hi, > > i want to make an application ,this application include that, when the > phone connected the network ,program will start automatically. > > > i used the below as broadcast receiver; > > /* > public class ConnectivityReceiver extends BroadcastReceiver { > > @Override > public void onReceive(Context context, Intent intent) { > Intent startupIntent= new Intent(context,networkDinleActivity.class); > startupIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); > context.startActivity(startupIntent); > > } > */ > > i used the below in the manifest.xml ; > > /* > > <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> > //is it true? > > <receiver android:name=".ConnectivityReceiver"> > > <intent-filter> > > <action android:name="android.net.wifi.STATE_CHANGE"/>// is it > true?if it wasn't,what is true? > > </intent-filter> > > </receiver> > */ > > i have tried them but it didn't work. > what is wrong ? > > thanks for advices... > > Baran > > > -- > 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 -- 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

