[android-developers] Re: Bizarre launch behavior for a "standard" launchMode Activity

2013-04-04 Thread plnelson


On Thursday, April 4, 2013 1:53:15 PM UTC-4, plnelson wrote:
>
>   ( *this is a followup to an earlier thread.  I've directed all new 
> comments there to here* )
>
> I'm trying to launch an Activity with *standard* launchMode; it launches 
> *perfectly 
> fine* when its launchMode is set to *singleInstance*. When I set it to *
> standard* nothing happens; it never gets to onCreate or onStart or 
> onResume, or the constructor or anyplace in the target Activity - I've 
> instrumented all the lifycycle events and set breakpoints.
>
> In the LogCat it shows . . . 
>
> 03-29 19:23:56.454: I/ActivityManager(119): Starting: Intent { 
> flg=0x400 cmp=com..remote/.DGraphActivity (has extras) } from pid 
> 13727
>
> … and that's all it has for DGraphActivity. What's interesting is my 
> program has lots of Activities and in all the other ones the "Starting: 
> Intent" was followed immediately by a "trying to launch..." the Activity in 
> question. But DGraphActivity had no "trying to launch" or anything else. 
> (how can I figure out why it stalls?)
>
>  My launch code looks like this . . . 
>
> if (DGraphActivity.bitmap != null) {Intent intent = new Intent(ctx, 
> DGraphActivity.class);intent.putExtra("Buttons", sButtonParam);try {  
>   ctx.startActivity(intent);}catch (Exception e)  {
> Log.e("Commands", "failed to start DGraphActivity", e);   }}
>  
>
> in the manifest . . . 
>
>  android:screenOrientation="portrait"
> android:launchMode="standard">
>
> But now I've made a* truly* *bizarre discovery*. If I try to launch it 
> TWICE, it works! I first noticed this just pressing the launch button twice 
> on my app, but it even works if I put the two calls next to each other in 
> the code!
>
> *try* {
>
> ctx.startActivity(intent);
>
> ctx.startActivity(intent); //!! investigating a weird bug
>
> }
>
>
>
>  The Logcat looks like this . . . 
>
> 04-04 13:20:05.291: I/ActivityManager(119): Starting: Intent { 
> flg=0x400 cmp=com..remote/.DGraphActivity (has extras) } from pid 
> 27067
>
> 04-04 13:20:05.291: I/ActivityManager(119): Starting: Intent { 
> flg=0x400 cmp=com..remote/.DGraphActivity (has extras) } from pid 
> 27067
>
> 04-04 13:20:05.295: D/PlyListActivity(27067): paused
>
> 04-04 13:20:05.299: W/ActivityManager(119): Trying to launch 
> com..remote/.DGraphActivity
>
> 04-04 13:20:05.302: D/PowerManagerService(119): enableUserActivity true
>
> 04-04 13:20:05.302: D/StatusBarManagerService(119): manageDisableList 
> what=0x0 pkg=android
>
> 04-04 13:20:05.306: D/DGraphActivity(27067): constructor
>
> 04-04 13:20:05.306: D/DGraphActivity(27067): created
>
> This is one of the weirdest things I've ever seen in my career as a 
> software engineer! Does anyone have any idea how to debug what's going 
> wrong here?  Thanks in advance!
>
>
>
> 

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Bizarre launch behavior for a "standard" launchMode Activity

2013-04-04 Thread plnelson
Note how the LogCat shows* two* instances of the DGraphActivity being 
started - 2 constructors, 2 onCreates.   That only happens when the two *
startActivitie*s are right next to each other.  When I was doing this by 
tapping the button twice in a row there was only one instance of 
DGraphActivity created, and there's only one instance when I do this:

ctx.startActivity(intent);
Thread.sleep(2000);
 ctx.startActivity(intent);  //!! investigating a weird bug

... Even if I wait a Really Long Time for a second instance to appear (like 
go out to lunch) a second one never happens.



>  

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Bizarre launch behavior for a "standard" launchMode Activity

2013-04-04 Thread skink


plnelson wrote:
> Note how the LogCat shows* two* instances of the DGraphActivity being
> started - 2 constructors, 2 onCreates.

try to remove *everything* from your DGraphActivity

leave onCreate with Log.d() only and see what happens

pskink

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Bizarre launch behavior for a "standard" launchMode Activity

2013-04-05 Thread plnelson

On Thursday, April 4, 2013 3:35:52 PM UTC-4, skink wrote:
>
>
>
> plnelson wrote: 
> > Note how the LogCat shows* two* instances of the DGraphActivity being 
> > started - 2 constructors, 2 onCreates. 
>
> try to remove *everything* from your DGraphActivity 
>
> leave onCreate with Log.d() only and see what happens 
>
>
Before I do that could you give me some idea why you think that might help 
or what you think it might reveal?   Keep in mind that with a 
*single*startActivity, DGraphActivity never gets created or constructed at all. 
  
So why would what's inside of it have any effect?

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Bizarre launch behavior for a "standard" launchMode Activity

2013-04-05 Thread skink


plnelson wrote:
> Before I do that could you give me some idea why you think that might help
> or what you think it might reveal?   Keep in mind that with a 
> *single*startActivity, DGraphActivity never gets created or constructed at 
> all.
> So why would what's inside of it have any effect?

because thousands of devs are starting activities in standard mode
without such problems?

pskink

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Bizarre launch behavior for a "standard" launchMode Activity

2013-04-05 Thread plnelson

OK I tried it. Here's the class ...

package com..remote;
>
> import android.app.Activity;
> import android.os.Bundle;
> import android.util.Log;
>
> public class DGraphActivity extends Activity {
> 
> @Override
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);   
> Log.d("DGraphActivity", "created");
> }   // end onCreate
>
} 


... It didn't make any difference but I still don't understand why you 
thought it would.  You can see from the LogCat I posted that Android's not 
even *trying* to launch it.It does a "starting: intent", but it never 
follows this up with a "trying to launch". If there was a compile-time 
problem inside the class it would have shown up in the build but the build 
is clean.But if there was a runtime problem inside the class how could 
this manifest itself if it's not launched?

Normally when you do a *startActivity()* Android does a series of steps 
("intent: starting", "trying to launch", etc).   So the main question in 
this thread is why Android would stop after just the first one and how do 
we get Android to tell us why? 

This problem has turned out to be a real stumper, both here and 
StackOverFlow.Does Android/Google have a support forum where actual 
Android or Google people read the postings and contribute?
 

> On Friday, April 5, 2013 8:59:23 AM UTC-4, skink wrote:
> plnelson wrote: 
> > Before I do that could you give me some idea why you think that might 
> help 
> > or what you think it might reveal?   Keep in mind that with a 
> *single*startActivity, DGraphActivity never gets created or constructed at 
> all. 
> > So why would what's inside of it have any effect? 
>
> because thousands of devs are starting activities in standard mode 
> without such problems? 
>
> pskink 
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Bizarre launch behavior for a "standard" launchMode Activity

2013-04-05 Thread skink


plnelson wrote:
> OK I tried it. Here's the class ...

hmm, really strange... what is the Context you are using?

pskink

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Bizarre launch behavior for a "standard" launchMode Activity

2013-04-05 Thread plnelson


On Friday, April 5, 2013 11:06:42 AM UTC-4, skink wrote:
>
>
>
> plnelson wrote: 
> > OK I tried it. Here's the class ... 
>
> hmm, really strange... what is the Context you are using? 
>

It's the context of the main Activity for the App.   I've tried varying its 
own launchMode but it makes no difference.   

This app is a large industrial-control application and and the class this 
is running in receives communication from a PC over a TCP connection and 
launches different Activities - approx 12, total, depending on what the PC 
says.I'm not having any trouble launching any of the other Activities, 
just this one.   Most of the other Activities are not standard launchMode.

Where does Google document the steps we can see in LogCat "starting: 
intent...", "Trying to launch..." , etc.All the documentation I see on 
the Activity Life Cycle seem to skip over those and start when the Activity 
is created.   I need to know why I'm not getting a "trying to launch" after 
the starting: intent". 

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Bizarre launch behavior for a "standard" launchMode Activity

2013-04-08 Thread plnelson
I appreciate everyone's efforts in making suggestions, but this has clearly 
stumped everyone, both here and on Stack Overflow.   

Is there a support/bugs forum read by actual Google/Android engineers I can 
ask a question like this on?Or is there a any documentation on the 
internal steps taken *between* startActivity and when the target activity 
Life Cycle steps begin? 

Right now I feel like launching an activity in Android is like putting a 
message in a bottle and throwing it in the ocean - IF it arrives at the 
other end then great.   But if it doesn't then there's no visibility or 
control over why.  We can try different bottles -  whiskey bottles or 
ketchup bottles -  or low tide or high tide -  but it seems like it's all 
guesswork. 
 

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Bizarre launch behavior for a "standard" launchMode Activity

2013-04-08 Thread skink


plnelson wrote:
> I appreciate everyone's efforts in making suggestions, but this has clearly
> stumped everyone, both here and on Stack Overflow.
>
> Is there a support/bugs forum read by actual Google/Android engineers I can
> ask a question like this on?Or is there a any documentation on the
> internal steps taken *between* startActivity and when the target activity
> Life Cycle steps begin?
>
> Right now I feel like launching an activity in Android is like putting a
> message in a bottle and throwing it in the ocean - IF it arrives at the
> other end then great.   But if it doesn't then there's no visibility or
> control over why.  We can try different bottles -  whiskey bottles or
> ketchup bottles -  or low tide or high tide -  but it seems like it's all
> guesswork.

btw did you try to start you activity using intent filter with an
action? just to make sure if it makes any difference...

pskink

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Re: Bizarre launch behavior for a "standard" launchMode Activity

2013-04-08 Thread Kristopher Micinski
I have to admit: I haven't followed your whole discussion because
you've given a very small amount of sample code.  I see that you're
trying to launch with an intent, but don't see why it could include
problems.

So if you want a comprehensive answer, please make up a small sample
project and put it somewhere: I'll try to investigate.

Given what you've said, I can try to shine some light with the
information I know up to this point.

You think that this code is weird:

(in onCreate, or some main thread method..)

ctx.startActivity(intent);
Thread.sleep(2000);

 ctx.startActivity(intent);  //!! investigating a weird bug

I would suspect that this would only fire a single intent: intents
will not start until that method has returned (message processing will
happen on that thread), and identical intents will be identified.
However, it *is* strange that if you only call startActivity once you
don't get anything happening.

I don't know if this just a simple mistake, or something going on in
the framework (I want to say a simple mistake, just because as the
platform gets older that code has fewer bugs..).  However, if you can
create a reproducible project, I'd be happy to try to find out what's
going on.

Kris

On Mon, Apr 8, 2013 at 11:28 AM, plnelson  wrote:
> I appreciate everyone's efforts in making suggestions, but this has clearly
> stumped everyone, both here and on Stack Overflow.
>
> Is there a support/bugs forum read by actual Google/Android engineers I can
> ask a question like this on?Or is there a any documentation on the
> internal steps taken between startActivity and when the target activity Life
> Cycle steps begin?
>
> Right now I feel like launching an activity in Android is like putting a
> message in a bottle and throwing it in the ocean - IF it arrives at the
> other end then great.   But if it doesn't then there's no visibility or
> control over why.  We can try different bottles -  whiskey bottles or
> ketchup bottles -  or low tide or high tide -  but it seems like it's all
> guesswork.
>
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to android-developers+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Re: Bizarre launch behavior for a "standard" launchMode Activity

2013-04-08 Thread plnelson
Coming up with a simplified example will be hard because it's a large 
industrial app with many activities and operates as a remote control for a 
manufacturing process under the control of a PC which sends commands to it 
asynchronously.  But I did get an important clue today: 

I reported that in LogCat all I got  was an "intent: starting .." and then 
nothing.But what I found out was that if I switched to another screen 
in the app the Activity would start, even if it was minutes later. *Here's 
what's going on*:  these Activities are being launched by intents in a 
separate NON-Activity class that receives communication from the PC.   They 
need a Context to start an Activity (ctx in the above code) and if the 
Context is not the one for the activity currently on the screen then 
nothing happens until that Activity comes to the fore.

So I either need a way to get the context of the Activity currently on the 
screen, or a way to start an Activity that will run regardless of the 
activity currently on the screen.  I can do the latter by setting the 
launchMode of DGraphActivity to "singleInstance" but I can't use 
singleInstance because DGraphActivity needs to fire off other activities 
and use onActivityResult to collect their results and you can't uses 
onActivityResult in a singleInstance. 

With a launchMode of "standard" I've tried using 

>   intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | 
> Intent.FLAG_ACTIVITY_NEW_TASK);
>
without success.
 

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Re: Bizarre launch behavior for a "standard" launchMode Activity

2013-04-08 Thread plnelson
OK, I've solved my problem by getting the context of the current top 
activity ( or at least the last one to get an *onResume()* ) and using that 
as my context (ctx).Now, no matter what Activity is on the screen, when 
the command comes in from the PC to display graphics it launches right 
away, even as a standard launchMode Activity.

Thank you to everyone who offered suggestions or took time to read this 
thread.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.