I too am having an issue attempting to launch an external application
from within my apps broadcastreceiver.
Here is the error:
ERROR/AndroidRuntime(19535): FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start receiver
com.example.InterceptorBroadcastReceiver:
android.content.ActivityNotFoundException: No Activity found to handle
Intent { act=packageName flg=0x10000000 }
Here is code causing error:
Intent GVIntent = new Intent("packageName");
GVIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(GVIntent);
Here it is defined in manifest:
<receiver android:name = "InterceptorBroadcastReceiver">
<intent-filter>
<action android:name="packageName" />
Any help or insight would be appreciated.
On Jun 9, 11:34 am, Dianne Hackborn <[email protected]> wrote:
> You are using hand-written constants all over the place. The SDK has a
> constant for the main action -- Intent.ACTION_MAIN. There are Intent and
> ComponentName constructors to build references to activities through the
> Context and their Class.
>
> You don't even need to use ACTION_MAIN if you are just explicitly starting
> one of your components.
>
> If you are using getApplication(), then this code will work the same way no
> matter where you do it from -- Activity, Service, or Receiver.
>
> There is nothing preventing you from starting an activity from any of these
> places, you just need to set Intent.FLAG_ACTIVITY_NEW_TASK if you aren't
> launching the activity from an existing activity (since without an activity
> you don't have an existing task to launch in to).
>
> It would help if you gave more information -- what errors you are seeing in
> the log etc.
>
>
>
>
>
>
>
>
>
> On Thu, Jun 9, 2011 at 10:41 AM, Marc <[email protected]> wrote:
> > Hello folks,
>
> > after googling all the day, I have solution to actually start an
> > external activity from a receiver.
> > In the end I added a service to the package, so the receiver starts
> > the service and the service should start the activity. Of course that
> > doesn't sound very efficient at all, but in addition to this it
> > doesn't work either. Thats my code from the service:
>
> > public void onCreate() {
> > super.onCreate();
> > Intent i = new Intent("android.intent.action.MAIN");
> > ComponentName n = new
> > ComponentName("com.schwimmer.android.carmode",
> > "com.schwimmer.android.carmode.ToggleCarMode");
> > i.setComponent(n);
> > i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
> > getApplication().startActivity(i);
> > //this.stopSelf();
>
> > If I put this code into an activity and start it wit
> > this.startActivity() it works like a charm. But not if it is put into
> > the receiver or server.
>
> > Do you have any idea how to fix that?
>
> > Thanks!
> > Marc
>
> > --
> > 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
>
> --
> Dianne Hackborn
> Android framework engineer
> [email protected]
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails. All such
> questions should be posted on public forums, where I and others can see and
> answer them.
--
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