When u say SMS Receiver, u must have a SMSReceiver class as well which extends the BroadcastReceiver.
In public void onReceive(final Context context, Intent intent) method u can call your intent as simple as that. Warm Regards, *Mukesh Kumar*, Android Consultant/Freelancer, India,Hyderabad. On Wed, Dec 28, 2011 at 3:05 PM, surabhi jain <[email protected]>wrote: > hiiiiii > > I have created two activity classes in one class i have registerd receiver > and in another activity class i am simply showing image > I want to go to my activity class from broadcastreceiver and the code > which i have write in broadcastreceiver class is > > if(intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")) > { > Intent launch = new Intent(context,MyActivity.class); > intent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); > context.startActivity(launch); > } > > and error is > > 12-28 14:50:41.894: ERROR/AndroidRuntime(814): Uncaught handler: thread > main exiting due to uncaught exception > 12-28 14:50:41.953: ERROR/AndroidRuntime(814): java.lang.RuntimeException: > Unable to start receiver com.MsgDemo.MsgReceive: > android.util.AndroidRuntimeException: Calling startActivity() from outside > of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this > really what you want? > 12-28 14:50:41.953: ERROR/AndroidRuntime(814): at > android.app.ActivityThread.handleReceiver(ActivityThread.java:2646) > 12-28 14:50:41.953: ERROR/AndroidRuntime(814): at > android.app.ActivityThread.access$3100(ActivityThread.java:119) > 12-28 14:50:41.953: ERROR/AndroidRuntime(814): at > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913) > 12-28 14:50:41.953: ERROR/AndroidRuntime(814): at > android.os.Handler.dispatchMessage(Handler.java:99) > 12-28 14:50:41.953: ERROR/AndroidRuntime(814): at > android.os.Looper.loop(Looper.java:123) > 12-28 14:50:41.953: ERROR/AndroidRuntime(814): at > android.app.ActivityThread.main(ActivityThread.java:4363) > 12-28 14:50:41.953: ERROR/AndroidRuntime(814): at > java.lang.reflect.Method.invokeNative(Native Method) > 12-28 14:50:41.953: ERROR/AndroidRuntime(814): at > java.lang.reflect.Method.invoke(Method.java:521) > 12-28 14:50:41.953: ERROR/AndroidRuntime(814): at > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) > 12-28 14:50:41.953: ERROR/AndroidRuntime(814): at > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) > 12-28 14:50:41.953: ERROR/AndroidRuntime(814): at > dalvik.system.NativeStart.main(Native Method) > 12-28 14:50:41.953: ERROR/AndroidRuntime(814): Caused by: > android.util.AndroidRuntimeException: Calling startActivity() from outside > of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this > really what you want? > 12-28 14:50:41.953: ERROR/AndroidRuntime(814): at > android.app.ApplicationContext.startActivity(ApplicationContext.java:550) > 12-28 14:50:41.953: ERROR/AndroidRuntime(814): at > android.content.ContextWrapper.startActivity(ContextWrapper.java:248) > 12-28 14:50:41.953: ERROR/AndroidRuntime(814): at > android.content.ContextWrapper.startActivity(ContextWrapper.java:248) > 12-28 14:50:41.953: ERROR/AndroidRuntime(814): at > com.MsgDemo.MsgReceive.onReceive(MsgReceive.java:31) > 12-28 14:50:41.953: ERROR/AndroidRuntime(814): at > android.app.ActivityThread.handleReceiver(ActivityThread.java:2637) > 12-28 14:50:41.953: ERROR/AndroidRuntime(814): ... 10 more > > -- > 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

