[android-developers] Can't Change Android CalendarView to another month

2016-06-10 Thread plnelson
 

Android introduced a CalendarView back in in API 11. I've implemented it in 
my app and it seems to work fine in the sense that it displays a perfectly 
normal-looking whole-month calendar and I can select a date and it triggers 
the appropriate event and I can read the selected date in my code with no 
problem. 

[image: screen shot of my CalendarView]  

*But* I can't advance it out of the current month! The documentation says 

*A user can select a date by taping on it and can scroll and fling the 
calendar to a desired date.*

(the "taping" appears in the documentation; I assume it's a typo for 
"tapping" )


I've tried flinging, swiping, scrolling and nothing happens. Is there 
something I need to do to enable this feature?


My XML looks like this:


[android-developers] Two newbie Android Studio Questions . . .

2016-05-19 Thread plnelson


*1.*  I just installed the latest version of Android Studio (2.1.1) on my 
PC (Win 7) and I'm learning how to use it. One thing all the other IDE's 
I've used (e.g., Visual Studio, Eclipse, etc) have is a window that lists 
the compiler errors and warnings and you can click on the items and it 
takes you to them in the source editor.  The only place I've found in 
Android Studio that shows errors and warnings is the Gradle Console but 
warnings and errors are embedded in lots of other Gradle output and you 
can't click on them to be taken to the source code in an editor.   Does 
Android Studio have a compiler output panel that links to the source?


*2.*   Does Android Studio have a GUI for setting the things that go in 
*.gradle* files or does everything have to be done by hand-editing? If the 
latter, does Android Studio have a *gradle*-aware source editor that can 
flag syntax errors, etc?


Thanks in advance.



-- 
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.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/2dba-147e-410b-b4c4-6c7eef77f42e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Finding Build Errors in Android Studio . . .

2014-12-29 Thread plnelson
I just installed Android Studio 1.01 and I'm getting up to speed on it. In 
my Hello Android app I deliberately introduced a compiler error to see 
how that's handled.

The development environments I've used (Visual Studio, Eclipse) have a 
window which displays errors and warnings after a build, and you can click 
on the individual errors or warning and it will take you to that spot in 
the source code in the editor. Where is this feature in Android Studio?

The Gradle Console displays compiler error details but it's just dumb text 
- you can't click on the item to be taken there in the editor. The Event 
Log also indicates when errors occurred but it's also just dumb text.

Also: where do I set the warning levels (i.e., what things I want to be 
warned about) for the compiler?

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/d/optout.


[android-developers] Re: Finding Build Errors in Android Studio . . .

2014-12-29 Thread plnelson
  (... is there any way to EDIT these posts afterwards to add new 
information of discoveries?  )

  I've noticed that my View  Tool Window  Messages is grayed out.   
Since the Messages window is one place that errors are displayed  why is 
mine grayed 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/d/optout.


Re: [android-developers] Re: WrongThread exception - how to analyze/debug?

2014-05-23 Thread plnelson


On Wednesday, May 21, 2014 12:23:32 PM UTC-4, Kostya Vasilyev wrote:



 Is there more to the message? I grepped the base framework, and came up 
 with these:


The entire message is CalledFromWrongThreadException: Only the original 
thread that created a view hierarchy can touch its views 

And it's widely discussed on places like Stack Overflow but the focus of 
the dicscussions is always on fixing the bug, whereas I'm posting this to 
the Google group instead of Stack Overflo0w because I want to *understand*what 
it actually 
*means*.   What do they mean by the wrong thread?   If the same thread 
(based on the debugger and trace) is accessing it when it generates the 
exception and when it doesn't, how does that thread become the wrong 
thread?   Where does Google document its exceptions?  

*And what does the Eclipse debugger thread nomenclature ( Thread x[ 
Thread-y] ) mean?*

 The Eclipse debugger seems to refer to a thread 9 and a thread 10.   What 
 does the debugger mean when it displays it that way?


 They're just thread ids (the x) and auto-generated thread names.


Yes, I know, but why are there *two* of them on one line?  That's my 
question.  Normally I see one TID per line, so what is Eclipse telling us 
when it uses *Thread x[ Thread-y] syntax?*




-- 
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/d/optout.


[android-developers] Re: WrongThread exception - how to analyze/debug?

2014-05-21 Thread plnelson
On Tuesday, May 20, 2014 11:51:35 PM UTC-4, Jonathan S wrote:

 Can you copy and paste code in the *MyRemoteActivity class?*


 It's 700 lines of (mostly proprietary) code, so no I don't think that 
would be practical.Anyway,* my questions are generic Android questions*; 
they're not specific to the code:   I'm not asking for anyone to debug this 
for me; I'm just trying to understand more so I can debug it myself.

1. * If it's the wrong thread then why does the stack trace show the same 
thread in the cases where it crashes and where it doesn't?* 
...in other words what does Android mean by wrong thread?  If the 
debugger shows it executing in the same thread when it's not crashing as 
when it lands in the catch block with the wrong thread then what exactly 
do they mean by wrong thread?

*And what does the Eclipse debugger thread nomenclature ( Thread x[ 
Thread-y] ) mean?*
The Eclipse debugger seems to refer to a thread 9 and a thread 10.   What 
does the debugger mean when it displays it that way?

*What are some good strategies for analyzing wrong thread bugs? *  
Just that -  what tools or strategies are recommended to see what code is 
executing in which threads - how do experienced Android programmers debug 
these kinds of exceptions?

 

 On Tuesday, May 20, 2014 4:17:16 PM UTC-4, plnelson wrote:

 I have a multi-threaded Android app. One thread wakes up periodically on 
 a timer and exchanges information over WiFi with a remote device and the 
 other one is the main thread that handles all the usual View stuff.

 Lately I've been getting a Called from Wrong Thread Exception in a 
 catch block in the remote handler thread.

 If I set a breakpoint in the remote handler code, when it's NOT crashing, 
 the stack trace in the Eclipse debugger says

 *Thread[ 9 Thread-10] (Suspended breakpoint at line 600 in 
 MyRemoteActivity)*

 But if I set a breakpoint in my catch-block when it crashes it names the 
 same threads, i.e.,

 *Thread[ 9 Thread-10] (Suspended breakpoint at line 605 in 
 MyRemoteActivity)*

 (... different line number because it's the catch-block which is a few 
 lines down.)

 My question: If it's the wrong thread then why does the stack trace show 
 the same thread in the cases where it crashes and where it doesn't? And 
 what does the Eclipse debugger thread nomenclature ( Thread x[ Thread-y] 
 ) mean? What are some good strategies for analyzing wrong thread bugs?   
 
 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/d/optout.


[android-developers] WrongThread exception - how to analyze/debug?

2014-05-20 Thread plnelson
I have a multi-threaded Android app. One thread wakes up periodically on a 
timer and exchanges information over WiFi with a remote device and the 
other one is the main thread that handles all the usual View stuff.

Lately I've been getting a Called from Wrong Thread Exception in a catch 
block in the remote handler thread.

If I set a breakpoint in the remote handler code, when it's NOT crashing, 
the stack trace in the Eclipse debugger says

*Thread[ 9 Thread-10] (Suspended breakpoint at line 600 in 
MyRemoteActivity)*

But if I set a breakpoint in my catch-block when it crashes it names the 
same threads, i.e.,

*Thread[ 9 Thread-10] (Suspended breakpoint at line 605 in 
MyRemoteActivity)*

(... different line number because it's the catch-block which is a few 
lines down.)

My question: If it's the wrong thread then why does the stack trace show 
the same thread in the cases where it crashes and where it doesn't? And 
what does the Eclipse debugger thread nomenclature ( Thread x[ Thread-y] 
) mean? What are some good strategies for analyzing wrong thread bugs?   

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/d/optout.


[android-developers] Re: ListView getCount is wrong - how do I reset it?

2014-05-19 Thread plnelson


It's public and static because the method in the ListActivity that calls it 
is static.   So if it wasn't static it would generate a compile-time error 
that a static method can't refence a non-static object.   The ListActivity 
method is static is that way because that's how the original program was 
architected and I don't have the authority to change the architecture.

But why does it matter?Why can't the size of a ListView be reset if 
it's static?


On Saturday, May 17, 2014 4:11:48 AM UTC-4, Doug wrote:



 On Friday, May 16, 2014 11:58:17 AM UTC-7, plnelson wrote:

 ...In MyListActivity, which is a ListActivity . . .

 public static ListView lv;   // my ListView in the code


 Why is this public and static?
  

 ...the data source is an ArrayList called listItems. The first time 
 around it has 12 items in it; later I clear it and add in 6 items. (see 
 below)

 public static ArrayListStringlistItems=new ArrayListString();


 Why is this public and static?
  

 ... in my adapter, which is a BaseAdapter, my override of getCount() 
 looks like this. After shrinking listItems to 6 it correctly returns 6.

 @Override
 public int getCount() {
 return listItems.size();
 }

 ... To shrink my dataset to 6 I first do a

 listItems.clear();
 lv.invalidate();   // my (failed) attempt to get lv to reset its count


 Invalidate doesn't do what you think it does.  That has to do with the 
 rendering of the view on screen, not the contents of the adapter that the 
 ListView knows about.
  

 ... and then add in the 6 new items. After adding each item to listItems 
 I do a notifyDataSetChanged() on the adapter. What I've noticed is that if* 
 I do an lv.getCount it returns 12, i.e., the value it was before doing the 
 listItems.clear()* and invalidate(). Why does the ListView still think 
 it's 12? How do I reset it? Is that why the adapter thinks it's too big?


 Try setting a new (non-public, non-static) adapter into the ListView 
 instead.

 Never change the contents of the data in an adapter after you've given it 
 to the ListView.  Make a deep copy of the data before sending it if you 
 have to.

 Doug



-- 
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/d/optout.


[android-developers] Re: ListView getCount is wrong - how do I reset it?

2014-05-19 Thread plnelson

I call if after adding each one mostly for diagnostics -  I wanted to see 
in the debugger what changed and when.   That's the same reason I'm getting 
the list items size -  for diagnostics, for debugging this problem.

*It's all for the same question *- How do I get ListView to report its 
correct size in getCount after the the size of its dataset changes?   When 
the size of listItems was 12 the listView's getCount returned 12; After 
I've changed the size of listItems to 6 I expect the ListView's getCount to 
return 6 - how to I get ListView to correctly return its new count?




On Monday, May 19, 2014 3:39:33 AM UTC-4, Rufatet Babakishiyev wrote:

 After adding each item to listItems I do a notifyDataSetChanged() on the 
 adapter.

 Why you call adter adding each time.

 public void updateListItems(){
// TODO clear list
// TODO Add element to list
// TODO NOTIFY DATA SET CHANGED
// TODO try to get list item size (I do not know why you need it)
 }

 P.S Sure you created adapter with this list and adapter set to list.


 On Friday, May 16, 2014 11:58:17 PM UTC+5, plnelson wrote:

 I have a listView in an android app which works fine when I first 
 populate it - it displays and scrolls with no problem. But if I load in a 
 new, smaller dataset and call notifyDataSetChanged() the app crashes 
 because getView() gets called with a position value that's bigger than the 
 dataset, i.e., if listItems.size==6, valid values for position should be 
 [0]-[5] but getView() is called with 6, so I'm getting index out of bounds 
 when I try to access an item in my list. While investigating this I noticed 
 that* ListView's getCount() is still returning the old value of 12.*

 Details:

 ...In MyListActivity, which is a ListActivity . . .

 public static ListView lv;   // my ListView in the code

 ... during onCreate() . . .

setContentView(R.layout.mylist);
lv = getListView();

 create the adapter and bind it . . .

 mylistadapter = new MyListAdapter(MyListActivity.this);
 setListAdapter(mylistadapter);   // bind the adapter

 ...the data source is an ArrayList called listItems. The first time 
 around it has 12 items in it; later I clear it and add in 6 items. (see 
 below)

 public static ArrayListStringlistItems=new ArrayListString();

 ... in my adapter, which is a BaseAdapter, my override of getCount() 
 looks like this. After shrinking listItems to 6 it correctly returns 6.

 @Override
 public int getCount() {
 return listItems.size();
 }

 ... To shrink my dataset to 6 I first do a

 listItems.clear();
 lv.invalidate();   // my (failed) attempt to get lv to reset its count

 ... and then add in the 6 new items. After adding each item to listItems 
 I do a notifyDataSetChanged() on the adapter. What I've noticed is that if* 
 I do an lv.getCount it returns 12, i.e., the value it was before doing the 
 listItems.clear()* and invalidate(). Why does the ListView still think 
 it's 12? How do I reset it? Is that why the adapter thinks it's too big?




-- 
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/d/optout.


[android-developers] Re: position value in getView seems too big

2014-05-19 Thread plnelson

I am calling notifyDataSetChanged().  

If I override it in my adapter, to add a log trace, this does get hit and 
the trace happens . . . 







 *// just overriding notifyDataSetChanged() to instrument it
 @Overridepublic void notifyDataSetChanged() {
 Log.e (notifyDataSetChanged()...,   listItems.size()= + 
 String.valueOf(listItems.size()) +   lv.getCount()= + 
 String.valueOf(lv.getCount()) );   //!! debugging
 super.notifyDataSetChanged();} *   


The dataset -  listItems - returns a size of 6.   But *getView(*) gets 
called with position values up to 12 (there are 12 items visible on the 
screen because that's how many items there *used to be* in the dataset,)

So why is getView being called with a position value greater that the 
(current) largest index in its dataset?
Another way to think of this question is how does getView know the largest 
value of position it can have?

(BTW I solved the ListView.getCount() problem by calling setListAdapter() 
on the ListActivity after updating the datasource.   As a result ListView's 
*getCount()* now accurately reflect the the number of list items.   That 
seems to have no affect on this bug.




On Thursday, May 15, 2014 2:09:57 PM UTC-4, plnelson wrote:


 I'm getting a crash in my adapter's *getView()* routine because it's 
 being called with a position value of 6 and my datasource only has 6 items 
 in it. So I assumed that the position parameter should be in a range of 
 [0]-[5]? What determines the range of values in *getView(*)'s position 
 parameter?

 Details:

 the XML ...

 ListView
   android:id=@android:id/list
   android:layout_height=match_parent
   android:layout_width=match_parent
   android:cacheColorHint=@color/colGrey
   android:background=@color/colGrey
   android:clickable=true
   android:fastScrollEnabled=true
   android:choiceMode=none/


 ...In MyListActivity, which is a ListActivity . . .

 public static ListView lv;   // my ListView in the code


 ... during *onCreate()* . . .

setContentView(R.layout.mylist);
lv = getListView();


 create the adapter and bind it . . .

 mylistadapter = new MyListAdapter(MyListActivity.this);
 setListAdapter(mylistadapter);   // bind the adapter


 ...the data source is an ArrayList called listItems. during the course of 
 running the program its size varies and it may have been 15 earlier in 
 program execution . . .

 public static ArrayListStringlistItems=new ArrayListString();


 ... in my adapter, which is a BaseAdapter, my ovveride of getCount() looks 
 like this . . .

 @Override
 public int getCount() {
 return listItems.size();
 }


 ... when I call *getCount()* in *getView()* it returns 6, which is the 
 number of items in the data source, but if I call lv.*getView(*) it 
 returns 15. (any idea where this 15 is coming from?) Could that be why the 
 adapter is calling *getView()* with index too big?

 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/d/optout.


[android-developers] Re: ListView getCount is wrong - how do I reset it?

2014-05-19 Thread plnelson


*FIXED:*

I fixed the *getCount()* problem.  After updating the listItems I now call 
*setListAdapter()* on the ListActivity.  (@Streets of Boston - there is 
only one ListActivity).   After that, when I call the ListView's 
*getCount()* it returns the correct value.

*N.B.* that this does *not* fix the other bug I have in a parallel thread - 
getView's position parameter value coming back too big 
:https://groups.google.com/forum/#!topic/android-developers/Rc09iKIAd9w





 

-- 
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/d/optout.


[android-developers] Re: position value in getView seems too big

2014-05-16 Thread plnelson

Sorry -  should be lv.get*Count*.

And yes, I am calling notifyDataSetChanged.   

I've also tried calling the ListView's *invalidate()* method, with no 
change in the behavior.

Since posting this I've written a whole separate version of the program 
where I initially display 12 items ( listItems.size() == 12).  That part 
works fine.  I then shrink my list to 6 by ...


   - clear my listItems 

*  (  listItems.size() == 0  )*

   - add in 6 new items 

*  (  listItems.size() == 6  )*

   - call notifydataSetChanged()


... but the ListView's getCount still returns 12!Why?And is this 
why the adapter's getCount() returns with an index that's too high for it's 
dataset?





-- 
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/d/optout.


[android-developers] ListView getCount is wrong - how do I reset it?

2014-05-16 Thread plnelson
I have a listView in an android app which works fine when I first populate 
it - it displays and scrolls with no problem. But if I load in a new, 
smaller dataset and call notifyDataSetChanged() the app crashes because 
getView() gets called with a position value that's bigger than the dataset, 
i.e., if listItems.size==6, valid values for position should be [0]-[5] but 
getView() is called with 6, so I'm getting index out of bounds when I try 
to access an item in my list. While investigating this I noticed that* 
ListView's getCount() is still returning the old value of 12.*

Details:

...In MyListActivity, which is a ListActivity . . .

public static ListView lv;   // my ListView in the code

... during onCreate() . . .

   setContentView(R.layout.mylist);
   lv = getListView();

create the adapter and bind it . . .

mylistadapter = new MyListAdapter(MyListActivity.this);
setListAdapter(mylistadapter);   // bind the adapter

...the data source is an ArrayList called listItems. The first time around 
it has 12 items in it; later I clear it and add in 6 items. (see below)

public static ArrayListStringlistItems=new ArrayListString();

... in my adapter, which is a BaseAdapter, my override of getCount() looks 
like this. After shrinking listItems to 6 it correctly returns 6.

@Override
public int getCount() {
return listItems.size();
}

... To shrink my dataset to 6 I first do a

listItems.clear();
lv.invalidate();   // my (failed) attempt to get lv to reset its count

... and then add in the 6 new items. After adding each item to listItems I 
do a notifyDataSetChanged() on the adapter. What I've noticed is that if* I 
do an lv.getCount it returns 12, i.e., the value it was before doing the 
listItems.clear()* and invalidate(). Why does the ListView still think it's 
12? How do I reset it? Is that why the adapter thinks it's too big?


-- 
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/d/optout.


[android-developers] Re: position value in getView seems too big

2014-05-16 Thread plnelson


There's a lot of proprietary code in the adapter; I'll see if I can whittle 
it down to something simple but meanwhile I'd like to pursue the listview's 
strange getCount result.   Because that's a separate question from the 
getView()'s position value (maybe) I've started a separate thread focusing 
on that:
https://groups.google.com/forum/#!topic/android-developers/Lx9_3H4RkhM

This seems to have stumped them on Stack Overflow and I've never been able 
to get a clear description of where *exactly* the value in ListView's 
getCount() actually come from.   


On Friday, May 16, 2014 2:39:54 PM UTC-4, Streets Of Boston wrote:

 That is hard to figure out without you posting the code of your adapter 
 and how you create an instance of your adapter. It is probably a subtle 
 bug...




-- 
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/d/optout.


[android-developers] position value in getView seems too big

2014-05-15 Thread plnelson

I'm getting a crash in my adapter's *getView()* routine because it's being 
called with a position value of 6 and my datasource only has 6 items in it. 
So I assumed that the position parameter should be in a range of [0]-[5]? 
What determines the range of values in *getView(*)'s position parameter?

Details:

the XML ...

ListView
   android:id=@android:id/list
   android:layout_height=match_parent
   android:layout_width=match_parent
   android:cacheColorHint=@color/colGrey
   android:background=@color/colGrey
   android:clickable=true
   android:fastScrollEnabled=true
   android:choiceMode=none/


...In MyListActivity, which is a ListActivity . . .

public static ListView lv;   // my ListView in the code


... during *onCreate()* . . .

   setContentView(R.layout.mylist);
   lv = getListView();


create the adapter and bind it . . .

mylistadapter = new MyListAdapter(MyListActivity.this);
 setListAdapter(mylistadapter);   // bind the adapter


...the data source is an ArrayList called listItems. during the course of 
running the program its size varies and it may have been 15 earlier in 
program execution . . .

public static ArrayListStringlistItems=new ArrayListString();


... in my adapter, which is a BaseAdapter, my ovveride of getCount() looks 
like this . . .

@Override
 public int getCount() {
 return listItems.size();
 }


... when I call *getCount()* in *getView()* it returns 6, which is the 
number of items in the data source, but if I call lv.*getView(*) it returns 
15. (any idea where this 15 is coming from?) Could that be why the adapter 
is calling *getView()* with index too big?

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/d/optout.


[android-developers] Re: Another Resources.NotFoundException with setContentView()

2013-05-21 Thread plnelson
I don't expect it to be reproducible unless you had my entire project and 
all its settings.   This is a large (~20 Activities) industrial-control 
app.   Think of the question as How do I debug a 
Resources.NotFoundException?   or What EXACTLY does a 
Resources.NotFoundException mean?
My IDE is Eclipse Indigo.

On Monday, May 20, 2013 4:43:48 PM UTC-4, bob wrote:

 I cannot reproduce the error you are getting.  What IDE are you using?

 Thanks.


 On Monday, May 20, 2013 3:35:24 PM UTC-5, plnelson wrote:



 On Monday, May 20, 2013 4:26:05 PM UTC-4, Jonathan S wrote:

 how about ant clean build


 This isn't an ant-based project, and anyway, ant is just supposed to 
 emulate the regular IDE so why  whould it be any better than what I've 
 already tried?What does it do in a clean and build that's 
 different/better for a problem like this?  



-- 
-- 
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: Another Resources.NotFoundException with setContentView()

2013-05-21 Thread plnelson


On Monday, May 20, 2013 5:48:03 PM UTC-4, Jonathan S wrote:

 clean remove all gen and bin folders.


As I said in my OP did deleted the gen folder.   I also deleted the bin 
folder.  Everything has been cleaned and rebuilt.


 Would you post all stacktrace for this exceptions?


Here's the stack trace (just as a reminder, in my update I replaced my 
Activity with a simple beginner's Hello activity to super-simplify 
this.)   

HelloActivity.onCreate(Bundle) line: 18
Instrumentation.callActivityOnCreate(Activity, Bundle) line: 1050

ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, 
Intent) line: 1782

ActivityThread.handleLaunchActivity(ActivityThread$ActivityClientRecord, 
Intent) line: 1834
ActivityThread.access$500(ActivityThread, 
ActivityThread$ActivityClientRecord, Intent) line: 122
ActivityThread$H.handleMessage(Message) line: 1027
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 132
ActivityThread.main(String[]) line: 4126
Method.invokeNative(Object, Object[], Class, Class[], Class, int, 
boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 491
ZygoteInit$MethodAndArgsCaller.run() line: 844
ZygoteInit.main(String[]) line: 602
NativeStart.main(String[]) line: not available [native method]
 

-- 
-- 
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: Another Resources.NotFoundException with setContentView()

2013-05-21 Thread plnelson
There's no activity at all in the Console window during the clean and 
build.   Only after I right-click on the target device (a tablet) and do a 
debug as... do I get console output (proprietary company and product names 
obfuscated)

[2013-05-21 13:02:50 - TheProduct] --
[2013-05-21 13:02:50 - TheProduct] Android Launch!
[2013-05-21 13:02:50 - TheProduct] adb is running normally.
[2013-05-21 13:02:50 - TheProduct] Performing com.xxx.yyy.ZzzActivity 
activity launch
[2013-05-21 13:02:55 - TheProduct] Uploading TheProduct.apk onto device 
'43C714440E0F2D7'
[2013-05-21 13:02:55 - TheProduct] Installing TheProduct.apk...
[2013-05-21 13:02:57 - TheProduct] Success!
...
Is there some setting I have to use for the console to see stuff during the 
clean and build?

I really think that the right way to debug this is with an eye to what 
Resource$NotFoundException really means.   Does it mean the resource is not 
in the APK file or that the it somehow has a different ID at runtime than 
what's in the R.java file, or what?The only relevant error in logcat 
says

*05-21 12:47:00.060: W/ResourceType(4801): Failure getting entry for 
0x7f030006 (t=2 e=6) in package 0 (error -75)*

What's a -75?  

On Tuesday, May 21, 2013 10:36:50 AM UTC-4, Piren wrote:

 Just to be sure... open the Eclipse Console and do a Clean on the 
 project.. see if there are any errors showing during the build (these do 
 not show in the Problems view)
 Sometimes something very stupid (like having capital letters in resource 
 names) causes the entire build to fail, but the project to still compile 
 and run (with incorrect resources).



-- 
-- 
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: Another Resources.NotFoundException with setContentView()

2013-05-21 Thread plnelson

* BINGO!*
The missing layout file was in the wrong res folder.   This app runs on a 
tablet and is constrained to run in landscape only so everything is 
supposed to be in layout-land but the missing file was in a different res 
folder.

*Thank you!*

( is there a point system on this forum where we can give answers or 
posters props, like they have on Stack Overflow? )


On Tuesday, May 21, 2013 10:47:53 AM UTC-4, bob wrote:

 I bet it is looking for the resource in a directory called 
 layout-somethingweird, and it's not there.

 What are the names of all your folders that start with layout?  Do they 
 all contain the resource in question?

 For instance, you might say:

 *layout-large*
 *layout-small*
 *layout-medium  *

 Thanks.


 On Tuesday, May 21, 2013 8:15:10 AM UTC-5, plnelson wrote:

 I don't expect it to be reproducible unless you had my entire project and 
 all its settings.   This is a large (~20 Activities) industrial-control 
 app.   Think of the question as How do I debug a 
 Resources.NotFoundException?   or What EXACTLY does a 
 Resources.NotFoundException mean?
 My IDE is Eclipse Indigo.

 On Monday, May 20, 2013 4:43:48 PM UTC-4, bob wrote:

 I cannot reproduce the error you are getting.  What IDE are you using?

 Thanks.


 On Monday, May 20, 2013 3:35:24 PM UTC-5, plnelson wrote:



 On Monday, May 20, 2013 4:26:05 PM UTC-4, Jonathan S wrote:

 how about ant clean build


 This isn't an ant-based project, and anyway, ant is just supposed to 
 emulate the regular IDE so why  whould it be any better than what I've 
 already tried?What does it do in a clean and build that's 
 different/better for a problem like this?  



-- 
-- 
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: Another Resources.NotFoundException with setContentView()

2013-05-21 Thread plnelson

PS  -

This bug was driving me crazy.I'll be at AndDevCon next week in Boston, 
so Bob, if by any chance you'll be there I'll buy you a beer.

-- 
-- 
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] Another Resources.NotFoundException with setContentView()

2013-05-20 Thread plnelson
 

There are lots of Resources$NotFoundException questions on the web and I've 
reviewed them and tried the various suggestions to no avail.

I had a perfectly working layout to display some graphics with some buttons 
underneath and I modified some of the buttons and started to get this 
error. I couldn't see anything wrong with my changes but just to narrow it 
down I deleted *ALL* the buttons, so now I just have a LinearLayout with an 
ImageView and I'm *still* getting the error. My Java:

try  {
setContentView(R.layout.graphics);
}
catch (Exception e)  {
Log.d(DGraphActivity, setContentView crash);   
}

My XML:

?xml version=1.0 encoding=UTF-8?LinearLayout 
xmlns:android=http://schemas.android.com/apk/res/android;
android:layout_width=match_parent
android:layout_height=match_parent
android:orientation=horizontal
   ImageView 
  android:id=@+id/image2
  android:layout_width=0px
  android:layout_weight=2
  android:layout_height=match_parent
  android:scaleType=fitCenter
/ImageView
 /LinearLayout

The error says *android.content.res.Resources$NotFoundException: Resource 
ID #0x7f030005*. In the R.java file that resource is identified with the 
graphics . . . 

public static final class layout {
public static final int addcomment=0x7f03;
public static final int areyousure=0x7f030001;
public static final int downarrow=0x7f030002;
public static final int downleftarrow=0x7f030003;
public static final int downrightarrow=0x7f030004;
public static final int graphics=0x7f030005;
public static final int infofromoperator=0x7f030006;

I deleted the gen folder and did a clean of** the project with no 
improvement.

I also rebooted my PC and did an explicit close of the project. 

I did a Refresh of my project

I do not have an explicit import Android.R

There's nothing obviously wrong with the graphics.xml file - it exists in 
the same folder with all my other XML files; it's not write-protected or 
hidden. Eclipse doesn't flag any errors or warnings for it. 

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: Another Resources.NotFoundException with setContentView()

2013-05-20 Thread plnelson
Just an update:  to simplify things further I replaced the layout file with 
a default layout file (foo.xml) that you get when you have Eclipse 
generate a new layout file for you:

?xml version=1.0 encoding=utf-8?
LinearLayout xmlns:android=http://schemas.android.com/apk/res/android;
android:layout_width=match_parent
android:layout_height=match_parent
android:orientation=vertical 
/LinearLayout

And I've replaced my java file with a beginner's hello android java file 
. . . 

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class HelloActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) 
{
super.onCreate(savedInstanceState);
try  {
setContentView(R.layout.foo);
}
catch (Exception e)  {
Log.d(HelloActivity, setContentView crash);   
} 
}
}

And I STILL get a *Resources NotFoundException*  in the setContentView()*

*How do I debug this?   Thanks, again, 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: Another Resources.NotFoundException with setContentView()

2013-05-20 Thread plnelson


On Monday, May 20, 2013 4:26:05 PM UTC-4, Jonathan S wrote:

 how about ant clean build


This isn't an ant-based project, and anyway, ant is just supposed to 
emulate the regular IDE so why  whould it be any better than what I've 
already tried?What does it do in a clean and build that's 
different/better for a problem like this?  

-- 
-- 
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] How to keep WiFi on and let screen go to sleep?

2013-04-11 Thread plnelson


On Wednesday, April 10, 2013 4:26:21 PM UTC-4, mike digioia wrote:

 What are you trying to do? If you want to measure power using wifi, then 
 just subtract the screen power consumption numbers after two tests - one 
 with screen in flight mode and one with wifi on.


Why do you think we're trying to measure power?  

As I explained above, these devices are used to control an industrial 
process.  There are typically many of them out on the factory floor and 
users can pick them up and operate them, but even when a user isn't 
interacting with them the server still is.   I want the display to go off 
because on a typical device that's the biggest battery hog - if the display 
stays off when not in use we can an get an 8-hour factory shift on one 
charge.

-- 
-- 
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] How to keep WiFi on and let screen go to sleep?

2013-04-10 Thread plnelson


I'm programming an Android device for use in an industrial environment 
where it needs to stay in touch with the server even when the screen goes 
to sleep. I thought I did all the right stuff but when the screen goes out 
it still sends a Fin to the server (confirmed on a network data packet 
sniffer).

I know that to do a WifiLock I must also do a WakeLock, so, in my onCreate 
I do . . . 

 private PowerManager.WakeLock wakelock;private WifiManager.WifiLock wifilock;

 . . . 

 PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
 wakelock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, CPUOnly);
 wakelock.acquire();
 WifiManager wifiManager = (WifiManager) 
 getSystemService(Context.WIFI_SERVICE);
 wifilock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, 
 WifiLock);
 wifilock.acquire();


I read on the web that this doesn't work on some devices and you have to 
leave the screen on dim, so I replaced the line above with 

 wakelock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, 
 CPUOnly);


That worked in the sense that WiFi stayed on, but at the expense of 
leaving the screen on dimly.   Is there any workaround to this so the 
screen can go off but WiFi stay on?

ALSO - this is on an Android 2.36 device, but the Android documentation  
says that as of API 17 SCREEN_DIM_WAKE_LOCK is deprecated and we're 
supposed to use FLAG_KEEP_SCREEN_ON, but that leaves the display on at *full 
brightness*!   So what are we supposed to do then?

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: How to keep WiFi on and let screen go to sleep?

2013-04-10 Thread plnelson
Just an addendum - I tried setting the WiFi Sleep Policy to Never in the 
WiFi Settings advanced Menu and it made no difference - unless I let the 
screen stay on, however dimly, as soon as the display goes out it sends a 
fin to the server.

-- 
-- 
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: How to keep WiFi on and let screen go to sleep?

2013-04-10 Thread plnelson

On Wednesday, April 10, 2013 2:37:53 PM UTC-4, bob wrote:

 Why do you need to keep the Wifi on?

As I explained in the OP, the Android devices are used in an industrial 
environment.  Specifically they are used in a factory where they are 
sending and receiving information to a central process control PC even when 
users are not interacting with the display or keyboard.

But *why* I want WiFi to stay on isn't really the point -  the point is 
that this is a feature that Android supposedly supports and I can't seem to 
get it to work.Is this an Android bug or am I doing something wrong?

The devices are all Samsung Media Players (a cellphone without the phone - 
sort of an Android iPod) running stock-out-of-the-box Android 2.35 or 2.36.




-- 
-- 
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] How to keep WiFi on and let screen go to sleep?

2013-04-10 Thread plnelson



 Acquiring wifilock like this only makes sure the system does not shut down 
 wifi. The actual wifi connection still goes through power optimizations 
 once screen is off in the driver. 

 This should not drop your connections,


But it does.   As I said, it sends a FIN packet - that's a request to 
close the connection.   The server responds with an ACK and.a FIN of its 
own which Android ACKs.   This is the textbook-standard way to close a TCP 
connection, and it's initiated by Android when the display goes off. We 
watch it all on our network sniffers and it's 100% reliable and repeatable.

The Android device does *not* send a FIN packet as long as the display 
stays on, no matter how long it stays on.

-- 
-- 
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.




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.




[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 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 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: Activity won't start when launchmode is standard

2013-04-04 Thread plnelson
 OK I tried that - no luck - it's not getting to the constructor

*BUT*  -  while testing it I got a new clue. It launches the SECOND 
time I try it, consistently,   Here's the extracted Logcat - you can see 
that the first time it never gets past Starting Intent, the second time it 
goes all the way 

04-04 11:35:18.279: I/ActivityManager(119): Starting: Intent { 
flg=0x400 cmp=com..remote/.DGraphActivity (has extras) } from pid 
25156
...
   ...
  ... 

04-04 11:35:34.002: I/ActivityManager(119): Starting: Intent { 
flg=0x400 cmp=com..remote/.DGraphActivity (has extras) } from pid 
25156
04-04 11:35:34.006: W/ActivityManager(119): Trying to launch 
com..remote/.DGraphActivity
04-04 11:35:34.025: D/DGraphActivity(25156): constructor
04-04 11:35:34.025: D/DGraphActivity(25156): created

This is bizarre . . . Does anyone have any ideas?   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] Bizarre launch behavior for a standard launchMode Activity

2013-04-04 Thread plnelson
 

  ( *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 . . . 

activity android:name=DGraphActivityandroid:screenOrientation=portrait 
   android:launchMode=standard/activity

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

04-04 11:35:34.025: D/DGraphActivity(25156): constructor

04-04 11:35:34.025: D/DGraphActivity(25156): 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: Activity won't start when launchmode is standard

2013-04-04 Thread plnelson

I think the discovery of the bizarre double-launch behavior puts a 
different spin on this, so I've started a new thread.   Please direct all 
further comments or suggestions to the new thread:   
https://groups.google.com/forum/?fromgroups=#!topic/android-developers/4js6GASVZc4
  
Thanks.


-- 
-- 
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: Activity won't start when launchmode is standard

2013-04-04 Thread plnelson


On Thursday, April 4, 2013 1:57:36 PM UTC-4, plnelson wrote:


 I think the discovery of the bizarre double-launch behavior puts a 
 different spin on this, so I've started a new thread.   Please direct all 
 further comments or suggestions to the new thread:   
 https://groups.google.com/forum/?fromgroups=#!topic/android-developers/4js6GASVZc4
   
 Thanks.




-- 
-- 
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


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 . . . 

 activity android:name=DGraphActivity
 android:screenOrientation=portrait
 android:launchMode=standard/activity

 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: Activity won't start when launchmode is standard

2013-04-02 Thread plnelson
   
Here's another detail:If I set  DGraphActivity's launchmode to 
singleInstance the logcat shows this . . . 

*03-31 18:49:12.224: I/ActivityManager(119): Starting: Intent { 
flg=0x400 cmp=com..remote/.DGraphActivity (has extras) } from pid 
19024

03-31 18:49:12.298: W/ActivityManager(119): Trying to launch 
com..remote/.DGraphActivity

03-31 18:49:12.318: D/DGraphActivity(19024): created*

But when it's standard it stops at Starting Intent.What does this 
mean?

Could someone *please* offer some clues here because I'm totally stumped!

-- 
-- 
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] How can I get notified when the server has closed the TCP connection

2013-04-02 Thread plnelson
I'm writing software for an Android device used as a remote control for an 
industrial process being run by a PC.   The PC is always listening and the 
Android device opens a connection via the Android socket class, which 
provides a client-side TCP socket. Once the connection is established 
commands flow back and forth over the connection. The PC can close the 
connection at any time, issuing a FIN, asynchronously.   My requirement is 
that I display this on the Android device as soon as it happens.
   
Studying the Android socket, it does not seem to be event driven.   There 
doesn't seem to be any way to raise an event or a callback if the server 
closes the connection.   It looks like the first sign I'll have is getting 
an error if I try to send something. Is this true or am I 
misunderstanding something?The guys on the PC side don't believe it 
because they say that their TCP socket software raises an event and calls a 
handler if a connection is closed on the other end.

So does this mean I'm going to have to sit in a timer-controlled loop and 
poll endlessly just to find out when the server has closed the connection 
or am I overlooking a better option?

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: How can I get notified when the server has closed the TCP connection

2013-04-02 Thread plnelson

Just to clarify- when you say add another command, do you mean add a 
command to the PC to send to the Android device that it's closing?That 
would be a good solution but I don't know if I have any control over what 
the PC sends.This is the first and only Android/Java device on that 
network and I think the assumption is that *of course* the Android app will 
just know or get an event when the PC closes the connection.The other 
devices on that network are either Windows PC's running sockets that 
fire-off event handlers when the connection is closed, or specialized 
manufacturing hardware running Linux with low-level custom code to detect 
things like FINs and RST's.   Android is my first exposure to java so I 
didn't know, either.

Maybe if I show the PC people this conversation it will help.  Thanks. 


On Tuesday, April 2, 2013 10:50:03 AM UTC-4, Piren wrote:

 Thats how it works in Java... 
  
 http://stackoverflow.com/questions/155243/why-is-it-impossible-without-attempting-i-o-to-detect-that-tcp-socket-was-grac
  
 http://stackoverflow.com/questions/155243/why-is-it-impossible-without-attempting-i-o-to-detect-that-tcp-socket-was-grac

 You shouldn't base your socket state to display this information anyhow, 
 since you could have the exact same issue for any other kind of 
 disconnection (i.e, it will appear live but once a command will be sent 
 the socket will fail or when the KeepAlive runs out... which is btw an 
 already existing timer controlled loop that polls endlessly just to find 
 out if the server has closed the connection .. hehe ). Instead add another 
 command to signal the device that the PC chose to close the connection. 


 On Tuesday, April 2, 2013 5:02:08 PM UTC+3, plnelson wrote:

 I'm writing software for an Android device used as a remote control for 
 an industrial process being run by a PC.   The PC is always listening and 
 the Android device opens a connection via the Android socket class, which 
 provides a client-side TCP socket. Once the connection is established 
 commands flow back and forth over the connection. The PC can close the 
 connection at any time, issuing a FIN, asynchronously.   My requirement is 
 that I display this on the Android device as soon as it happens.

 Studying the Android socket, it does not seem to be event driven.   There 
 doesn't seem to be any way to raise an event or a callback if the server 
 closes the connection.   It looks like the first sign I'll have is getting 
 an error if I try to send something. Is this true or am I 
 misunderstanding something?The guys on the PC side don't believe it 
 because they say that their TCP socket software raises an event and calls a 
 handler if a connection is closed on the other end.

 So does this mean I'm going to have to sit in a timer-controlled loop and 
 poll endlessly just to find out when the server has closed the connection 
 or am I overlooking a better option?

 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: Activity won't start when launchmode is standard

2013-03-31 Thread plnelson


On Friday, March 29, 2013 7:06:59 PM UTC-4, Streets Of Boston wrote:


Log.*e*(Commands, failed to start DGraphActivity*, e*);


 OK, I've added that although, since it's not hitting that (or any) 
exceptions it's not really telling me anything.

So we're still kinda back on the original question - if an activity fails 
to start is there anyway of finding out why?   

 

 

-- 
-- 
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: Debugging the Activity life-cycle?

2013-03-31 Thread plnelson


On Friday, March 29, 2013 11:16:26 PM UTC-4, Kristopher Micinski wrote:

  
  In that particular example the returning Activity was standard but the 
  Activity invoking it was singleInstance.   I knew the returning Activity 
 had 
  to be standard but I only found out that the caller couldn't be 
  singleInstance by time-consuming trial-and-error.I've never seen it 
  documented.When I made the caller activity also standard it worked. 
  Which illustrates my question:   which is whether there's a way to 
  systematically find out from Android what happened.   Is any of this 
 stuff 
  instrumented so we can see why something did or did not happen? 
  

 No. 

 But you should see something in the logcat that shows an intent was 
 fired.  Do you not see that? 


When the Activity (called DGraphActivity (-out proprietary namespace) 
is set to a standard launchMode and I do a search of all the logCat 
output I see two references to it


*03-29 19:21:04.357: I/ActivityManager(119):   Force finishing activity 
HistoryRecord{40698f18 com..remote/.*
*DGraphActivity}

03-29 19:23:56.454: I/ActivityManager(119): Starting: Intent { 
flg=0x400 cmp=com..remote/.**DGraphActivity (has extras) } from pid 
13727*

What was interesting about this is that 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, it just stops at starting: intent  - that must 
be some kind of clue but I don't know what.   

*But*, when DGraphActivity's launchmode is set to singleInstance the logcat 
shows this . . . 

*03-31 18:49:12.224: I/ActivityManager(119): Starting: Intent { 
flg=0x400 cmp=com.assemblyguide.remote/.DGraphActivity (has extras) } 
from pid 19024

03-31 18:49:12.298: W/ActivityManager(119): Trying to launch 
com.assemblyguide.remote/.DGraphActivity

03-31 18:49:12.318: D/DGraphActivity(19024): created*


For my purposes I need it to be standard but I don't know how to interpret 
this to glean why Android can start the Activity in singleInstance, but not 
in standard mode




-- 
-- 
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: Debugging the Activity life-cycle?

2013-03-31 Thread plnelson


On Friday, March 29, 2013 11:16:26 PM UTC-4, Kristopher Micinski wrote:

  
  In that particular example the returning Activity was standard but the 
  Activity invoking it was singleInstance.   I knew the returning Activity 
 had 
  to be standard but I only found out that the caller couldn't be 
  singleInstance by time-consuming trial-and-error.I've never seen it 
  documented.When I made the caller activity also standard it worked. 
  Which illustrates my question:   which is whether there's a way to 
  systematically find out from Android what happened.   Is any of this 
 stuff 
  instrumented so we can see why something did or did not happen? 
  

 No. 

 But you should see something in the logcat that shows an intent was 
 fired.  Do you not see that? 


When the Activity (called DGraphActivity (-out proprietary namespace) 
is set to a standard launchMode and I do a search of all the logCat 
output I see two references to it


*03-29 19:21:04.357: I/ActivityManager(119):   Force finishing activity 
HistoryRecord{40698f18 com..remote/.*
*DGraphActivity}

03-29 19:23:56.454: I/ActivityManager(119): Starting: Intent { 
flg=0x400 cmp=com..remote/.**DGraphActivity (has extras) } from pid 
13727*

What was interesting about this is that 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, it just stops at starting: intent  - that must 
be some kind of clue but I don't know what.   

*But*, when DGraphActivity's launchmode is set to singleInstance the logcat 
shows this . . . 

*03-31 18:49:12.224: I/ActivityManager(119): Starting: Intent { 
flg=0x400 cmp=com..remote/.DGraphActivity (has extras) } from pid 
19024

03-31 18:49:12.298: W/ActivityManager(119): Trying to launch 
com..remote/.DGraphActivity

03-31 18:49:12.318: D/DGraphActivity(19024): created*


For my purposes I need it to be standard but I don't know how to interpret 
this to glean why Android can start the Activity in singleInstance, but not 
in standard mode




-- 
-- 
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: Debugging the Activity life-cycle?

2013-03-31 Thread plnelson


On Friday, March 29, 2013 11:16:52 PM UTC-4, Kristopher Micinski wrote:

 You might try asking the package manager if the intent you're sending 
 will have any receivers, also.. 


I'm not sure how do that.  Using the intent I use to launch my activity,  I 
tried . . . 

  PackageManager p = ctx.getPackageManager();
  final ListResolveInfo info=p.queryIntentActivities(intent, 
PackageManager.GET_ACTIVITIES);

...but I had no idea how to interpret the output.   Here it is, first the 
successful (singleInstance) case, and second the failing (standard) 
case.I don't see a difference but I may just be too blurry-eyed to see 
it (it's 8PM here).


infoArrayList  (id=830008681048)
arrayObject[1]  (id=830008671280)
[0]ResolveInfo  (id=830008643864)
activityInfoActivityInfo  (id=830008586728)
applicationInfoApplicationInfo  (id=830008677824)
configChanges0 [0x0] [^@ (NUL)]
descriptionRes0 [0x0] [^@ (NUL)]
enabledtrue
exportedfalse
flags0 [0x0] [^@ (NUL)]
icon0 [0x0] [^@ (NUL)]
labelRes0 [0x0] [^@ (NUL)]
launchMode3 [0x3] [^C]
logo0 [0x0] [^@ (NUL)]
metaDatanull
namecom..remote.DGraphActivity 
(id=830008007480)
nonLocalizedLabelnull
packageNamecom..remote (id=830007988376)
permissionnull
processNamecom..remote (id=830007818216)
screenOrientation1 [0x1] [^A]
softInputMode0 [0x0] [^@ (NUL)]
targetActivitynull
taskAffinitycom..remote (id=830007817688)
theme0 [0x0] [^@ (NUL)]
filternull
icon0 [0x0] [^@ (NUL)]
isDefaultfalse
labelRes0 [0x0] [^@ (NUL)]
match0 [0x0] [^@ (NUL)]
nonLocalizedLabelnull
preferredOrder0 [0x0] [^@ (NUL)]
priority0 [0x0] [^@ (NUL)]
resolvePackageNamenull
serviceInfonull
specificIndex-1 [0x]
modCount1 [0x1] [^A]
size1 [0x1] [^A]




infoArrayList  (id=830008607104)
arrayObject[1]  (id=830008590088)
[0]ResolveInfo  (id=830008265248)
activityInfoActivityInfo  (id=830008525064)
applicationInfoApplicationInfo  (id=830008598288)
configChanges0 [0x0] [^@ (NUL)]
descriptionRes0 [0x0] [^@ (NUL)]
enabledtrue
exportedfalse
flags0 [0x0] [^@ (NUL)]
icon0 [0x0] [^@ (NUL)]
labelRes0 [0x0] [^@ (NUL)]
launchMode0 [0x0] [^@ (NUL)]
logo0 [0x0] [^@ (NUL)]
metaDatanull
namecom..remote.DGraphActivity 
(id=830008010320)
nonLocalizedLabelnull
packageNamecom..remote (id=830008010248)
permissionnull
processNamecom..remote (id=830007812448)
screenOrientation1 [0x1] [^A]
softInputMode0 [0x0] [^@ (NUL)]
targetActivitynull
taskAffinitycom..remote (id=830007796672)
theme0 [0x0] [^@ (NUL)]
filternull
icon0 [0x0] [^@ (NUL)]
isDefaultfalse
labelRes0 [0x0] [^@ (NUL)]
match0 [0x0] [^@ (NUL)]
nonLocalizedLabelnull
preferredOrder0 [0x0] [^@ (NUL)]
priority0 [0x0] [^@ (NUL)]
resolvePackageNamenull
serviceInfonull
specificIndex-1 [0x]
modCount1 [0x1] [^A]
size1 [0x1] [^A]

  Thanks for your help on this!!


-- 
-- 
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] Activity won't start when launchmode is standard

2013-03-29 Thread plnelson
This question has (so far)  stumped them on Stack Overflow. . . . 

I'm trying to launch an Activity which launches *perfectly fine* when its 
launchMode is set to *singleInstance*. When I change it to *standard*nothing 
happens; it never gets to onCreate (or onStart or onResume, or 
anyplace in the target Activity - I've overridden all the lifycycle events 
and set breakpoints)

if (DGraphActivity.bitmap != null) {
Intent intent = new Intent(ctx, DGraphActivity.class);
intent.putExtra(Buttons, sButtonParam);
try {
ctx.startActivity(intent);
}
catch (Exception e)  {
Log.d(Commands, failed to start DGraphActivity);   
}}   

in the manifest . . . 

activity android:name=DGraphActivity
android:screenOrientation=portrait
android:launchMode=standard/activity

I need the DGraphActivity launchMode to be *standard* because it will be 
launching another activity and using onActivityResult to collect the 
response and onActivityResult doesn't work with activites launched in 
singleInstance launchMode. 

I have lots of other Activities with *standard* launchMode that launch 
perfectly well, I can't figure out what's different about this one. 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] Debugging the Activity life-cycle?

2013-03-29 Thread plnelson
Over many projects I've run into various problems with Activities doing 
mysterious things.   I've had them not start; I've had onActivityResult not 
get called when I'm trying to send parameters back from an Activity; I've 
had onActivityResult get called *instantly* before the other Activity even 
got created.Googling the web I see that lots of people have these 
problems and often these either stump people on StackOverflow or result in 
random superstitious fixes with no obvious basis - even if they sometimes 
seem to work.
 
So* My Question*:  is there any *systematic* way to debug Activity 
life-cycle problems - are there log files, traces, dumps, or anything that 
programmers can use to figure out why something is happening.If I call 
startActivity and the activity is never created or started, is there 
anyplace Android tells us why?   If onActivityResult is called prematurely 
(i.e., before the Activity that's supposed to return the result even 
exists) how can we find out why it was called? Are there any hints of 
tricks to interpreting the call stack that can shed light on that?

Thanks in advance for any tips or tricks.

-- 
-- 
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: Debugging the Activity life-cycle?

2013-03-29 Thread plnelson
On Friday, March 29, 2013 5:56:18 PM UTC-4, Streets Of Boston wrote:

 Look at your logcat. It tells you when an activity hasn't started. 


When an activity fails to start all I see in LogCat is .. *nothing* related 
to that Activity.   If the Activity is created or started (or paused, etc) *
then* I see it in Logcat.   Are you saying that I should see a message 
saying that the Activity failed to start or be created?   I run LogCat in 
verbose mode with no filters on.

 

 For the onActivityResult getting called instantly: Your returning activity 
 was probably started with a singleTask or singleInstance. This means that 
 onActivityResult was called immediately after your activity was started 
 (and not upon its return). Use default/standard instead.


In that particular example the returning Activity was standard but the 
Activity *invoking* it was singleInstance.   I knew the returning Activity 
had to be standard but I only found out that the caller couldn't be 
singleInstance by time-consuming trial-and-error.I've never seen it 
documented.When I made the caller activity also standard it 
worked.  Which illustrates my question:   which is whether there's a 
way to *systematically* find out from Android what happened.   Is any of 
this stuff instrumented so we can see why something did or did not happen?  

I'm currently trying to debug a case where I can ONLY start an activity if 
it's singleInstance.   I don't know why and lots of people on StackOverflow 
have made many guesses and suggestions, none of which (as of this writing) 
have worked.Because we're all fumbling in the dark since we don't know 
what Android is doing behind the scenes.   I want to know if there's a way 
to find 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.




[android-developers] Re: Activity won't start when launchmode is standard

2013-03-29 Thread plnelson


On Friday, March 29, 2013 5:57:46 PM UTC-4, Streets Of Boston wrote:

 Look at your logcat and see why your activity can't be started. Could be 
 as simple as a typo in your manifest.


I only see things in LogCat about  DGraphActivity when it *does* start 
(ie., when its launchMode is singleInstance).Are you saying there 
should be a message that it failed to start (or failed to be created)?   I 
run Logcat with no filters and in verbose mode so I think I'm seeing 
everything there is.

The manifest is exactly as it's shown - the *only* difference between the 
successful case and the failing case is the launchMode, so if there was a 
typo it would have to be unique to that line.Furthermore it only works 
for singleInstance, it fails for standard, singleTop and singleTask, so if 
there was a typo it would have to be in all three of those but not in the 
singleInstance case.


RichardC wrote 
  Technically it needs a . here:

  activity android:name=.DGraphActivity
   
I'm skeptical.   My program has about 20 Activities and none of them have 
.'s in front of the name and I've written a lot of other Android programs 
without .'s.   And this works fine without the . if I launch it in 
singleInstance.   From time to time I have heard people mention .'s 
in the Manifest so I don't know if that used to be a requirement in the 
early days or what.   Just for yucks I tried putting the . in and it 
didn't help. 

-- 
-- 
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: Activity won't start when launchmode is standard

2013-03-29 Thread plnelson


On Friday, March 29, 2013 7:04:39 PM UTC-4, Streets Of Boston wrote:

 I've never seen this. If it fails to start, i get a logcat message and an 
 exception is thrown (and you are catching that).


*My bad* -  it turned out it did have a filter on.  (thanks for saying you 
never saw that - it made me look twice!)   With it off  I do get 2 logcat 
messages about this activity  (I've 'd out some proprietary 
content).   I'm not sure what these mean . . . 


03-29 19:21:04.357: I/ActivityManager(119):   Force finishing activity 
HistoryRecord{40698f18 com..remote/.DGraphActivity}


03-29 19:23:56.454: I/ActivityManager(119): Starting: Intent { 
flg=0x400 cmp=com..remote/.DGraphActivity (has extras) } from pid 
13727

What was interesting about this is, as I mentioned, 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!   So that seems to be a clue but 
I don't know of what.


Have you tried to set the Intent.FLAG_ACTIVITY_NEW_TASK flag when starting 
 the activity?


No I haven't -  thought that just places it outside the others on the 
history stack  -  why do I want to do that? 

(PS - where on the Streets of Boston are you -  I'm on the streets of 
Chelmsford).


-- 
-- 
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] How to test if something is a PopupWindow

2012-01-27 Thread plnelson
(I posted this on Stack Overflow but as of this writing I've received no 
response)

I'm writing code that starts with a View object in a layout hierarchy and 
iteratively walks up the tree to the view root, using *getParent()*, 
displaying information about each level as it goes. 

Everything is working fine except for PopupWindow, which is one of the 
classes I want to display. All the other ones in my layout are derived 
directly or indirectly from the View class, e.g., LinearLayout, 
RelativeLayout, Button etc. So I get the Parent View (vPar) and do a 

Object obj = (Object)vPar;

To test for, say, RelativeLayout I can then do a . . .

if (obj instanceof RelativeLayout ) {

...

But this doesn't work for PopupWindow. Even though PopupWindow is derived 
from Object, when it's in a layout it's shown as 
PopupWindow$PopupViewContainer in the debugger. And PopupViewContainer is 
not part of the public API, according to 
http://www.kiwidoc.com/java/l/x/android/android/5/p/android.widget/c/PopupWindow.PopupViewContainer.

So how do I test to see if I have a PopupWindow as I'm walking up the 
hierarchy?

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

[android-developers] Android developer discussion forums?

2011-10-27 Thread plnelson
I'm looking for an ACTIVE discussion forum for Android app
developers. I already use Stack Overflow, which I think is a
wonderful resource, but it's strictly a question and answer format,
where there is a clear, objective answer.   Some things require a more
extended discussion, or sometimes I ask a question on Stack Overflow
and get no satisfactory answers so I'd like to try an alternative
site.

Anddev,org has been suggested but traffic there is very low.   There
are plenty of good question that have been up there for a week with
only a few dozen views and no responses.Also, N.B., I'm looking
for a web-forum, not an email list.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