Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Using startActivity( intent ) multiple times, fails.
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mark Jawdoszak  
View profile   Translate to Translated (View Original)
 More options Aug 23 2012, 10:16 am
From: Mark Jawdoszak <evilja...@gmail.com>
Date: Thu, 23 Aug 2012 07:16:05 -0700 (PDT)
Local: Thurs, Aug 23 2012 10:16 am
Subject: Using startActivity( intent ) multiple times, fails.

I have an intent that starts the default Android mail client:

Intent emailIntent = this.getPackageManager().getLaunchIntentForPackage( "com.android.email" );
this.startActivity( emailIntent );

Very simple stuff, and it fires off the Email client, from an "Import from Email" button in my app.

My application is also registered with an <intent-filter> to open PDF files.
So, if I use the above Intent to open up the Email client, find an email with a PDF attachment, download it, launch it, select my application from the chooser... then everything loads great.

Now if I hit my "Import from Email" button again, the intent runs, but the Email client is never brought into the foreground.

Am I missing something when using startActivity() to (re)launch the correct app?
I have tried checking if the intent is OK by following this http://developer.android.com/training/basics/intents/sending.html#Verify but it always returns true (and that makes sense, as it can find the Application, but it's just not bringing it to the foreground).

I have also tried using startActivityForResult(), but as explained in the Android docs, this fires off a "cancel" immediately, because the Activity is not Explicit, but Implicit (thought I'd try it, just in case).

I feel like I'm missing something, a step, a call to something... or have I hit upon some strange loop that works in one case, but cannot keep looping?  Any help/pointers would be greatly appreciated!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Justin Anderson  
View profile   Translate to Translated (View Original)
 More options Aug 24 2012, 1:29 pm
From: Justin Anderson <magouyaw...@gmail.com>
Date: Fri, 24 Aug 2012 11:29:30 -0600
Local: Fri, Aug 24 2012 1:29 pm
Subject: Re: [android-developers] Using startActivity( intent ) multiple times, fails.

Does this help?
http://developer.android.com/reference/android/content/Intent.html#FL...

Also, why are you restricting the user to a specific email program
("com.android.email")?  That doesn't follow good Android practices...

Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dianne Hackborn  
View profile   Translate to Translated (View Original)
 More options Aug 24 2012, 2:41 pm
From: Dianne Hackborn <hack...@android.com>
Date: Fri, 24 Aug 2012 11:41:13 -0700
Local: Fri, Aug 24 2012 2:41 pm
Subject: Re: [android-developers] Using startActivity( intent ) multiple times, fails.

This is wrong in a number of ways:

    getLaunchIntentForPackage( "com.android.email" );

First, "com.android.email" is not an API.  That is the internal identifier
for the current e-mail application that is part of AOSP; there is *no*
guarantee that such a thing will ever exist on the device.

Second, more specific to your issue here, getLaunchIntentForPackage()
returns a *launch* intent, for use in semantics like an app launcher.  What
you are asking for is not an app launcher; you want to run flow as part of
your own task, not launch something different.  In particular, what this
Intent will do is bring the current e-mail app to the foreground *in
whatever state it was last in*.  The user may have been in the middle of
composing a message, viewing something, etc.  It isn't saying to bring them
to the list of e-mail messages for them to import something.

One other thing, when you say startActivityForResult() is not working, this
is not because of an explicit vs. implicit Intent; this is because part of
what getLaunchIntentForPackage() does is set FLAG_ACTIVITY_NEW_TASK, which
says to launch the Intent as a separate task from yours (bringing an
existing task to the foreground etc), which is central to the semantics of
this being for app launchers not in-task UI flow.

--
Dianne Hackborn
Android framework engineer
hack...@android.com

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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Jawdoszak  
View profile  
 More options Aug 28 2012, 9:42 am
From: Mark Jawdoszak <evilja...@gmail.com>
Date: Tue, 28 Aug 2012 06:42:09 -0700 (PDT)
Local: Tues, Aug 28 2012 9:42 am
Subject: Re: [android-developers] Using startActivity( intent ) multiple times, fails.

I think this may well do the trick!
Just when you think you've scoured the docs looking for the right answer,
someone else goes and finds it for you :-)

And the specific email app is what our client wants.
Mind you, a chooser would be a better approach and are used elsewhere.
 Will see about convincing them of this, instead.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Jawdoszak  
View profile  
 More options Aug 28 2012, 9:47 am
From: Mark Jawdoszak <evilja...@gmail.com>
Date: Tue, 28 Aug 2012 06:47:04 -0700 (PDT)
Local: Tues, Aug 28 2012 9:47 am
Subject: Re: [android-developers] Using startActivity( intent ) multiple times, fails.

Fantastic response, thanks!

I knew I was missing something... turns out it's not just *one* thing I was
missing, but a whole host of them.

As I said in the other post, this was the decision made by the client, but
would look to (and rather!) invoke a chooser for mail applications.

With regards to the launching Intent, I'm clearly missing something as to
the best approach for this, or at least, missing an understanding of the
mechanisms Android employs in order to launch this.  We only wanted to
launch the Email client, be able to browse/check this, download some files
and launch our application again.  Is there actually a better approach?
 From what you're saying, I'm almost certainly doing it wrong - but am a
little stumped as to the *right* way.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »