[android-developers] Does anyone has a recommendation on a good implementation of SQLite Script Runner

2014-08-23 Thread Satya Komatineni
I have gone through StackOverflow etc.

I ran into the Beryl library etc.

Do you know if Beryl library is still active on google code?

Does anyone have strong recommendations on this subject

Appreciate your thoughts
Satya

-- 
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] Help: When will CONTEXT_INCLUDE_CODE result in a security exception while creating a package context?

2014-05-10 Thread Satya Komatineni
Is it when the target context does not share the user id with the calling
context?

Appreciate your insight
Satya

-- 
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] A startup weekend question on parental controls for Android

2014-02-02 Thread Satya Komatineni
is there a way to enable and disable certain features of Android based on
parental or control authority permissions.

Say a parent may want to disable certain features of the phone either
during homework hours, or based on a location (like a car) say.

Appreciate if one can chime in
thanks
Satya
http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni

-- 
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 stop or cancel Asyntask (Download image)

2013-11-30 Thread Satya Komatineni
You can call the cance(boolean) method on the asynctask. And you can pass
true to forcefully remove the thread as per the docs. However it depends on
what the URL and the drawable is doing and if they need to be informed of
cancelling. You can also set a flag to cancel the task and check it often
in the dobackground method if there is a loop of activity going on. In your
case as there is no loop you may want to read up on the URLs and drawables
to see if they have a cancel. then I will try cancel(true) on the asynctask.

Here are some research notes on asynctask if you have patience to read
through:

Understanding Asynctask and ProgressDialogs
http://satyakomatineni.com/item/3536


On Sat, Nov 30, 2013 at 10:58 AM, askl amal...@gmail.com wrote:

 *Hi Dear,*
 *Can u please explain how to stop or cancel downloading progress within
 asyntask in android. Here's the my sample code. Please help me to solve
 this problem.*

 *private class DownloadPicture extends*
 * AsyncTaskString, Void, Drawable {*

 * @Override*
 * protected Drawable doInBackground(String... urls) {*

 * try {*
 * InputStream nextPicIs = (InputStream) new URL(urls[0])*
 * .getContent();*
 * Drawable nextPicDraw = Drawable.createFromStream(nextPicIs,*
 * Jathaka Katha);*

 * nextPicIs.close();*

 * return nextPicDraw;*

 * } catch (Exception e) {*
 * System.out.println(IMAGE EXCEPTION  + e);*
 * return null;*
 * }*
 * }*

 * @Override*
 * protected void onPostExecute(Drawable result) {*

 * if (result != null) {*
 * Bitmap currentImg= ((BitmapDrawable) result).getBitmap();*

 *img_view.setImageBitmap(currentKatha);*

 * } else {*
 *
 img_view.setBackgroundResource(R.drawable.play_default);*
 * }*

 * onCancelled();*
 * }*

 * @Override*
 * protected void onCancelled() {*
 * super.onCancelled();*
 * }*
 * }*

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




-- 
http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni

-- 
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] Circular Menu

2013-02-15 Thread Satya Komatineni
Ravi,
what you need is a custom view and some 2D graphics API details.

Some of the material might be of some help

Essential Custom View Code snippets
http://satyakomatineni.com/item/4330

Also you will see here links for custom layouts research as well if
you were to arrange buttons or images in a circular layout.

On Fri, Feb 15, 2013 at 7:23 AM, ravi . ravikanth...@gmail.com wrote:
 Hi All
 I want to design a menu just like the attached screen. I had tried in many
 ways but couldn't get a solution.

 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.



http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni

-- 
-- 
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] Info: Research notes on using GSON for Mobile App Storage

2012-12-28 Thread Satya Komatineni
Article: GSON for Mobile App Storage
http://satyakomatineni.com/item/4440

Here is an abstract:

You will be surprised how GSON can propel your mobile app productivity
especially release 1 candidates. In this approach you will represent
the persistent state of your apps as JSON. You will use the
Beautiful tool GSON from google to convert your application objects
to JSON and persist the resulting JSON string either in a shared
preference or on internal storage as files.

This article answers the following questions


What does Android recommend for data storage options? The Official line!
The JSON solution
What is GSON?
  What is GSON's homepage?
  Is there a user guide for GSON?
  Can I save nested objects?
  Can I save nested collections of objects?
  How are characters in strings escaped?
How do you add external jar files to Android APK file?
What are shared preferences?
Difference between getSharedPreferences and getPreferences?
How to get a context independent of an activity?
Where are shared preference files stored?
How do you save JSON to a shared preference file?
What does the saved preference file look like?
How do you read JSON from shared preferences back as Java Objects?
How does escape characters work in android preferences?
What is internal storage?
How do you save to internal storage?
How do you restore objects from internal storage?
Should you use external storage like the SD card?
What are the useful references while working with this approach?
How do you code such a way that you can migrate in the future to SqlLite?
What Next?

Thanks
Satya

-- 
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] wondering if a value of * is deprecated for the metadata android.app.default_searchable?

2012-11-30 Thread Satya Komatineni
application...
activity.../
meta-data android:name=android.app.default_searchable
android:value=* /
/application

Is this feature of indicating * seem to be deprecated.

The following lines in Searchables.java

// This value is deprecated, return null
if (refActivityName.equals(MD_SEARCHABLE_SYSTEM_SEARCH)) {
return null;
}


Thank you so much
Satya

-- 
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] Principles of Custom Layouts with code snippets

2012-11-10 Thread Satya Komatineni
Here are some notes and code samples for implementing custom layouts
like a flow layout

http://satyakomatineni.com/item/4359

This covers
***
Inherit from ViewGroup
Override OnMeasure
  Use a pencil and paper to figure out your algorithm
  Use ViewGroup.measureChild(). Don't directly use child.measure()
  (Unless you know what you are doing)
  Use layout params to stuff the origin of each child view
  Take into accound padding
Override OnLayout
  Just retrieve the layout param object and use its origin
Implement custom LayoutParams with any additional layout attributes
Override layout params construction methods

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


Re: [android-developers] Re: 3D game engine integration in the android framework

2012-11-09 Thread Satya Komatineni
These are excellent goals. Thank you for your work and the post
Satya

http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni

On Fri, Nov 9, 2012 at 2:29 PM, sebastian_bugiu
sebastian.bugiu.reloa...@gmail.com wrote:
 Why should the platform take any Game Engine? Because beginning game
 developers would surely appreciate something that leverages the android API
 directly. It would be easier for them to choose Android over Apple when
 choosing a platform to learn game development. Right now Android has worse
 game development support than Apple since it requires beginning people to
 take a C++ engine from the internet and try to use it through the NDK that
 doesn't fully support C++, all the while the official language is Java. It's
 cumbersome. At Apple you already get everything streamlined in the platform.
 You use Objective-C and can easily port your C/C++ engine to it. Android
 basically doesn't fully support C++ and developing using the NDK is pretty
 bad, especially for a beginner. It would make android much more developer
 friendly if it were to have a java written engine (easy to use), without
 using the JNI for all the calls to a C++ engine underneath (so it would be
 faster). Integrating the engine in the platform shows better commitment to
 the people that start programming and want to get in game development. And
 people want to make games for phones since it's easier for an indie dev to
 start for the phone than to write a game for PC or Xbox etc.

 Why this one? Because this one does not go anywhere near C++, so no JNI.
 Also because the renderer is very capable for all kinds of games as it is
 based on Ogre so you can have advanced graphics on the phone while using a
 simple programming language (Java). Also it has good documentation so people
 can learn about its design and understand how a game engine works, should
 they want to write their own or modify and extend this one.


 On Friday, November 9, 2012 7:24:59 PM UTC+2, RichardC wrote:

 Yours is one of many Game Engines for Android.  Why should the platform
 take any Game Engine and specifically why this one?

 On Friday, November 9, 2012 4:57:37 PM UTC, sebastian_bugiu wrote:

 I have created a 3D game engine written in java for Android. It is based
 on the Ogre renderer and features

 - a complete OpenGL ES 2.0 multithreaded renderer
 - sound support
 - input as touch or sensors
 - GUI API
 - easy material creation
 - a new mesh format for fast loading based on ms3d format
 - artemis framework integration for data driven game design
 - easy to use and extensible design

 A game that will feature this engine will be released somewhere at the
 end of this month or somewhere early in December to show off the engine
 capabilities.

 From what I have seen the Android framework does not feature an API for
 game programmers so everyone has to create their own engine. Instead of this
 duplication I am asking the android developers if it could be possible to
 integrate my engine (I will open source the code) in the android framework
 so that everybody can have an easier way to create a 3D game?


 --
 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 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] A quick note on the dispatchMethodX pattern in Android

2012-11-07 Thread Satya Komatineni
When I am researching the custom components I often ran into something
I call a dispatchMethodX pattern.

Example is how draw(), onDraw() and dispatchDraw() work hand in hand
for a composite pattern like views and view groups.

I put a quick note here with also references to the design patterns

http://satyakomatineni.com/item/4348

Thanks
Satya

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


Re: [android-developers] How do I make an app that allows users to interact with each other?

2012-11-02 Thread Satya Komatineni
that is an ambitious question. :)

See a little bit of research I have done
http://satyakomatineni.com/item/4234

this space is coming to be known as BAAS (Back end as a service)

Some players are

Cocoafish - Appecelerator/Titanium now ACS
Parse
Applicasa
Stackmob
Kinvey

But thats just tip of the iceberg you are looking at. See the picture
from Kinvey at that URL all the way at the end to see the explosion.

Good luck

On Fri, Nov 2, 2012 at 6:26 PM, Jason Hsu jhsu802...@gmail.com wrote:
 How do I make an app that allows users to interact with each other?  I
 assume that this requires a central server that interacts with the app.

 Examples of such interactive apps:
 1.  Message boards
 2.  Chat rooms
 3.  Multiplayer games

 Please point me to the types of tools behind such interactive apps.

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



-- 
http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni

-- 
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] Re: How does one use fragment dialogs inside compound controls?

2012-11-01 Thread Satya Komatineni
I couldn't find a reasonable way to solve this. So I did the following
from the compound view

private FragmentManager getFragmentManager()
{
  Context c = getContext();
  if (c instanceof Activity)
  {
 return ((Activity)c).getFragmentManager();
  }
  throw new RuntimeException(Activity context expected instead);
}

Not that it doesn't work. Thought it is a reasonable compromise. Then i can do

public void onClick(View v)
   {
  Button b = (Button)v;
  if (b.getId() == R.id.fromButton)
  {
  DialogFragment newFragment = new
DatePickerFragment(this,R.id.fromButton);
   newFragment.show(getFragmentManager(),
com.androidbook.tags.datePicker);
   return;
  }

  //Otherwise
   DialogFragment newFragment = new DatePickerFragment(this,R.id.toButton);
newFragment.show(getFragmentManager(),
com.androidbook.tags.datePicker);
return;
   }//eof-onclick

Any ways if anyone is looking to see how to do compound controls that
manage their own state and also use fragment dialogs you may want to
look at my attempt at doing this

Principles of Compound Controls: A semi article
http://satyakomatineni.com/item/4341
(principles, sample code, images, and research)

Thanks
Satya

On Tue, Oct 30, 2012 at 3:40 PM, Satya Komatineni
satya.komatin...@gmail.com wrote:
 Examples of fragment dialogs look like this

 SomeActivity
 {
 public void buttonClicked(View someView)
 {
 DialogFragment newFragment = new DatePickerFragment();
 newFragment.show(getFragmentManager(), timePicker);
 }
 public static class DatePickerFragment extends DialogFragment(){  };
 }


 If you have a compound control extending a layout like a linear layout
 how do you isolate this to the view? how do you get a
 fragmentManager from the bowels of a view? or do you pass that to
 the view explicitly?

 Thank you very much for your help
 Satya



-- 
http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni

-- 
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] How does one use fragment dialogs inside compound controls?

2012-10-30 Thread Satya Komatineni
Examples of fragment dialogs look like this

SomeActivity
{
public void buttonClicked(View someView)
{
DialogFragment newFragment = new DatePickerFragment();
newFragment.show(getFragmentManager(), timePicker);   
}
public static class DatePickerFragment extends DialogFragment(){  };
}


If you have a compound control extending a layout like a linear layout
how do you isolate this to the view? how do you get a
fragmentManager from the bowels of a view? or do you pass that to
the view explicitly?

Thank you very much for your help
Satya

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


Re: [android-developers] How to do if User focussed on Edittext, menus should be displayed?

2012-10-27 Thread Satya Komatineni
Meena,
I haven't tried it. But a view seem to have a public method called
showConextMenu(). So you will set up a context menu for your control
and call showContextMenu() on focus grab. (My theory but try it out)

But more importantly, you may need to go in the direction of writing
your own input method for simulating keyboard input. Like the voice
does. So painting can be treated as another input method and register
method and see how that input method is enabled.

You may have to check literature on how to write your input methods.

http://twitter.com/SatyaKomatineni
http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com

On Sat, Oct 27, 2012 at 5:34 AM, Meena Rengarajan
meenasoft...@gmail.com wrote:
 My needs : If i click or focussed on EditText, it should call Menus . In
 Menus, i wanna create two options. That is, normal writing and keyboard
 writing.

 If user selects keyboard writing, it looks like Android Keyboard. Should be
 able to type it from keyboard. And next one, normal writing. This is like
 normal.

 In Menus, if user selects normal writing then one screen should appear when
 it is clicked like MS-Paint application . With pencil , user should be able
 to write like we'll almost write in a paint application.

 I am new to Android and learning though !

 In my code, where should i do all the Functionalities of Menus ?

 How could i do this ? Any helps or suggestion greatly appreciated !

 And this is my Code :

 else if(q.trim().equals(A))

 {
 fillUp=new EditText(context);
 fillUp.setOnClickListener(new View.OnClickListener() {
 public void onClick(View arg0) {
  }
 });
 fillUp.setBackgroundResource(R.drawable.option);
 fillUp.setId(9);
 fillUp.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
 public void onCreateContextMenu(ContextMenu arg0, View arg1,ContextMenuInfo
 arg2) {
 }
 });
 fillUp.setOnFocusChangeListener(new View.OnFocusChangeListener() {
 public void onFocusChange(View v, boolean hasFocus) {
 Toast.makeText(context, Focused, Toast.LENGTH_LONG).show();
 if (hasFocus) {
 context.getWindow();
 context.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
 }
 }
 });

 fillUp.setLayoutParams(Rl);
 fillUp.setGravity(Gravity.CENTER);
 fillUp.setId(9);
 compLayout.addView(fillUp);

 --
 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 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] Few hunches on requestLayout() and forceLayout() (Their differences)

2012-10-26 Thread Satya Komatineni
I have been doing some research for custom components. The long thread
of the research is at

http://satyakomatineni.com/item/4148

Reading the internet I have got bits and pieces about requestLayout()
and invalidate(). I think I kind of know what they are. However the
difference between requestLayout() and forceLayout() is hazy,
especially the force part.

Here is what I think is the difference: (Hope this will add to larger
corpus out there)

It is easier to tell what forceLayout() is first. It is like a touch
command in build environments. Usually when a file doesn't change the
build dependencies will ignore it. So you force that file to be
compiled by touching and thereby updating its time stamp. Just like
touch it will not invoke any build commands by itself (Unless your
build environment is too sophisticated to kick off right away.) When a
build is requested just don't ignore this file.

So when you forceLayout() a view you are marking that view (only that)
a candidate for measuring. If a view is not marked then its
onMeasure() will not be called. You can see this in the measure()
method of the view. This measure() method checks to see if this view
is marked for layout.

The behavior of requestLayout() is (only) slightly different. a
requestlayout touches the current view just like forceLayout() but
also walks up the chain touching every parent of this view until it
reaches ViewRoot. ViewRoot overrides this method and schedules a
layout pass. Because it is just a schedule to run it doesnt start the
layout pass right away. It will wait for the main thread to complete
its chores and attend the message queue.

Still, explain to me when I use forceLayout!! I understand the
requestLayout because I end up scheduling a pass. What am I doing with
forceLayout? Obviously if you are calling a requestLayout on a view
there is no point in calling forceLayout on that view. What is force
anyway?

Recall, that a force is like a touch for build!! So you are
forcing the file to compile.

When a view gets its requestLayout called, all its siblings are
untouched. They don't have this flag up. Or if the view that is
touched is a viewgroup (like when you delete a view or add a view) the
viewgroup doesn't need to calculate the sizes of the its children
because their sizes haven't changed. No point in calling their
onMeasure. But if for some reason if the view group decides that these
children needs to be measured, it will call forceLayout on each of
them followed by measure() which now correctly calls onmeasure(). It
won't call requestLayout on children because no need to trigger
another pass when i am in the middle of the current pass. (Don't
interrupt me while I am interrupting kind of deal).

That begs the question then what happens the very first time?? who
touched all views to begin with. I reason that (I haven't verified
this yet) the views start out with this flag being set!! Let me see I
will check in a minute and report again. That's what I thought.

But thats not what happens. When a view is added to a view group, the
view group makes sure the view is marked for measurement and calls a
request layout on itself.

Importantly, when do you call each?

Developers typically have more occasions to call requestLayout. For
example when you respond to a mouse click on a view to increase its
size, you do that and then you say requestLayout on that view. For
whatever reason if that doesn't do anything you are inclined to call
forceLayout as the name is quite leading. Based on what I know that
is like yelling twice. if the first yell is a no-op, second yell will
get the same response. However for some reason, on the account of your
target view changing, if you believe the size of your sibling view
will get impacted, then call its forceLayout. Of course you call the
siblings requestLayout as well but that adds a few more cycles to the
CPU but knowing what you are doing a simpler forceLayout would do.
It is also possibly common in complex layouts that are derived from
view groups where a change to a single sibling may need a measurement
of its siblings, so you want to explicitly decide if they need to
remeasure again or not.

Hope this adds to what is out there
http://twitter.com/SatyaKomatineni
http://satyakomatineni.com
http://androidbook.com
http://satyakomatineni.com/android/training

-- 
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] Re: What is the norm these days to save the state of a custom view

2012-10-25 Thread Satya Komatineni
Here is the conclusion I came to on this one

 1. Just have the activity or fragment call a dedicated save and restore 
 methods especially if the base class of your SpecialView is View.

It is not very clean doing it this way. Especially if you could do it
well (even if that meant with some extra coding) by delegating the
state management to the view itself. However this approach (due to
clarity) could be used (like in the SnakeView API sample) if your
intention is to demonstrate something else (like how a canvas works)
and not focus on view state management.

 2. Use the View's capabilities of onSaveInstanceState() and ignore the null 
 from the VIew implementation

This is an intermediate way where we are delegating the state
management to the view but used a quick and dirty approach to plug
into the framework where we don't use the BaseSavedState pattern. I
don't think this is worth the trouble unless again you are using this
to demonstrate something else. The primary problem with this is
namespace collision of the things that you stuff into the veiw state
bundle or needing to recognize your own bundle in the hierarchy.

 3. Or use the BaseSaveState pattern that is used by things like TextView etc.

I have come to the conclusion that this is the best approach. However
if you are specializing a view group there are strategies you need to
use to deal with the unique id problem.

Here is a sample source code for a CircleView that uses this approach
and is pretty complete as to what is required to create a custom view

http://satyakomatineni.com/item/4330

Thanks
http://twitter.com/SatyaKomatineni
http://satyakomatineni.com
http://androidbook.com

On Wed, Oct 24, 2012 at 9:41 AM, Satya Komatineni
satya.komatin...@gmail.com wrote:
 The literature seem to indicate a number of alterantives

 1. Just have the activity or fragment call a dedicated save and
 restore methods especially if the base class of your SpecialView is
 View.
 2. Use the View's capabilities of onSaveInstanceState() and ignore the
 null from the VIew implementation
 3. Or use the BaseSaveState pattern that is used by things like TextView etc.

 Appreciate your thoughts and comments.

 Thanks
 Satya

-- 
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] What is the norm these days to save the state of a custom view

2012-10-24 Thread Satya Komatineni
The literature seem to indicate a number of alterantives

1. Just have the activity or fragment call a dedicated save and
restore methods especially if the base class of your SpecialView is
View.
2. Use the View's capabilities of onSaveInstanceState() and ignore the
null from the VIew implementation
3. Or use the BaseSaveState pattern that is used by things like TextView etc.

Appreciate your thoughts and comments.

Thanks
Satya

-- 
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] Is it redundant to call invalidate() in the onSizeChanged method?

2012-10-22 Thread Satya Komatineni
I looked at the setFrame() method of the parent view class. This
method calls onSizeChanged() only if there is a change in size of that
view. If there is a change in size it also calls invalidate().

So am I right in thinking that it is redundant to call invalidate() in
onSizeChanged() method.

Also I don't see any difference between taking the width and height
from the onSizeChanged() or from the view methods of getTop(),
getLeft() etc. am I missing something here?

Thanks a lot
Satya

-- 
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] How come LinearLayout doesn't seem to measure wrap_content properly

2012-10-22 Thread Satya Komatineni
I am doing more research to see if this indeed is the case. But here
are the symptoms


LinearLayoutheight=wrap_conent
   textviewheight=wrap_content
  some-custom-circle-viewheight=wrap_content
  textview ..height=wrap_content
/LinearLayout

In the custom circleview constructor I set the minimum height and width.

I was hoping these minimum sizes will be used if the height of my
custom view is wrap_content. But looks like linear layout never
sends out the unspeicified but only does the 'at_most' making the
getDefaultSIze return the entire space after the first text view. In
fact the last textview is beyond the screen below.

Do I have to write onMeasure() in the custom view and deal with
wrap_content separately? why is LinearLayout not measuring the
desired size?

Your insights are greatly appreciated

Thanks
Satya

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


Re: [android-developers] How come LinearLayout doesn't seem to measure wrap_content properly

2012-10-22 Thread Satya Komatineni
Does wrap_content always result in AT_MOST?

If it says 411 pixles at most, I would have thought I will take all of
it because I could use that. I would not have thought to give back my
content size. Just thinking aloud.

what will match_parent do? Does that come in as EXACT, matching
the size of the parent?

Thank you so much for your help. It saved me hours of agony that I am
about to jump into  ...
Satya

On Mon, Oct 22, 2012 at 5:40 PM, Romain Guy romain...@android.com wrote:
 LinearLayout is doing the right thing. wrap_content results in an
 AT_MOST MeasureSpec. If you are writing a custom view that extends the
 base View class you really should override onMeasure().

 On Mon, Oct 22, 2012 at 2:33 PM, Satya Komatineni
 satya.komatin...@gmail.com wrote:
 I am doing more research to see if this indeed is the case. But here
 are the symptoms


 LinearLayoutheight=wrap_conent
textviewheight=wrap_content
   some-custom-circle-viewheight=wrap_content
   textview ..height=wrap_content
 /LinearLayout

 In the custom circleview constructor I set the minimum height and width.

 I was hoping these minimum sizes will be used if the height of my
 custom view is wrap_content. But looks like linear layout never
 sends out the unspeicified but only does the 'at_most' making the
 getDefaultSIze return the entire space after the first text view. In
 fact the last textview is beyond the screen below.

 Do I have to write onMeasure() in the custom view and deal with
 wrap_content separately? why is LinearLayout not measuring the
 desired size?

 Your insights are greatly appreciated

 Thanks
 Satya

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



 --
 Romain Guy
 Android framework engineer
 romain...@android.com

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


Re: [android-developers] Does an onDraw() get called if I don't do invalidate() but did the requestLayout()?

2012-10-21 Thread Satya Komatineni
Thank you very much. That helps.

what if the layout results in shifting a view in its placement (origin
change but not size). will that result in using the cached results of
the previous draw?


On Sat, Oct 20, 2012 at 4:19 PM, Romain Guy romain...@android.com wrote:
 requestLayout() itself does not lead to a draw pass but some views might
 react to a
 Layout change by calling invalidate.

 On Oct 20, 2012 12:59 PM, Satya Komatineni satya.komatin...@gmail.com
 wrote:

 For a UI action in the same thread:

 //On my view I call requestLayout()
 ViewRoot schedules a traversal

 //I don't call invalidate() on my view
 So, no rectangle is invalid (I am assuming that is the assertion
 because I didn't call invalidate)


 Is it possible that the layout phase may invalidate() some of the
 views? I suppose for those views that don't change their position or
 size, I am assuming onDraw() won't be called.

 Wondering if someone could comment on this.

 Thanks a lot.
 Satya

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



-- 
http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni

-- 
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] Does an onDraw() get called if I don't do invalidate() but did the requestLayout()?

2012-10-20 Thread Satya Komatineni
For a UI action in the same thread:

//On my view I call requestLayout()
ViewRoot schedules a traversal

//I don't call invalidate() on my view
So, no rectangle is invalid (I am assuming that is the assertion
because I didn't call invalidate)


Is it possible that the layout phase may invalidate() some of the
views? I suppose for those views that don't change their position or
size, I am assuming onDraw() won't be called.

Wondering if someone could comment on this.

Thanks a lot.
Satya

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


Re: [android-developers] REQUEST

2012-10-04 Thread Satya Komatineni
May be this is a long shot. But may be you can look at 3D modelling
tools like AutoDesk and see if you can export the 3D structures to be
consumed by Android.


Just a thought. I expect lot of work but worth doing... Tue, Oct 2,
2012 at 4:18 PM, ANDRÉS LEONARDO MOLINA

Good luck
http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni


moland...@gmail.com wrote:
 Hi,

 Actually I´m working in a very important project at UDFJC University In
 Colombia. I have an idea--- Create a software application about structural
 design...
 Do you give me some information of resources what I need for this
 development??? The application includes 3D Modeling, calculation of
 materials and basic costs module. I´m a little confused about how to start,
 what platforms to generate code that is compatible with android and other---

 Could you please help me???
 Some info, please let me know!!!


 Regards!

 --
 ANDRÉS LEONARDO MOLINA B.
 Tecnólogo Mecánico
 Universidad Distrital Francisco José de Caldas
 Diseñador • ezGo S.A.
 (57) 1 747 0252 Ext. 406 • 313 264 6258
 Bogotá, Colombia

 P Salva un árbol... no imprimas este e-mail si no es necesario.



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


Re: [android-developers] My AVD is super slow

2012-09-15 Thread Satya Komatineni
what is your computer and OS?

if it is windows it helps to have 4G or more. It could still be slow
but much better exprience. It further helps if you have a solid state
drive. It also helps to keep the AVD running once it has started.

http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni

On Fri, Sep 14, 2012 at 11:37 PM, _Chilling thakkar.ro...@gmail.com wrote:
 Hi All,

 I am pretty new to Android SDK. I am trying to write my first hello world
 program. The AVD that I have created is super slow in performance and I am
 pretty sure this is not ow a real world phone performs.

 Any tips on making this better ?

 My AVD is set up as

 Android 4.0.3 // assuming this is the current biggest market share and the
 right decision to code against
 CPU ARM
 SD card size 512 mB
 Skin - Default WVGA800

 lcd density: 240
 cpumodel: cortex-a8
 vm.headsize:48
 vm.ramsize: 512

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


i

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


Re: [android-developers] GL_POINTS not drawing points

2012-09-02 Thread Satya Komatineni
Sorry this line

Finally to get your gl_position = mvp * gl_position; and not the other way.

should read

Finally to get your gl_position = mvp * positionAttributeVariable; and not
the other way.

On Sat, Sep 1, 2012 at 11:10 PM, Satya Komatineni 
satya.komatin...@gmail.com wrote:

 Guich,
 Given a number of ways how to do the same thing in OpenGL it will be quite
 hard to debug.

 On Sat, Sep 1, 2012 at 9:11 AM, guich guiha...@gmail.com wrote:

 Hi,

 I've spent a full day trying to draw a series of points using GL_POINTS.
 I know i could use a texture, but i want to learn how to draw points. The
 resulting image (zoomed) is shown here:

 The code is written below. Any help on why are only 4 points appearing is
 greatly appreciated. Although it is possible to create your model, view,
 and projection matrices, it is better to use Matrix class and use the
 methods available on that class to generate the required matrices.


 To get the view matrix you can call
 Matrix.setLookAtM(viewMatrix)

 To get the projection matrix
 Matrix.frustumM(projectionMatrix)

 Then you can get your ModelViewProjection matrix by doing
 Matrix.multiplyMM(mvp, projmatrix, viewmatrix)

 Finally to get your gl_position = mvp * gl_position; and not the other way.

 I would start with a simple program that works and then gradually increase
 the complexity. A triangle or a square is a good place to start and then
 make it work using the examples in the tutorial on the android developer
 site.

 If there is a specific issue that you are not clear ask that specifically
 and you may be able to debug it that way

 http://satyakomatineni.com/android/training
 http://satyakomatineni.com
 http://androidbook.com
 http://twitter.com/SatyaKomatineni



 https://lh5.googleusercontent.com/-lelPSZoY4dw/UEIH5mVQfII/AD4/o5q5GMFuL00/s1600/points.png

 public class MainActivity extends Activity
 {
class MyGLSurfaceView extends GLSurfaceView
{
   public MyGLSurfaceView(Context context)
   {
  super(context);

  setEGLContextClientVersion(2); // Create an OpenGL ES 2.0
 context.
  setEGLConfigChooser(8, 8, 8, 8, 0, 0);
  getHolder().setFormat(PixelFormat.RGBA_);
  setRenderer(new MyGLRenderer()); // Set the Renderer for drawing
 on the GLSurfaceView
 // setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); // Render
 the view only when there is a change in the drawing data (must be after
 setRenderer!)
   }
}

public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(new MyGLSurfaceView(this));
}
 }

 class MyGLRenderer implements GLSurfaceView.Renderer
 {
byte[][] bitmap = {
  {1,1,1,1,1,1,1,1},
  {1,0,0,1,1,0,0,1},
  {1,0,0,1,1,0,0,1},
  {1,0,0,1,1,0,0,1},
  {1,0,0,1,1,0,0,1},
  {1,0,0,1,1,0,0,1},
  {1,0,0,1,1,0,0,1},
  {1,0,0,1,1,0,0,1},
  {1,1,1,1,1,1,1,1}};

static final int COORDS_PER_VERTEX = 3;

// Set color with red, green, blue and alpha (opacity) values
float color[] = { 0,0,0, 1.0f };
float coords[] = new float[4 * COORDS_PER_VERTEX];
int w,h;

public void onSurfaceCreated(GL10 unused, EGLConfig config)
{
}

public void onDrawFrame(GL10 unused)
{
   try
   {
  drawText();
   } catch (Exception e) {debug(e.getMessage());}
}

private String vertexShaderCode(int w, int h)
{
   return // http://www.songho.ca/opengl/gl_projectionmatrix.html
  attribute vec4 vPosition; +
  mat4 projectionMatrix = mat4( 2.0/+w+.0, 0.0, 0.0, -1.0,+
   0.0, -2.0/+h+.0, 0.0, 1.0,+
   0.0, 0.0, -1.0, 0.0,+
   0.0, 0.0, 0.0, 1.0);+
  void main() {gl_Position = vPosition*projectionMatrix;}; //
 the matrix must be included as a modifier of gl_Position
}

private final String fragmentShaderCode =
   precision mediump float; +
   uniform vec4 vColor; +
   void main() {gl_FragColor = vColor;};

private int mProgram;
private int mPositionHandle;
private int mColorHandle;

public void onSurfaceChanged(GL10 unused, int width, int height)
{
   w = width; h = height;
   // Adjust the viewport based on geometry changes, such as screen
 rotation
   GLES20.glViewport(0, 0, width, height);

   // prepare shaders and OpenGL program
   int vertexShader =
 MyGLRenderer.loadShader(GLES20.GL_VERTEX_SHADER,vertexShaderCode(width,height));
   int fragmentShader =
 MyGLRenderer.loadShader(GLES20.GL_FRAGMENT_SHADER,fragmentShaderCode);

   mProgram = GLES20.glCreateProgram(); // create empty
 OpenGL Program
   GLES20.glAttachShader(mProgram, vertexShader);   // add the vertex
 shader to program
   GLES20.glAttachShader(mProgram, fragmentShader); // add the
 fragment shader to program

Re: [android-developers] GL_POINTS not drawing points

2012-09-02 Thread Satya Komatineni
I am on my way to take my kids to the beach. I will look at it a bit closer
next week. May be just give me the simple problem defintion and I will try
to create the program for you and send the zip file.

ButI will try a quick answer

Say you want a 20x20 graph.

Specify your point vertices as (0,0) (1,1,)(5,5) all x,y and specify the z
as 0 if needed.

Then you need to set your camera using

Matrix.setLookAtM(mVMatrix, 0, 0, 0, -15, 0f, 0f, 0f, 0f, 1.0f, 0.0f);

This is saying set your camera on the 'z' axis at -15 and look at the
origin (0,0,0) and make it look up (0,1,0) See the docs for full detail.
This populate your client memory mVMatrix.

then do

//take your width and height of the window and do
float ratio = (float) w / h;
Matrix.frustumM(mProjMatrix, 0, -ratio * 30, ratio * 30, -30 //top,
30//bottom, 3, 7);

Read up on frustum to give it enough height and width and some depth to fit
your coords. You get the projection matrix.

Now do Matrix.Multiply to do

final MVP = projection * mVMarix;

then send your position attributes to the shader and in the shader

gl_position = final MVP * your_position_attribute; //like all matrix
multiplications order is important


On Sun, Sep 2, 2012 at 10:39 AM, Satya Komatineni 
satya.komatin...@gmail.com wrote:

 Sorry this line

 Finally to get your gl_position = mvp * gl_position; and not the other way.


 should read

 Finally to get your gl_position = mvp * positionAttributeVariable; and not
 the other way.


 On Sat, Sep 1, 2012 at 11:10 PM, Satya Komatineni 
 satya.komatin...@gmail.com wrote:

 Guich,
 Given a number of ways how to do the same thing in OpenGL it will be
 quite hard to debug.

 On Sat, Sep 1, 2012 at 9:11 AM, guich guiha...@gmail.com wrote:

 Hi,

 I've spent a full day trying to draw a series of points using GL_POINTS.
 I know i could use a texture, but i want to learn how to draw points. The
 resulting image (zoomed) is shown here:

 The code is written below. Any help on why are only 4 points appearing
 is greatly appreciated. Although it is possible to create your model, view,
 and projection matrices, it is better to use Matrix class and use the
 methods available on that class to generate the required matrices.


 To get the view matrix you can call
 Matrix.setLookAtM(viewMatrix)

 To get the projection matrix
 Matrix.frustumM(projectionMatrix)

 Then you can get your ModelViewProjection matrix by doing
 Matrix.multiplyMM(mvp, projmatrix, viewmatrix)

 Finally to get your gl_position = mvp * gl_position; and not the other
 way.

 I would start with a simple program that works and then gradually
 increase the complexity. A triangle or a square is a good place to start
 and then make it work using the examples in the tutorial on the android
 developer site.

 If there is a specific issue that you are not clear ask that specifically
 and you may be able to debug it that way

 http://satyakomatineni.com/android/training
 http://satyakomatineni.com
 http://androidbook.com
 http://twitter.com/SatyaKomatineni



 https://lh5.googleusercontent.com/-lelPSZoY4dw/UEIH5mVQfII/AD4/o5q5GMFuL00/s1600/points.png

 public class MainActivity extends Activity
 {
class MyGLSurfaceView extends GLSurfaceView
{
   public MyGLSurfaceView(Context context)
   {
  super(context);

  setEGLContextClientVersion(2); // Create an OpenGL ES 2.0
 context.
  setEGLConfigChooser(8, 8, 8, 8, 0, 0);
  getHolder().setFormat(PixelFormat.RGBA_);
  setRenderer(new MyGLRenderer()); // Set the Renderer for
 drawing on the GLSurfaceView
 // setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); // Render
 the view only when there is a change in the drawing data (must be after
 setRenderer!)
   }
}

public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(new MyGLSurfaceView(this));
}
 }

 class MyGLRenderer implements GLSurfaceView.Renderer
 {
byte[][] bitmap = {
  {1,1,1,1,1,1,1,1},
  {1,0,0,1,1,0,0,1},
  {1,0,0,1,1,0,0,1},
  {1,0,0,1,1,0,0,1},
  {1,0,0,1,1,0,0,1},
  {1,0,0,1,1,0,0,1},
  {1,0,0,1,1,0,0,1},
  {1,0,0,1,1,0,0,1},
  {1,1,1,1,1,1,1,1}};

static final int COORDS_PER_VERTEX = 3;

// Set color with red, green, blue and alpha (opacity) values
float color[] = { 0,0,0, 1.0f };
float coords[] = new float[4 * COORDS_PER_VERTEX];
int w,h;

public void onSurfaceCreated(GL10 unused, EGLConfig config)
{
}

public void onDrawFrame(GL10 unused)
{
   try
   {
  drawText();
   } catch (Exception e) {debug(e.getMessage());}
}

private String vertexShaderCode(int w, int h)
{
   return // http://www.songho.ca/opengl/gl_projectionmatrix.html
  attribute vec4 vPosition; +
  mat4 projectionMatrix = mat4( 2.0/+w+.0, 0.0, 0.0, -1.0

Re: [android-developers] GL_POINTS not drawing points

2012-09-01 Thread Satya Komatineni
Guich,
Given a number of ways how to do the same thing in OpenGL it will be quite
hard to debug.

On Sat, Sep 1, 2012 at 9:11 AM, guich guiha...@gmail.com wrote:

 Hi,

 I've spent a full day trying to draw a series of points using GL_POINTS. I
 know i could use a texture, but i want to learn how to draw points. The
 resulting image (zoomed) is shown here:

 The code is written below. Any help on why are only 4 points appearing is
 greatly appreciated. Although it is possible to create your model, view,
 and projection matrices, it is better to use Matrix class and use the
 methods available on that class to generate the required matrices.


To get the view matrix you can call
Matrix.setLookAtM(viewMatrix)

To get the projection matrix
Matrix.frustumM(projectionMatrix)

Then you can get your ModelViewProjection matrix by doing
Matrix.multiplyMM(mvp, projmatrix, viewmatrix)

Finally to get your gl_position = mvp * gl_position; and not the other way.

I would start with a simple program that works and then gradually increase
the complexity. A triangle or a square is a good place to start and then
make it work using the examples in the tutorial on the android developer
site.

If there is a specific issue that you are not clear ask that specifically
and you may be able to debug it that way

http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni



 https://lh5.googleusercontent.com/-lelPSZoY4dw/UEIH5mVQfII/AD4/o5q5GMFuL00/s1600/points.png

 public class MainActivity extends Activity
 {
class MyGLSurfaceView extends GLSurfaceView
{
   public MyGLSurfaceView(Context context)
   {
  super(context);

  setEGLContextClientVersion(2); // Create an OpenGL ES 2.0 context.
  setEGLConfigChooser(8, 8, 8, 8, 0, 0);
  getHolder().setFormat(PixelFormat.RGBA_);
  setRenderer(new MyGLRenderer()); // Set the Renderer for drawing
 on the GLSurfaceView
 // setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); // Render
 the view only when there is a change in the drawing data (must be after
 setRenderer!)
   }
}

public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(new MyGLSurfaceView(this));
}
 }

 class MyGLRenderer implements GLSurfaceView.Renderer
 {
byte[][] bitmap = {
  {1,1,1,1,1,1,1,1},
  {1,0,0,1,1,0,0,1},
  {1,0,0,1,1,0,0,1},
  {1,0,0,1,1,0,0,1},
  {1,0,0,1,1,0,0,1},
  {1,0,0,1,1,0,0,1},
  {1,0,0,1,1,0,0,1},
  {1,0,0,1,1,0,0,1},
  {1,1,1,1,1,1,1,1}};

static final int COORDS_PER_VERTEX = 3;

// Set color with red, green, blue and alpha (opacity) values
float color[] = { 0,0,0, 1.0f };
float coords[] = new float[4 * COORDS_PER_VERTEX];
int w,h;

public void onSurfaceCreated(GL10 unused, EGLConfig config)
{
}

public void onDrawFrame(GL10 unused)
{
   try
   {
  drawText();
   } catch (Exception e) {debug(e.getMessage());}
}

private String vertexShaderCode(int w, int h)
{
   return // http://www.songho.ca/opengl/gl_projectionmatrix.html
  attribute vec4 vPosition; +
  mat4 projectionMatrix = mat4( 2.0/+w+.0, 0.0, 0.0, -1.0,+
   0.0, -2.0/+h+.0, 0.0, 1.0,+
   0.0, 0.0, -1.0, 0.0,+
   0.0, 0.0, 0.0, 1.0);+
  void main() {gl_Position = vPosition*projectionMatrix;}; // the
 matrix must be included as a modifier of gl_Position
}

private final String fragmentShaderCode =
   precision mediump float; +
   uniform vec4 vColor; +
   void main() {gl_FragColor = vColor;};

private int mProgram;
private int mPositionHandle;
private int mColorHandle;

public void onSurfaceChanged(GL10 unused, int width, int height)
{
   w = width; h = height;
   // Adjust the viewport based on geometry changes, such as screen
 rotation
   GLES20.glViewport(0, 0, width, height);

   // prepare shaders and OpenGL program
   int vertexShader =
 MyGLRenderer.loadShader(GLES20.GL_VERTEX_SHADER,vertexShaderCode(width,height));
   int fragmentShader =
 MyGLRenderer.loadShader(GLES20.GL_FRAGMENT_SHADER,fragmentShaderCode);

   mProgram = GLES20.glCreateProgram(); // create empty
 OpenGL Program
   GLES20.glAttachShader(mProgram, vertexShader);   // add the vertex
 shader to program
   GLES20.glAttachShader(mProgram, fragmentShader); // add the fragment
 shader to program
   GLES20.glLinkProgram(mProgram);  // create OpenGL
 program executables
   GLES20.glUseProgram(mProgram); // Add program to OpenGL environment

   // get handle to fragment shader's vColor member
   mColorHandle = GLES20.glGetUniformLocation(mProgram, vColor);
   

Re: [android-developers] Android custom view (very basic)

2012-08-28 Thread Satya Komatineni
Victor,
I am not entirely sure. But I can suggest a couple of experiments to
debug. May be inheriting a View directly is too simplisitic. Try
inheriting a TextView first. And if it works then you can look at what
other base methods of the View you will need to inherit.

Take a look at this item from the docs

http://developer.android.com/training/custom-views/custom-drawing.html

to see what other methods you need to override.

Also if you are intending to use some custom attributes you may want
to look at some detailed notes I have gathered at

http://satyakomatineni.com/item/4169

This goes into how attrs.xml and declare styleables work.

Also let me know what you find.
Thanks
Satya
http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni
On Mon, Aug 27, 2012 at 2:09 PM, Victor Reboucas vcsrebou...@gmail.com wrote:
 Hi, I'm new to Android development and I'm trying to implement a custom view
 to act as a custom menu button for my app.

 I followed the instructions at
 http://developer.android.com/training/custom-views/create-view.html but by
 the end of the implementation I get a message saying Unfortunately
 customviews1 has stopped and the app just shut's down.

 My approach is very simple and I cannot find any reference about solving
 this basic problem. Here's what I'm doing:

 1. create a new Android project in Eclipse named customviews1

 2. I run the project and it shows a Hello World TextView on the
 activity_main.xml layout file

 3. I add a new class that extends View to the src folder of the project:

 public class MyCustomView extends View {

 public MyCustomView(Context context, AttributeSet attrs) {
 super(context, attrs);
 }

 }

 4. I remove the TextView from activity_main.xml and add a customview1 to
 it:


 RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android;
 xmlns:tools=http://schemas.android.com/tools;
 android:layout_width=match_parent
 android:layout_height=match_parent

 com.example.customviews1.MyCustomView android:id=@+id/myCustomView1 /
 /RelativeLayout

 5. I run the app again and I got the message saying Unfortunately
 customviews1 has stopped and the app shuts down.


 Is there any code I'm missing here?


 Thanks for any clue,
 Regards,
 Victor Reboucas







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


Re: [android-developers] Are there any official Google sponsored training seminars/classes, etc?

2012-08-28 Thread Satya Komatineni
See if something like this helps

http://androidbook.com/training

Also if you have a set number of folks (about 10) I don't mind
travelling with in the US for a week to teach.

http://androidbook.com/training
http://androidbook.com
http://satyakomatineni.com
http://twitter.com/SatyaKomatineni

On Tue, Aug 28, 2012 at 4:00 PM, RKS sean.sambor...@live.com wrote:
 I'm looking for information on officially sponsored training
 seminars/classes etc? I'm not really interested in online but will take some
 info on that if you have it. What I'm really interested in are
 seminars/courses that you pay for, have to go to the location, and take
 classes ranging from fundamentals to advanced. I've seen a couple of
 workshops posted around the interwebs and these might be just as productive
 as something Google sponsors but without any reviews or anything I don't
 know how comfortable I am giving just anyone $1K+ on an advertisement for
 training.

 Local colleges have options as well, but mainly I'm looking for more of a
 workshop style that isn't intending on teaching you from scratch. We've got
 guys who are already senior programmers in other languages that are not
 going to be interested in going to school for a semester! A week long course
 would be perfect to go out and bring home a few things.

 So does anyone know of anything like that?

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


Re: [android-developers] How do I read an XML Data in Android?

2012-08-27 Thread Satya Komatineni
See if this SDK doc helps

http://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html

Here is some earlier research I have done on XML treatment on Android
(This may be a bit outdated as I haven't revisited it in a year)

What XML libraries are available for Android
http://satyakomatineni.com/item/3731

http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni


On Sun, Aug 26, 2012 at 9:36 AM, Guilherme Bernardi
gui.bernard...@gmail.com wrote:
 I'm developing an application that uses XML data...

 I consumed an wcf web service with SOAP, convert the object to a basic XML
 and save on sdcard, but now I need to read this data file to edit, confer
 and save?

 How can I do that? Can anyone help me?

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


Re: [android-developers] First android app

2012-08-22 Thread Satya Komatineni
If you are still looking for advice I have created a note a while ago called

How I have learned Android SDK: An authors note
http://www.satyakomatineni.com/item/3784

See if this is of some help
(Disclosure: Yes I do have a book on the subject)


http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni

On Wed, Aug 22, 2012 at 11:13 AM, cham herbias cham.herb...@gmail.comwrote:

 im sorry. what do you mean notepad example?


 On Wed, Aug 22, 2012 at 8:07 AM, Michael Leung michaelchi...@gmail.comwrote:

 Start with Notepad Example, that is good

 On Thu, Aug 23, 2012 at 1:01 AM, cham herbias cham.herb...@gmail.comwrote:

 Thank you for the help nirav. i appreciate it.


 On Tue, Aug 21, 2012 at 6:44 AM, Nirav Parmar n.parma...@gmail.comwrote:

 Hello Cham,
 In my opinion Developer site is best..it has good examples..Also you
 can download API demos for each platform.You can learn lot from that
 demos.. Best of luck..

 Regards,
 Nirav

 On Tue, Aug 21, 2012 at 2:29 PM, cham herbias 
 cham.herb...@gmail.comwrote:

 I am a computer engineering student. Can you help me with some
 suggestions about basic android app? . I have a very basic background of
 android programming and i want to learn more.

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




 --
 Regards,

 Nirav Parmar.


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




 --

archie herbias
  http://www.earnmailer.com/link/6ab51cbaff12bf5f
  http://www.earnmailer.com/alert/confirm/6ab51cbaff12bf5f
  http://www.earnmailer.com/

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




 --
 Regards,
 Michael Leung
 http://www.itblogs.info - My IT Blog
 http://diary.skynovel.info - My Blog
 http://www.michaelleung.info - My Homepage

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




 --

archie herbias
  http://www.earnmailer.com/link/6ab51cbaff12bf5f
  http://www.earnmailer.com/alert/confirm/6ab51cbaff12bf5f
  http://www.earnmailer.com/

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

Re: [android-developers] Back face culling

2012-08-20 Thread Satya Komatineni
Hi,

I don't see any image except a blank screen. There may be, and quite
likely, more reasons why your figure is not showing (if it is not showing).
You may want to check your eye positioning, check your view port, check
your frustum etc. More importantly close trace your sample that works and
the one that doesn't.

Now coming to winding I believe the following triangles are would in the
opposite to the rest

The wrong ones are:

7,6,3
7,4,5
0,1,5
2,6,5


Because if you spin a right hand screw in that order the screw needs to
go-in or come-out facing the outside of the cube's surface. By that
logic they are likely
7,3,6
7,5,4
0,5,1
2,5,6

But again even if they were wrong you would have seen something on the
screen.

Here is a quick note on winding and hiding a hidden surface
http://satyakomatineni.com/item/4230

Here is how to hide hidden surfaces
http://satyakomatineni.com/item/4192

Here are my notes on as I have been working through OpenGL
http://satyakomatineni.com/item/opengl

If it helps here is a free chapter on OpenGL 1.1 and a bit on ES 2.0
http://www.satyakomatineni.com/akc/display?url=DisplayNoteIMPURLreportId=4060downerUserId=satya


Hope that helps
Satya
http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni

On Sun, Aug 19, 2012 at 7:57 PM, Braindrool cawehk...@gmail.com wrote:

 I have returned to this group, once again. In search of assistance.
 Dealing with OpenGL ES 1.0, I'm having trouble getting back face culling to
 work. I have been following a variety of random tutorials that I've found
 for OpenGL, but this 
 onehttp://www.droidnova.com/android-3d-game-tutorial-part-v,376.htmlin 
 particular. The sample code works fine, but I'm not sure what I'm doing
 wrong. All I know is that it is about how I wind the vertices into the
 index buffer.

 For instance, I try to create a cube. I get this.

 http://imgur.com/07nbH.png


 The vertices / indices for that would be:

 [code]float[] coords = {
 -0.5f, 0.5f, -0.5f,
 -0.5f, -0.5f, -0.5f,
 0.5f, -0.5f, -0.5f,
 0.5f, 0.5f, -0.5f,
 -0.5f, 0.5f, 0.5f,
 -0.5f, -0.5f, 0.5f,
 0.5f, -0.5f, 0.5f,
 0.5f, 0.5f, 0.5f,

 };

 short[] indices = new short[] {
  //Front
 0,1,2,
 2,3,0,
  //Right
 3,2,6,
 7,6,3,
  //Back
 7,6,5,
 7,4,5,
  //Left
 0,1,5,
 0,4,5,
  //Bottom
 1,5,2,
 2,6,5,
  //Top
 0,3,4,
 3,7,0,

 };[/code]


 No idea what I'm doing wrong, help greatly appreciated!

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

Re: [android-developers] Re: Back face culling

2012-08-20 Thread Satya Komatineni
No difference at all where you start.

On Mon, Aug 20, 2012 at 4:27 PM, Braindrool cawehk...@gmail.com wrote:

 Your fix didn't work, but something I am getting confused about. Does it
 matter what vertex is the starting point in a counter clockwise winding?
 Example:

 http://i.imgur.com/Yn4Zd.png

 Would it matter if you go:

 0,1,3,
 3,1,2


 or
 1,3,0,
 1,2,3?

 Any difference?

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




-- 
http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni

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

Re: [android-developers] OpenGL using multiple classes

2012-08-16 Thread Satya Komatineni
Hopefully you have a good reason to structure  your classes they way
you have done.

To start BlaRenderer is a proper derived class that will get called.
So this is a concrete class by itself.

Number 2, the player class looks more like a utilitiy class and hence
doesn't need to derive from BlaRenderer. In your code I don't see the
Player class playing the role of a renderer.

Number 3, BlaRenderer has a local variable pointing to a Player class.
So the variables of Player class are physically separate from the
variables of BlaRenderer. if your intention is to have the Player as a
utility class, then

1. Don't inherit from Renderer
2. Remove the local variables in the BlaRenderer which are now
controlled by Renderer

Hope that helps
http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni


On Wed, Aug 15, 2012 at 8:37 PM, Braindrool cawehk...@gmail.com wrote:
 I've been programming for years, but I have very little experience with 3D
 graphics. I thought OpenGL would be the most efficient in this project. It's
 coming along alright, I am still studying the API and documentation. But I
 have encountered a problem using multiple classes. For instance, here I try
 to use a separate class for the player model. (Yes, currently it's just a
 cube.)

 Renderer:

 Code:

 package com.braindrool.bla;

 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.FloatBuffer;
 import java.nio.ShortBuffer;

 import javax.microedition.khronos.egl.EGLConfig;
 import javax.microedition.khronos.opengles.GL10;

 import android.opengl.GLSurfaceView.Renderer;

 public class BlaRenderer implements Renderer {

   int nrOfVertices;
   float A;
   Player player = new Player();

   public void onSurfaceCreated(GL10 gl, EGLConfig config) {
   // TODO Auto-generated method stub

   gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
   gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

   gl.glEnable(GL10.GL_CULL_FACE);

   gl.glFrontFace(GL10.GL_CCW);
   gl.glCullFace(GL10.GL_BACK);

   gl.glClearColor(0.3f, 0.8f, 0.9f, 1);

   //  initTriangle();
   player.initPlayer();

   }

   public void onDrawFrame(GL10 gl) {
   // TODO Auto-generated method stub

   

   gl.glLoadIdentity();

   gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

   // gl.glRotatef(A * 2, 1f, 0f, 0f);
   // gl.glRotatef(A, 0f, 1f, 0f);
   //
   // gl.glColor4f(0.5f, 0, 0, 1);

   gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
   gl.glColorPointer(4, GL10.GL_FLOAT, 0, colorBuffer);
   gl.glDrawElements(GL10.GL_TRIANGLES, nrOfVertices,
   GL10.GL_UNSIGNED_SHORT, indexBuffer);
   // A++;

   }

   public void onSurfaceChanged(GL10 gl, int width, int height) {
   // TODO Auto-generated method stub
   gl.glViewport(0, 0, width, height);

   }

   private FloatBuffer vertexBuffer;
   private ShortBuffer indexBuffer;

   private FloatBuffer colorBuffer;

   private void initTriangle() {

   float[] coords = { 0, 0.5f, 0, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 
 0.5f,
   0, 0, -0.5f };

   nrOfVertices = coords.length;

   ByteBuffer vbb = ByteBuffer.allocateDirect(nrOfVertices * 3 * 
 4);
   vbb.order(ByteOrder.nativeOrder());
   vertexBuffer = vbb.asFloatBuffer();

   ByteBuffer ibb = ByteBuffer.allocateDirect(nrOfVertices * 2);
   ibb.order(ByteOrder.nativeOrder());
   indexBuffer = ibb.asShortBuffer();

   ByteBuffer cbb = ByteBuffer.allocateDirect(4 * nrOfVertices * 
 4);
   cbb.order(ByteOrder.nativeOrder());
   colorBuffer = cbb.asFloatBuffer();

   float[] colors = { 1f, 0f, 0f, 1f, // point 1
   0f, 1f, 0f, 1f, // point 2
   0f, 0f, 1f, 1f, // point 3
   };

   short[] indices = new short[] {
   // indices
   0, 1, 2, 0, 2, 3, 0, 3, 1, 3, 1, 2

   };

   vertexBuffer.put(coords);
   indexBuffer.put(indices);
   colorBuffer.put(colors);

   vertexBuffer.position(0);
   indexBuffer.position(0);
   colorBuffer.position(0);

   }

 }

 And now the player class.

 Code:

 package com.braindrool.bla;

 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.FloatBuffer;
 import java.nio.ShortBuffer;

 import javax.microedition.khronos.egl.EGLConfig;
 import javax.microedition.khronos.opengles.GL10;

 public class Player extends BlaRenderer{

   

Re: [android-developers] Can't make new Android project in Eclipse.

2012-08-16 Thread Satya Komatineni
Johannes,
Your tools may be more recent. Otherwise an android application
project is similar to android project in earlier tool versions.
There should be enough parallels to extrapolate.

http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni

On Sun, Aug 12, 2012 at 10:53 AM, Johannes johannesmoe...@gmail.com wrote:
 Hey guys. I'm trying to make an application for Android in Eclipse.
 However when I try to follow guides like this one: 
 http://androidcodemonkey.blogspot.dk/2010/01/hello-world-your-first-android.html

 I get a problem from the start. When I go to File  New there is no Android 
 Project even though I installed multiple Android packages to Eclipse. All i 
 can find is under file  new  project  Android and then things like 
 Android Application Project and Android Sample Project. However these are 
 not alike the once i see in the tutorial.

 I hope anyone got the answer for why I can't make an Android Application like 
 the one in the tutorial.

 Thanks - Johannes.

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


Re: [android-developers] App Not Installed

2012-08-16 Thread Satya Komatineni
Where are you installing the app? are you doing it on the emulator or
a real device? If it is a real device you can do that with out
creating an unsigned package directly through eclipse. Otherwise you
will need to sign it to install on the device as a proper app.

And the image you have included seem to have lot of Java errors. It is
not clear from the image what they are. You have to debug them or show
someone that is close by to you to take a look.

http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni

On Sun, Aug 12, 2012 at 10:36 AM, EeLeng Tee marcusel...@gmail.com wrote:
 Hello..
 Im new to eclipse.
 I've tried to play with android sample project from SDK.
 I export any project to unsigned apk file and install it
 But comes out App not installed message.
 Everything looks fine but just cant be installed.
 Anyone help? Thanks

 Oh ya i also encountered this problem which is java problem shown.

 http://i50.tinypic.com/r7rdkz.png

 Hope you guys can help because its important for my final year project =)

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


Re: [android-developers] Error in an XML file: aborting build.

2012-08-16 Thread Satya Komatineni
You typically install the .apk file on the emulator or the device
and then locate the icon for your application and use that icon to
click on it to run.

If you are using eclipse, you can use eclipse to run the project
automatically on the emulator or the device. (Eclipse will compile and
make the .apk file, and loads it and also starts the application
automatically with out locating the icon).

The typical sequence of events are

1. Get your source code
2. Make a project in eclipse
3. Compile the project in eclipse (Eclispse is usually set to
auto-compile the project)
4. Create an emulator (AVD) that matches with the SDK API level that
is used to compile the project
5. Use eclipse to run that project on that specific AVD
6. You can also use the real device instead (But it can be a bit
involved in having the eclipse identify the device)


http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni


On Fri, Aug 10, 2012 at 3:58 PM, James Spinella jimmyco2...@gmail.com wrote:
 Hey all,

 I'm brand new to Android development, well except for rooting, custom ROMs,
 etc. I'm going through Google's lessons in development, and I'm stuck at
 the part where it says to run my app that it just had me make... I've tried
 USB Debugging with my phone, as well as the emulator and whenever I try to
 run activity_main.xml, I get the aforementioned error.

 I have a feeling I am trying to run the wrong thingis this what Google
 wants me to run as per
 http://developer.android.com/training/basics/firstapp/running-app.html ?

 It has to be the wrong thing, I followed directions to a tee

 --
 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 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] Kudos: Android Team, You have done a fantastic job on OpenGL documentation

2012-07-24 Thread Satya Komatineni
http://developer.android.com/guide/topics/graphics/opengl.html

The lessons and tutorials here are excellent!
http://developer.android.com/training/graphics/opengl/index.html

Real thanks
http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni

-- 
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] A free article on Android custom attributes

2012-06-15 Thread Satya Komatineni
It turns out there is a little bit of depth to android custom
attributes. These are the XML attributes that you can use for your own
custom views in layout files.

I have collected my research notes into a proper article and posted it at

http://satyakomatineni.com/item/4169

This article will answer the following questions

What are custom attributes?
Why use custom attributes?
How do you code a custom class?
How do you specify a custom attribute?
Do you have to define a custom attribute to Android?
Where do you have to define a custom attribute to Android?
What is AttributeSet?
What is TypedArray?
How do you read a custom attribute in your java code?
What is the styleable tag?
What is attrs.xml?
Does the name of a styleable tag need to match your java custom view name?
How do you declare a namespace for your custom attribute?
Do you need to declare your namespace differently if you have a sub package?
Do you need to specify package/sub-package name for your custom view
class in a styleable?
Does an attribute name has to be unique in your entire package?
Can a styleable grouping avoid attribute name uniqueness constraint?

http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni

-- 
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] what are the restrictions on the declare-styleable name attribute? (Does it allow sub packages?)

2012-05-22 Thread Satya Komatineni
what happens if I have two custom views

com.mycompany.projectname.CustomView
com.mycompany.projectname.subpkg.CustomView

How do I declare styleable resoruce for these classes? (of course I
can name them differently, but is that the only way?)

Here is an example

resources
declare-styleable name=CustomView
   .
/declare-styleable
/resources

would I then do for the second sub package custom view?

resources
declare-styleable name=subpkg.CustomView
   .
/declare-styleable
/resources

If so how does the constant

R.styleable.CustomView

look for the sub pakcage subpkg.CustomView?

I suppose I can try it and see but If one of you is kind enough to
throw some light

Thanks
http://satyakomatineni.com/android/training
http://satyakomatineni.com
http://androidbook.com
http://twitter.com/SatyaKomatineni

-- 
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] 5 free chapters from the previous editions of Pro Android

2012-03-29 Thread Satya Komatineni
I have made available some valuable published content from the
previous editions of Pro Android for free. we had to remove these
chapters from our latest edition ProAndroid 4
(http://androidbook.com/proandroid4)  due to size and other reasons.

The chapters are

OpenGL
Search API
Live Folders
Text to Speech
Titaninum

These 5 free android sdk chapters are avilable at

http://androidbook.com/item/4060

Bootstrapping developers on the Android SDK
http://twitter.com/SatyaKomatineni
http://androidbook.com/training
http://satyakomatineni.com
http://androidbook.com

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


Re: [android-developers] onUpdate function is never being called from widget

2012-01-02 Thread Satya Komatineni
Do you have a widget configurator activity? if so the first onUpdate() is
not going to get called but subsequent onUpdates() will.

Also if you were to overload onReceive() make sure you call the parent
onReceive() otherwise you are disabling yourself from calling the rest of
the widget callbacks.

Good luck with your debugging

Satya

On Fri, Dec 30, 2011 at 12:31 PM, Eyal T elt...@gmail.com wrote:

 Hi all

 I try create a clickable widget.
 I saw that the clickable notification is not configured because
 onUpdate function is never being called (so I cannot set the
 notification)
 * I did not saw the log in the LogCat so I assume that the function is
 never being called
 * The Log in the onRecieve is being execute when I add the widget to
 the screen, and once in 30 minutes.


 Can anyone help me?

 Thanks Eyal


 public class AnimationWidget extends AppWidgetProvider {
public static int imageNumber = 0;
private static final String ACTION_WIDGET_RECEIVER =
 ActionRecieverWidget;




   /** Called when the activity is first created. */



   @Override
   public void onUpdate(Context context, AppWidgetManager
 appWidgetManager,
 int[] appWidgetIds) {

  Log.i(print from main, widget id: );

 }

 @Override
public void onReceive(Context context, Intent intent) {


   Log.i(print from main, onReceive  +
 intent.getAction());
 }

 manifest xmlns:android=http://schemas.android.com/apk/res/android;
  package=com.animation.widget
  android:versionCode=1
  android:versionName=1.0
uses-sdk android:minSdkVersion=7 android:targetSdkVersion=7/

   !-- Broadcast Receiver that will process AppWidget updates --
application android:icon=@drawable/pic android:label=@string/
 app_name
   receiver android:name=.AnimationWidget
 android:label=@string/app_name
 intent-filter
 action
 android:name=android.appwidget.action.APPWIDGET_UPDATE /
  /intent-filter
 meta-data
 android:name=android.appwidget.provider
  android:resource=@xml/widget_info /
   /receiver
   service android:name=.AnimationWidget$UpdateService /



   /application

uses-permission android:name=android.permission.INTERNET /
uses-permission android:name=android.permission.WAKE_LOCK /
 /manifest

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




-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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

Re: [android-developers] Emulator takes 15 minutes to start an app, something wrong ?

2011-12-13 Thread Satya Komatineni
I ran for 2 years on 2Gig of RAM. With ICS, on a spur, I have paid 30
dollars to upgrade my 2 year old laptop to 4Gig of RAM.

Everything runs so much better. 2 Gig for a tablet emulator on windows
7 is just not practical.

You will need 4 Gig of RAM on windows boxes, was my conclusion.

On Tue, Dec 13, 2011 at 9:45 PM, Yang Bo yangbo@gmail.com wrote:
 I think it is normal,it start very slow in my laptop (2G cpu,3G RAM)
 either...

 在 2011-12-14 上午10:35,SL@maxis ecp_...@my-rialto.com写道:


 I am just playing with some sample applications, eg LunarLander.

 It takes about 10-15 minutes to start when run the application. Have I
 missed something ?

 My machine: XP SP2, 1GB RAM, 10GB free space.

 Thanks.

 --
 Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

-- 
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] Help: I have git on windows. I just want to a) see b) download a speciifc android repository

2011-11-23 Thread Satya Komatineni
This is really frustrating try to see/get android source code on windows.

Previously this is fine with the online browsing as the repositories
were available for online browsing.

Anyways, I have downloaded git on windows.

I dont need to compile on windows. I just want to download a
repository to see the source for clarification,

I will seriously appreciate if some can answer the following questions:

1. is there a new git URL that I can use the git clone on?
2. How can I see a list of repositories that could comprise android?
3. Can I clone one of these repositories with just git?


Thank you so very much
(Yes I did read about 50 messages on stackoverflow and here...)
(I am really not prepared to install a linux to get a repository
out..How may operating systems does it take to change a light bulb!!)
-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

-- 
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] Re: Help: I have git on windows. I just want to a) see b) download a speciifc android repository

2011-11-23 Thread Satya Komatineni
Ok, I may be getting somewhere, the following seem to work

git clone https://android.googlesource.com/platform/manifest.git

and

git clone https://android.googlesource.com/platform/frameworks/base.git

will keep you posted

On Wed, Nov 23, 2011 at 7:59 AM, Satya Komatineni
satya.komatin...@gmail.com wrote:
 This is really frustrating try to see/get android source code on windows.

 Previously this is fine with the online browsing as the repositories
 were available for online browsing.

 Anyways, I have downloaded git on windows.

 I dont need to compile on windows. I just want to download a
 repository to see the source for clarification,

 I will seriously appreciate if some can answer the following questions:

 1. is there a new git URL that I can use the git clone on?
 2. How can I see a list of repositories that could comprise android?
 3. Can I clone one of these repositories with just git?


 Thank you so very much
 (Yes I did read about 50 messages on stackoverflow and here...)
 (I am really not prepared to install a linux to get a repository
 out..How may operating systems does it take to change a light bulb!!)
 --
 Satya Komatineni
 http://www.satyakomatineni.com
 http://www.androidbook.com




-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] Help: I have git on windows. I just want to a) see b) download a speciifc android repository

2011-11-23 Thread Satya Komatineni
Mark,
thank you very much. Really appreciate your help on this forum.

The google code search doesnt seem to bring out the 4.0 code. At lease
on my initial search. For instance the contact provider implementation
doesnt seem to match what is there in the API docs.

I will check again. may be i am missing something on code search.

Also I am glad to know, if that is going to be really true, that the
online browsing may be coming back soon.

again thanks a bunch
Satya

On Wed, Nov 23, 2011 at 8:13 AM, Mark Murphy mmur...@commonsware.com wrote:
 On Wed, Nov 23, 2011 at 7:59 AM, Satya Komatineni
 satya.komatin...@gmail.com wrote:
 This is really frustrating try to see/get android source code on windows.

 Previously this is fine with the online browsing as the repositories
 were available for online browsing.

 Use Google Code Search, at least for the next five weeks.

 Anyways, I have downloaded git on windows.

 I dont need to compile on windows. I just want to download a
 repository to see the source for clarification,

 I will seriously appreciate if some can answer the following questions:

 1. is there a new git URL that I can use the git clone on?

 There never was just a single git URL, AFAIK. You use the repo command
 in Cygwin to download a whole boatload of repositories.

 Instead, clone:

 https://android.googlesource.com/platform/manifest

 Look at default.xml. It contains a bunch of elements like:

 project path=packages/apps/Email name=platform/packages/apps/Email /

 The path appears to be relative to
 https://android.googlesource.com/platform, so you can then clone:

 https://android.googlesource.com/platform/packages/apps/Email

 2. How can I see a list of repositories that could comprise android?

 I think that page was lost when the GitWeb interface was taken down.

 3. Can I clone one of these repositories with just git?

 See my answer to #1.

 --
 Mark Murphy (a Commons Guy)
 http://commonsware.com | http://github.com/commonsguy
 http://commonsware.com/blog | http://twitter.com/commonsguy

 Android App Developer Books: http://commonsware.com/books

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] Help: I have git on windows. I just want to a) see b) download a speciifc android repository

2011-11-23 Thread Satya Komatineni
Thank you very much for all the help for this question. This has been
a fruitful morning after all.

I used the following command

git clone 
https://android.googlesource.com/platform/packages/providers/ContactsProvider

to download the latest contacts provider that deals with personal profiles.

Great.

I have uploaded the manifest default.xml that Mark referenced here for
a quick view

http://www.satyakomatineni.com/item/3920

As stated by Mark, you can use this reference to locate the repository
that you want and use the git clone feature to get the latest.

Note that some repositories (such as base.git) are quite large. If you
are using a laptop, plug it in.

thanks again folks, perhaps now I will be able to see some internals
of how personal profile in ics is integrated with the rest of the
contacts

Thanks again

Happy Thanksgiving

Satya

On Wed, Nov 23, 2011 at 8:38 AM, Mark Murphy mmur...@commonsware.com wrote:
 On Wed, Nov 23, 2011 at 8:32 AM, Satya Komatineni
 satya.komatin...@gmail.com wrote:
 The google code search doesnt seem to bring out the 4.0 code. At lease
 on my initial search. For instance the contact provider implementation
 doesnt seem to match what is there in the API docs.

 It at least has Gingerbread -- I just did a search on CalendarView and
 it popped up. Looks like it might even be something we could pull into
 a separate library project...

 But, yeah, it doesn't seem to be indexing ICS, as the new Switch
 widget isn't there. Nor is GridLayout.

 Also I am glad to know, if that is going to be really true, that the
 online browsing may be coming back soon.

 Well, I hope it does, someday. However, if Google Code Search really
 does get shut down, I may cry.

 --
 Mark Murphy (a Commons Guy)
 http://commonsware.com | http://github.com/commonsguy
 http://commonsware.com/blog | http://twitter.com/commonsguy

 Android App Developer Books: http://commonsware.com/books

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

-- 
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] Re: How come there is no PROFILE specific URI for raw contact data in the contact api?

2011-11-22 Thread Satya Komatineni
The immediate problem seem to be my over caution that made me put

 cv.put(Data.IS_USER_PROFILE, 1);

My reasoning was that this will be used to distinguish whether to add
the data element to the profile raw contact or the plain raw contact.

That paranoia seem to be unfounded.

when I remove this the code worked fine even with the same
Data.CONTENT_URI with out the need for Data.PROFILE_CONTENT_URI.

The code underneath seem to know this difference by merely looking at
the raw contact id passed in. There must be some logic the code is
using to see where this raw contact id is from.

Anyways temporarily I understand a little m ore.

(Ali, thanks for the link as well)

On Mon, Nov 21, 2011 at 3:48 PM, Satya Komatineni
satya.komatin...@gmail.com wrote:
 I see that there is a URI for inserting/contributing a raw contact to
 the new (4.0) personal profile

 ContactsContract.Profile.CONTENT_RAW_CONTACTS_URI

 I am able to use this URI to insert a raw contact (with a specific
 account type and name) into the personal profile.

 However I don't see a corresponding URI for the Data contract such as

 ContactsContract.Data.PROFILE_CONTENT_URI

 How do one go about addint a data element to a raw contact that
 contributes to a profile?

 For example I ran the following code

 private void insertPhoneNumber(long rawContactId)
 {
  ContentValues cv = new ContentValues();
  cv.put(Data.RAW_CONTACT_ID, rawContactId);
  cv.put(Data.IS_USER_PROFILE, 1);
  cv.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
  cv.put(Phone.NUMBER,P123 123  + rawContactId);
  cv.put(Phone.TYPE,Phone.TYPE_HOME);
  this.mContext.getContentResolver().insert(Data.CONTENT_URI, cv);
  if (puri == null) {
      log(Not able to insert phone number);
  }
  else {
      log(Not able to insert phone number);
  }
 }

 This returns a NULL phone uri indicating that the operation failed.

 I am not able to get a clear picture from the documentation. I see
 that there are two databases: one for the regular contacts
 (contacts.db) and one for the profile contacts (profile.db). I also
 see that the raw contacts for profile and the regular contacts are
 kept separately.

 However I am not able to insert a data value for a personal profile
 raw contact.

 Appreciate if someone can clarify

 Thanks
 Satya




-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

-- 
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] How come there is no PROFILE specific URI for raw contact data in the contact api?

2011-11-21 Thread Satya Komatineni
I see that there is a URI for inserting/contributing a raw contact to
the new (4.0) personal profile

ContactsContract.Profile.CONTENT_RAW_CONTACTS_URI

I am able to use this URI to insert a raw contact (with a specific
account type and name) into the personal profile.

However I don't see a corresponding URI for the Data contract such as

ContactsContract.Data.PROFILE_CONTENT_URI

How do one go about addint a data element to a raw contact that
contributes to a profile?

For example I ran the following code

private void insertPhoneNumber(long rawContactId)
{
  ContentValues cv = new ContentValues();
  cv.put(Data.RAW_CONTACT_ID, rawContactId);
  cv.put(Data.IS_USER_PROFILE, 1);
  cv.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
  cv.put(Phone.NUMBER,P123 123  + rawContactId);
  cv.put(Phone.TYPE,Phone.TYPE_HOME);
  this.mContext.getContentResolver().insert(Data.CONTENT_URI, cv);
  if (puri == null) {
  log(Not able to insert phone number);
  }
  else {
  log(Not able to insert phone number);   
  }
}

This returns a NULL phone uri indicating that the operation failed.

I am not able to get a clear picture from the documentation. I see
that there are two databases: one for the regular contacts
(contacts.db) and one for the profile contacts (profile.db). I also
see that the raw contacts for profile and the regular contacts are
kept separately.

However I am not able to insert a data value for a personal profile
raw contact.

Appreciate if someone can clarify

Thanks
Satya

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


Re: [android-developers] Widget refresh rate

2011-10-08 Thread Satya Komatineni
A,

My understanding is that if your refresh rate is above 30 mins, then
it will impact accordingly. The recommendation is to put it no quicker
than 30 mins and I believe starting somewhere around 2.0 this was
enforced by either making it 30 mins at least.

Bottom line appears to be place this above 30mins to save power and is
enforced as such.


On Sat, Oct 8, 2011 at 9:35 AM, A. Purohit gopal.a...@gmail.com wrote:
 Hi all,
     I read that widget is refreshed after 30mins and there is almost no
 meaning of refresh rate specified in XML file.
 To overcome this, we have to use AlarmManager if we want to make refresh
 rate  30mins!

 Is this still valid or this was true till Android 1.5 only?

 Thanks,
 -A

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

-- 
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] my_activity - brower-activity (How can I go back to my activity)??

2011-09-11 Thread Satya Komatineni
My Activity A  starts BrowserActivity with a URL. (No flags)

I press BACK button while in the browser

Browser follows its own history back and not come back to my activity A.

Because I am starting the browser activity (I do realize it is a
singletask) is there any flag I can set to have the browser honor the
activity that is invoking it?

Appreciate your help

Satya

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


Re: [android-developers] Updating a database without freezing

2011-09-04 Thread Satya Komatineni
You may want to look at using an asynctask

Here are some research notes on async task (This is not a tutorial but
could point you to do some work)
http://www.satyakomatineni.com/item/3536

On Fri, Sep 2, 2011 at 5:23 PM, Jared Kass jdk...@cornell.edu wrote:
 Hi,
 I'm working on an app that records information for a study and posts
 it to a database. An alert dialog prompts the user with a question and
 the answer is recorded and sent. I'm successfully updating the
 database using httpclient and httppost, however it takes a varying
 amount of time, usually several seconds. This is unacceptable, and I
 was wondering how to go about having this run in the background. Any
 advice you could give me would be great, thanks!

 -Jared

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] XML parsing in android

2011-09-04 Thread Satya Komatineni
Krishna,
here are research notes I have on XML processing in Android

http://www.satyakomatineni.com/item/3731

You may be able to use XmlPullParser facility but you may need to work
as you process each node sequentially.

If you have the option of JSON the following research link may help

http://www.satyakomatineni.com/item/3687


On Fri, Sep 2, 2011 at 4:00 AM, Krishna Prasad
krishnaprasadrs.1...@gmail.com wrote:
 Is It possible to parse a dynamically created xml in android?

 I want  to display the xml based on fields in the xml.

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] Re: Java book (like C KR and C++ Programming Language)

2011-06-11 Thread Satya Komatineni
C++ by Stroustroup is one of the best books in languages that I have
read (especially the ARM book).

On Java I still prefer the simplicity of the first edition by the
creator of Java. to the point. brief. clear and concise.

The more recent topics you can probably learn from on line sources
such as generics, genericized lists etc..


On Sat, Jun 11, 2011 at 7:26 AM, John jmo...@softmoore.com wrote:

 I have a C and C++ background and i'm looking for THE java book, like the
 C Programming Language, best know as KR, for C and the C++ Programming
 Language by Bjarne Stroustrup for C++.

 I have always liked the Core Java books (two volumes) by Horstmann and
 Cornell. now in their eighth edition.  See 
 http://www.horstmann.com/corejava.html
 for more details.  I also support the other poster's recommendation of
 Josh Bloch's book entitled Effective Java as an excellent reference,
 but not necessarily as a first source for learning Java.

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] Re: Are dialogs supposed to be modal?

2011-06-02 Thread Satya Komatineni
Common guys. Give him a bit of credit.

Yes. I agree it is a GOOD recommendation to not use private APIs. It
is especially good recommendation to not use them for a general
purpose facility.

Other than that it is a good effort.

Someone thinks differently let him experiment.

Satya

On Thu, Jun 2, 2011 at 2:04 AM, Zsolt Vasvari zvasv...@gmail.com wrote:
 Of course, it's wise, but frankly, only an idiot would use that piece
 of code -- and you cannot really help those people.

 On Jun 2, 2:00 pm, Chris crehb...@gmail.com wrote:
 The suggestion to avoid using private APIs is wise.  I had a company once
 that built a model on WinNT 4 and when XP/5.0 came out was rendered
 obsolete.

 Just sayin' is all.

 - C

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] Trying to get a ProgressDialog to display.

2011-05-28 Thread Satya Komatineni
UI, including dialogs, is fundamentally an asynchronous process served
by the same thread.

A show() on a dialog is a delayed instruction to tell the main
thread to show the dialog when it comes back around the loop to
process that message.  However if you follow the show with a
dismiss in the same thread then you cancel each other out (may be
with a bit of delay).

If you inject some processing between show and dismiss, as long as you
are on the same main thread of execution it is ineffective.

You should try to use an AsyncTask along with a progress dialog to
accomplish what you are looking for.

Or if you insist not to use the asynctask then you need to post
yourself a message (through a handler) after showing the dialog so
that you can pick up the processing and at the end ofthe processing
you can dismiss the dialog.

There are quite a few articles on the web on asynctask.

I have link below that is a bit more detailed and if you have patience
to read through that it could be helpful

http://www.satyakomatineni.com/item/3536


On Sat, May 28, 2011 at 10:00 AM, B Lyon bradfl...@gmail.com wrote:
 I've never used that one, but I'm wondering if the second .show() is
 necessary, and/or if it is somehow causing weirdness?  This person
 (http://www.helloandroid.com/tutorials/using-threads-and-progressdialog)
 didn't do that.

 On Sat, May 28, 2011 at 9:43 AM, EmilDiego emildi...@gmail.com wrote:
 I have a function inside one of my activities that calculates some
 statistics and takes a little time to generate a report.  I want to
 display a progressDialog while this is going on to give the user some
 feedback that something is happening while he is waiting.  The problem
 I am having is that I can't get my progressDialog to display no matter
 what I do.  Is there some obscure factoid that I am missing out on
 here that is preventing this to work.  This problem is particularly
 perplexing because I am using similar code elsewhere in the Activity
 and that works ok.  Any ideas


 Here is my code:

 //* ADD THE CODE FOR THE PROGRS DIALOG
                //* Start the progress dialog
                xReportProgress = ProgressDialog.show(this, , Preparing
 Report.);
                xReportProgress.show();

                switch(iReportFormat)
                {
                        case callLog.REPORT_FORMAT_CSV:
                                sReportOutput = this.createCSVReport();
                                break;

                        case callLog.REPORT_FORMAT_XML:
                                sReportOutput = this.createXMLReport();
                                break;

                        default:
                                
 ed.app.commTracker.main.systemLog.logError(Invalid report
 format.);
                                return;

                }

                //* Close the dialog so we can display the intent chooser
                xReportProgress.dismiss();

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] Re: Career as an Andoid developer. Is there any point?

2011-05-23 Thread Satya Komatineni
This is certainly nice.

I have had a chance to play around with Scratch and lego like
programming interface to teach programming concepts to teens and
gaming concepts to programmers.

It is wonderfully intriguing to tie the idea to productivity applications.

I don't believe it will replace the programming need.

But who knows once you go in a new direction it may open doors that no
one new that existed. Creativity is the goal of programming. Less
programming the better as long it ensures freedom and creativity

May be this year for the 1 week camp I will try this instead of Scratch

Thanks for bringing to attention here



On Mon, May 23, 2011 at 8:23 PM, B Lyon bradfl...@gmail.com wrote:
 I think some folks will probably do some cool things with it.

 On Mon, May 23, 2011 at 8:20 PM, Miguel Morales therevolti...@gmail.com 
 wrote:
 Sorry, that was a bit too brief and actually not completely related.
 But, what I meant was that because of the layers of non-complexity the
 browsers and app makers provide there are limits to their use.
 Even though a browser implements javascript and you can do many things with
 it, it's non complexity adds layers/paths of cpu instructions.
 So, to clarify my statement, being good at programming is ultimately the
 most desired skill.  These technologies, no matter how good and easy they
 get, have their limitations.

 On Mon, May 23, 2011 at 5:14 PM, Doug beafd...@gmail.com wrote:

 On May 23, 3:43 pm, Miguel Morales therevolti...@gmail.com wrote:
  This is because those interfaces are not turing complete.  They're
  useless
  once you reach a certain level of complexity.
  This is why browser apps are only for the most basic of apps.

 Care to elaborate on that last statement?

 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


 --
 ~ Jeremiah:9:23-24
 Android 2D MMORPG:
 http://solrpg.com/, http://www.youtube.com/user/revoltingx

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] Access instance variables from an activity inside a AsyncTask

2011-05-16 Thread Satya Komatineni
In addition to what Mark has pointed out keep in mind that when the
device is rotated the activity is restarted but not the asynctask. So
you will end up with a null activity variable. It is fairly well
documented on the android developer site how to deal with device
rotation or configuration changes.

On Mon, May 16, 2011 at 7:39 PM, Mark Murphy mmur...@commonsware.com wrote:
 On Mon, May 16, 2011 at 7:37 PM, elioncho elion...@gmail.com wrote:
 I have an AsyncTask (in a separate file) which is invoked on an
 activity. When I instantiate the AsyncTask, I send the activity as a
 param. How can I access the acitivity's instance variables from the
 onPostExecute method of the AsyncTask?

 Make the instance variables package-protected, and put both classes in
 the same package.

 Or, more cleanly, implement getter/setter methods on the activity that
 the AsyncTask can use.

 --
 Mark Murphy (a Commons Guy)
 http://commonsware.com | http://github.com/commonsguy
 http://commonsware.com/blog | http://twitter.com/commonsguy

 Android Training in London: http://bit.ly/smand1, http://bit.ly/smand2

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] Recommendations for 'specialization'.

2011-05-14 Thread Satya Komatineni
Perhaps there are diffrent type of jobs requiring different skills/depth.

if you are looking for an IT job writing business applications for the
mobile, perhaps I could say a few words.

Good hiring managers know that a good programmer is a good java
programmer. And a good java programmer is a good android programmer.

However some managers prefer that you have a explicit Android
programming experience. The way some of these managers are workign
this out is to see if you have any published apps on the android
market. Don't have to be an extensive app. If you were to follow this
logic it may better to write a few simple apps and publish them on the
market.

If your goals is to write a killer personal app that you can make
money out off, that is a serious task, only toil and frustration can
accrue.


2011/5/14 Harri Smått har...@gmail.com:
 Hi All,

 First of all, I'm very new to Android, installed my first SDK just 3 months 
 ago. But given the nature of Java programming in general, it provides one 
 with very flexible environment for familiarizing yourself with with it 
 relatively quickly. And this holds for Android too (thanks guys, Dianne etc, 
 you've done a great job).

 But since I have somewhat limited time for doing this, I'm learning Android 
 on my spare time while someone else pays my bills, it soonish became quite 
 obvious for me Android is huge. And I can't get into level on every area of 
 Android programming I wanted to very easily.

 Now this leaves me with two options;

 1. Start programming an application and force myself to go through services  
 and what ever comes on the way.
 - This is what I started with at first. Went on with a Facebook Client, which 
 I thought would provide me good overall experience on Android development (UI 
 basics, network usage/optimization etc etc). But once I found myself reading 
 XMPP documentation and writing my own Facebook chat client (I just didn't 
 feel comfortable with adding a 500kB readymade jar to my smallish project), I 
 had to start thinking is this a good way after all.

 2. Find a 'special' domain to concentrate on and do it REALLY WELL.
 - This would provide smaller applications, maybe libraries, but gave me good 
 insight on how to do certain things and I could concentrate on making them 
 flexible/usable for other developers too. Meaning interfaces they can use to 
 access my code. Or code itself should be flexible at least.

 Problem is, if I'm about to try finding an Android related job one day, 
 should I go with the application approach instead? Or could you provide me 
 with some examples of general interests, hot topics, I could spend my time on?

 --
 H

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] Does android supports modal dialog box ?

2011-05-10 Thread Satya Komatineni
Although the dialogs are *almost* modal in Android, they are
fundamentally (or practically) asynchronous.

Search for modal dialogs and android in google and you will see a lot
of write up from this news group.

So you have to reorient your programming where you can alert and wait
the main thread. This is just not possible (as far as I know).

If you are using alerts for debugging you may want to use toast or Log.d.

Bottom line you cannot stop the main thread while a dialog is being
acted upon and finished.


On Tue, May 10, 2011 at 7:38 AM, ABS ravi.chavan...@gmail.com wrote:
 Hi Everybody,

              I am new to android, working on one application in which
 i am using series of dialog boxes to show alert to user , I have to
 show dialogs one after another i.e simultaneously but when first
 dialog comes out the code running behind dialog haven't stop still end
 of method. hence it does not shows remaining dialogs simply it ignores
 remaining dialogs.
             I have to stop control of program at the first dialog,
 if  anybody has solution on this reply me


 Thanks in advance

 Regards

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] Re: Async Task or Spawn a Thread?

2011-05-10 Thread Satya Komatineni
I would say

1. Understand first how handler/looper/threrading works in android
2. Then you will realize that AsyncTask is just one pattern on top of
the above basics
3. Try to use AsyncTask if it can work for your problem as it
simplifies the mechanics of threading/handlers. if not then go for the
guts using handlers/threads

Coming to thread pools the latest documentation seem to suggest that
after honeycomb the AsyncTask may roll back to a single thread
implementation and have the programmer deal with multiple threads
explicitly.


On Mon, May 9, 2011 at 6:34 AM, Bob Kerns r...@acm.org wrote:
 I'm OK with having people who aren't very experienced with threads create a
 new AsynchTask for each recurrence. Better than debugging a synchronization
 problem -- or worse, living with it. And it's not really that high an
 overhead, either in code complexity or time and memory. It's not like it's
 creating a new thread each time.
 Just to be clear: Handler/Looper doesn't give you threads. I've seen people
 get very confused on this point! It does make using threads, well, not
 simpler, but safer. If you're interested in passing off work to another
 thread, then it's better to use Handler/Looper than to try to handle the
 synchronization of passing off the work item yourself.
 Still, since you have to create that work item to pass it off, generally
 speaking, you might as well make it an AsynchTask, and get thread pooling,
 clean interface to the UI thread, and convenient progress bar handling for
 free. The only time I can think of to prefer Handler/Looper is when the
 thread pooling behind AsynchTask doesn't fit your needs -- and if it
 doesn't, you may want to consider your needs, as having lots of threads
 takes lots of memory (for the stacks).

 On Sunday, May 8, 2011 4:33:44 PM UTC-7, Indicator Veritatis wrote:

 All the answers I have seen so far are true, but yours is the most
 informative. I would be a little careful about the generalization
 though, that if he has to ask, then AsyncTask is the answer. AsyncTask
 is not so convenient for recurring tasks, unless you are OK with
 having to start it up all over again each time the trigger occurs.

 And there is one other tool in Android that is still useful for
 Threads, when barebones Java Threads are too much of a bother to
 manage: Looper/Handler. This was the standard Android threading
 'workhorse' before AsyncTask (or its unoficcial predecessor UserTask)
 became so popular.

 On May 7, 11:31 am, Bob Kerns r@acm.org wrote:
  Use an AsyncTask -- unless both of the following are true:
 
     - AsyncTask doesn't meet your needs somehow
     - You know very clearly and well how to properly synchronize between
     threads, and how to transfer work to the UI thread where needed, etc.
 
  If AsyncTask doesn't meet your needs, and you don't have the second
  requirement -- you have a very steep (and error-prone) learning curve
  ahead
  of you. The whole idea of AsyncTask is to make it easier to write
  reliable
  asynchronous code.
 
  Generally speaking -- if you have to ask, AsyncTask is probably the
  answer.
 
  On Saturday, May 7, 2011 8:53:29 AM UTC-7, Droid wrote:
 
   Seems I can use an async task OR roll my own thread to do a background
   task.
 
   Is one better than the other?

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] Re: Long process before a dialog is opened

2011-05-10 Thread Satya Komatineni
I have thought about this a bit further.

You should be able to do this with some work.

If I am not mistaken what you are wanting to do is a special case of
something like a Progress Dialog except it is custom and the user
wants to dismiss it explicitly. Also you must not wait for the
onPostExecute.

My high level thougths are:

1. Create a dialog as you normally do in onCreateDialog() and return that dialog
2. Keep a pointer to the dialog so that you can alter the view in that
dialog some manner
3. Kick off your asynctask
4. Update progress on your dialog with a visual cue
5. OnPostExecute enable a button on the dialog to do the desired
action by the user

I think this will work...(if it suits your intent)

On Fri, May 6, 2011 at 5:14 PM, venkata raidu venkata.ra...@gmail.com wrote:
 Thank you Satya. Using Activity would solve the problem. But, I
 thought, by using a dialog, the user don't have to leave the current
 screen and also, since the dialog is transparent,  the user can see
 the background always. By the way, I own your book. It is a very good
 comprehensive book for Android.

 Venkata

 On May 6, 1:57 pm, Satya Komatineni satya.komatin...@gmail.com
 wrote:
 Venkata,
 All you probably need is an activity. May be just the activity that
 you are on when the menu is clicked.

 Eitherway on the menu click start an asynctask and you can show the
 progress bar while the asynctask is in progress.

 At the end of that asynctask you can update the view in your activity
 with the data. Or you can start a new actvity first and have that new
 activity start an async task.









 On Fri, May 6, 2011 at 2:44 PM, venkata raidu venkata.ra...@gmail.com 
 wrote:
  Problem:
  I need to display a dialog upon the click of a menu item. The
  information to be displayed on the dialog will be downloaded each time
  and is a lengthy process. How do you solve this problem, so that a
  progress bar is displayed during this process.

  Solution I tried:
   I used onCreateDialog() of the Activity and wrote a class which
  extends AsyncTask to create a dialog with new data. But in the method
  onCreateDialog(), it waits for a dialog to be returned, and I was not
  able to send using my class because onPostExecute() method's return
  type is void.

  Please suggest a solution. Thanks.

  -Venkata

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

 --
 Satya Komatinenihttp://www.satyakomatineni.comhttp://www.androidbook.com

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] Re: Long process before a dialog is opened

2011-05-10 Thread Satya Komatineni
 Or (if I understand your context right) better yet, show a progress
dialog when the menu is clicked and when the progress dialog finishes
show your special dialog thereby fulfilling both requirements of
visibility and long running process.



On Tue, May 10, 2011 at 10:41 AM, Satya Komatineni
satya.komatin...@gmail.com wrote:
 I have thought about this a bit further.

 You should be able to do this with some work.

 If I am not mistaken what you are wanting to do is a special case of
 something like a Progress Dialog except it is custom and the user
 wants to dismiss it explicitly. Also you must not wait for the
 onPostExecute.

 My high level thougths are:

 1. Create a dialog as you normally do in onCreateDialog() and return that 
 dialog
 2. Keep a pointer to the dialog so that you can alter the view in that
 dialog some manner
 3. Kick off your asynctask
 4. Update progress on your dialog with a visual cue
 5. OnPostExecute enable a button on the dialog to do the desired
 action by the user

 I think this will work...(if it suits your intent)

 On Fri, May 6, 2011 at 5:14 PM, venkata raidu venkata.ra...@gmail.com wrote:
 Thank you Satya. Using Activity would solve the problem. But, I
 thought, by using a dialog, the user don't have to leave the current
 screen and also, since the dialog is transparent,  the user can see
 the background always. By the way, I own your book. It is a very good
 comprehensive book for Android.

 Venkata

 On May 6, 1:57 pm, Satya Komatineni satya.komatin...@gmail.com
 wrote:
 Venkata,
 All you probably need is an activity. May be just the activity that
 you are on when the menu is clicked.

 Eitherway on the menu click start an asynctask and you can show the
 progress bar while the asynctask is in progress.

 At the end of that asynctask you can update the view in your activity
 with the data. Or you can start a new actvity first and have that new
 activity start an async task.









 On Fri, May 6, 2011 at 2:44 PM, venkata raidu venkata.ra...@gmail.com 
 wrote:
  Problem:
  I need to display a dialog upon the click of a menu item. The
  information to be displayed on the dialog will be downloaded each time
  and is a lengthy process. How do you solve this problem, so that a
  progress bar is displayed during this process.

  Solution I tried:
   I used onCreateDialog() of the Activity and wrote a class which
  extends AsyncTask to create a dialog with new data. But in the method
  onCreateDialog(), it waits for a dialog to be returned, and I was not
  able to send using my class because onPostExecute() method's return
  type is void.

  Please suggest a solution. Thanks.

  -Venkata

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

 --
 Satya Komatinenihttp://www.satyakomatineni.comhttp://www.androidbook.com

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



 --
 Satya Komatineni
 http://www.satyakomatineni.com
 http://www.androidbook.com




-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] putExtra not working for a pending intent

2011-05-10 Thread Satya Komatineni
There is enough material on this forum if you search with 'pending
intent' especially around its uniqueness criteria.

At a high level, pending intents are references to already stored
intents. A pending intent uses the input intent as a key to locate
previously established pending intent for this intent. The key to
locate this does not include the extras. All other parts of an
intent participate in this uniqueness.

So even if you set extras different on 10 different intents
(everyother part of an intent being same) will result in a single
pendingintent.

The flag that was suggested will retreive that previous intent and
replaces the new extras on the old one.

You can also use something called a requestid to make the intents
unique. But it is suggested in the docs that you don't want to create
a lot of pendign intents if you have other ways of solving it.

Hope this brings a bit more background to pending intent


On Tue, May 10, 2011 at 12:58 PM, TreKing treking...@gmail.com wrote:
 On Tue, May 10, 2011 at 11:40 AM, Boozel boozelcl...@gmail.com wrote:

 however in the service intent.hasExtra(a) is always false. why? does
 this not work for pending intents? How can I pass a a value between the two?

 Try
 this: http://developer.android.com/reference/android/app/PendingIntent.html#FLAG_UPDATE_CURRENT

 -
 TreKing - Chicago transit tracking app for Android-powered devices

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] putExtra not working for a pending intent

2011-05-10 Thread Satya Komatineni
Also here are some previous notes I have collected on pending intents

Quick intro to pending intents:
http://www.satyakomatineni.com/item/3301

How alarmmanager and pending intents interact
http://www.satyakomatineni.com/item/3503

At this later link there is a lot of discussion on how pending intents
are unique and what happens extras etc. You will also see links to a
number of useful posts on pending intents.


On Tue, May 10, 2011 at 1:36 PM, Satya Komatineni
satya.komatin...@gmail.com wrote:
 There is enough material on this forum if you search with 'pending
 intent' especially around its uniqueness criteria.

 At a high level, pending intents are references to already stored
 intents. A pending intent uses the input intent as a key to locate
 previously established pending intent for this intent. The key to
 locate this does not include the extras. All other parts of an
 intent participate in this uniqueness.

 So even if you set extras different on 10 different intents
 (everyother part of an intent being same) will result in a single
 pendingintent.

 The flag that was suggested will retreive that previous intent and
 replaces the new extras on the old one.

 You can also use something called a requestid to make the intents
 unique. But it is suggested in the docs that you don't want to create
 a lot of pendign intents if you have other ways of solving it.

 Hope this brings a bit more background to pending intent


 On Tue, May 10, 2011 at 12:58 PM, TreKing treking...@gmail.com wrote:
 On Tue, May 10, 2011 at 11:40 AM, Boozel boozelcl...@gmail.com wrote:

 however in the service intent.hasExtra(a) is always false. why? does
 this not work for pending intents? How can I pass a a value between the two?

 Try
 this: http://developer.android.com/reference/android/app/PendingIntent.html#FLAG_UPDATE_CURRENT

 -
 TreKing - Chicago transit tracking app for Android-powered devices

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



 --
 Satya Komatineni
 http://www.satyakomatineni.com
 http://www.androidbook.com




-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] Long process before a dialog is opened

2011-05-06 Thread Satya Komatineni
Venkata,
All you probably need is an activity. May be just the activity that
you are on when the menu is clicked.

Eitherway on the menu click start an asynctask and you can show the
progress bar while the asynctask is in progress.

At the end of that asynctask you can update the view in your activity
with the data. Or you can start a new actvity first and have that new
activity start an async task.


On Fri, May 6, 2011 at 2:44 PM, venkata raidu venkata.ra...@gmail.com wrote:
 Problem:
 I need to display a dialog upon the click of a menu item. The
 information to be displayed on the dialog will be downloaded each time
 and is a lengthy process. How do you solve this problem, so that a
 progress bar is displayed during this process.

 Solution I tried:
  I used onCreateDialog() of the Activity and wrote a class which
 extends AsyncTask to create a dialog with new data. But in the method
 onCreateDialog(), it waits for a dialog to be returned, and I was not
 able to send using my class because onPostExecute() method's return
 type is void.

 Please suggest a solution. Thanks.

 -Venkata

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] Multiple Threads

2011-05-04 Thread Satya Komatineni
An AsyncTask may be doing its work with a single worker thread. You
may want to download the sourcecode of AsyncTask and  alter it so that
a pool of threads can do the work to speed up.

This is just thinking aloud.

Or write your own handler that spawns multple threads and have the
handler report back to the main thread much like the async task.

Satya

On Wed, May 4, 2011 at 10:03 AM, Stefan stefankru...@hotmail.com wrote:
 I'm making a app which got it's data from parsing a website, and I
 have to download around 100 webpages.
 This is a time consuming task, so I created a AsyncTask for
 downloading the data, so I can show a Loading message on the UI
 Thread.

 Only problem is, that the 100 webpages are now downloaded after each
 other. Is there a way to download the webpages at the same time? I
 tried to make a new thread in the asynctask, but I only got a Can't
 create handler inside thread that has not called Looper.prepare()
 eror...

 What's the best way to do this usually?

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] help for oops concept in android?

2011-05-04 Thread Satya Komatineni
A lot may depend on the detail that you are working with.

From what you wrote it appears to me that your data/object/xml model
may be (I am guessing your intentions)

audio track=  album= artist= /
audio track=  album= artist= /
video track=  album= artist= /
video track=  album= artist= /

In this type of representation the children become really the
attributes of the parent. So when one clicks on a track you may ask
who am I? The answer may come as audio or video.

Or if you look the other way around and make your track an independent
object then the category becomes the attribute of the track.

From what you are describing it appears to me the earlier model may be
better. In that earlier model you may even consider the attributes as
tags like in social networking as optional attributes on the nature
of  a base audio entity.

Hope this helps

On Wed, May 4, 2011 at 9:27 AM, Hitendrasinh Gohil
hitendra.virtuei...@gmail.com wrote:
 hi,

 i am having two categories

 within these 2 categories there are three subcategories.
 like__
 1.audio
   1a. track
   1b  album
   1c artist
 2.video
   2a. track
   3b  album
   2c  artist

 I have made one class that handles the click event for track,album and
 artist.but how can i know the category whether track is clicked from
 audio or video category.because i am using same xml for subcategory.
 currently i am managing it through flags.but is there any better way
 to do it?

 regards,
 hitendrasinh gohil

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] Keytool and Jarsigner - where are they?

2011-04-27 Thread Satya Komatineni
They are in

your-jdk-directory\bin



On Wed, Apr 27, 2011 at 11:02 PM, Paul Spradley pwsprad...@gmail.com wrote:
 I am using eclipse and cannot find Keytool or Jarsigner . Where are they
 accessed from?

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] Android Widget Design.

2011-04-26 Thread Satya Komatineni
Chris,

I don't have an online tutorial but we have covered this topic in a
fair amount of detail in our 2nd edition of ProAndroid 2
(http://www.androidbook.com) from Apress. The coverage includes state
management through preferences.

The third edition that should be available any time soon have extended
the material to also cover list based widgets in honeycomb.

Here is my journal as I have developed material for those chapters.

http://www.satyakomatineni.com/item/3299

Hope this will be of some help. the journal is useful if you are
looking for answers to specific questions but if you are looking for a
tutorial the book is much more helpful

Thanks
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

On Mon, Apr 25, 2011 at 3:49 PM, Chris Ruskai cruskai...@gmail.com wrote:
 Hi, I've been programming apps for a while now and want to branch out
 into the realm of widgets. Does anyone have any suggestions on where
 to find good tutorials? I've googled the subject and my results are
 limited to maybe one or two specific widgets. What I'm looking for is
 more of a general tutorial.

 Thank you,
 Chris Ruskai

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


Re: [android-developers] Are dialogs supposed to be modal?

2011-04-14 Thread Satya Komatineni
For what it is worth dialogs in the Android SDK run in the main thread
through a post back to the main thread.

This means the main thread will follow the thread of logic after
show() and gets back to the main queue and then will paint the dialog
subsequently.

However the modality prevetns other UI from receivign UI input except
for the modal dialog.

You have to accordingly code your logic to take this into account.

-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

On Thu, Apr 14, 2011 at 3:58 PM, Markus Junginger mar...@greenrobot.de wrote:
 After years of using dialogs, today I got doubts that they are
 strictly modal after all. There seems to be a short time span in which
 it is possible to hit other Views AFTER show() of the dialog is
 called.

 Does this work as intended?

 Any ideas how to make a dialog really modal?

 Have a look here for some details:
 http://stackoverflow.com/questions/5666707/bypass-modal-android-dialogs-by-clicking-buttons-twice-fast-enough

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


Re: [android-developers] Are dialogs supposed to be modal?

2011-04-14 Thread Satya Komatineni
Markus,
I have reread the post on stack overflow, the prevention of the UI
seem to work once the show() of the dialog takes effect from the
main thread. But by that time (due to a post of the message) another
message may be queueed (from the second button).

This leaves two messages on the queue to be served by the main thread.

msg1: show
msg2: button2

I guess it is possible to quick fast enough to beat the system. May be
you need to set a variable to detect this.

Just thinking aloud...

Satya

On Thu, Apr 14, 2011 at 4:13 PM, Satya Komatineni
satya.komatin...@gmail.com wrote:
 For what it is worth dialogs in the Android SDK run in the main thread
 through a post back to the main thread.

 This means the main thread will follow the thread of logic after
 show() and gets back to the main queue and then will paint the dialog
 subsequently.

 However the modality prevetns other UI from receivign UI input except
 for the modal dialog.

 You have to accordingly code your logic to take this into account.

 --
 Satya Komatineni
 http://www.satyakomatineni.com
 http://www.androidbook.com

 On Thu, Apr 14, 2011 at 3:58 PM, Markus Junginger mar...@greenrobot.de 
 wrote:
 After years of using dialogs, today I got doubts that they are
 strictly modal after all. There seems to be a short time span in which
 it is possible to hit other Views AFTER show() of the dialog is
 called.

 Does this work as intended?

 Any ideas how to make a dialog really modal?

 Have a look here for some details:
 http://stackoverflow.com/questions/5666707/bypass-modal-android-dialogs-by-clicking-buttons-twice-fast-enough

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




-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

-- 
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] when will the source code for Android 3.0 released?

2011-03-07 Thread Satya Komatineni
I am trying to find out nuances with the new features of home screen widgets.

I am wondering when will the source code for Android 3.0 be availabe
in git repositories.

Thanks
Satya

-- 
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] Help: RemoteViewsFactory: what is the difference between its constructor and its onCreate() callback?

2011-03-02 Thread Satya Komatineni
As part of figuring out the new widget support in honeycomb, I am at a
loss to understand the difference between

the constructor of a RemoteViewsFactory and its callback method onCreate().

won't they always be called one after the other?

The fact that oncreate() exists, suggests that it is possible to
have onCreate() called multiple times for the same
RemoteViewsFactory.

why can't I do what I need to do in oncreate() in the constructor itself?

I am missing something.

Any help is much appreciated.

I looked at the stack widget example and also teh weather widget
example. this aspect is not clear.

Thanks
Satya

-- 
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] Re: what does this code segment do in weatherwidgetprovider: intent.setData(Uri.parse(sameintent.toUri()))

2011-02-26 Thread Satya Komatineni
Ok I get it

this is to do with (I think) how two *innocent* intents could be
deemed the same even if they are different owing to their *extras.

The uniqueness of intents when dealing with pending intents does not
take into account the EXTRAS but it does take into account the
data portion.

And hence the following code simulating this uniqueness by converting
an intent with extras first to a string (which will include the extras
as appended string) and then set that unique string as data URI. :) I
get it.

Hope this helps another **easily baffled**.

Satya

On Fri, Feb 25, 2011 at 2:35 PM, Satya Komatineni
satya.komatin...@gmail.com wrote:
 If you could take a look at this segment of code


 final Intent intent = new Intent(context, WeatherWidgetService.class);
 intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);

 //
 //what is done here???
 //
 intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));

 final RemoteViews rv = new RemoteViews(context.getPackageName(),
 R.layout.widget_layout);
 rv.setRemoteAdapter(appWidgetIds[i], R.id.weather_list, intent);


 This code is taken from:

 http://developer.android.com/resources/samples/WeatherListWidget/src/com/example/android/weatherlistwidget/WeatherWidgetProvider.html


 I understand what toUri does for an intent. However in this case

 1. the intent is explicitly invoking a service component
 2. The service component is free to choose the extra parameters from the 
 intent
 3. If so why set the data to itself???

 Appeciate if you can throw some light on this

 Thanks
 Satya




-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

-- 
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] what does this code segment do in weatherwidgetprovider: intent.setData(Uri.parse(sameintent.toUri()))

2011-02-25 Thread Satya Komatineni
If you could take a look at this segment of code


final Intent intent = new Intent(context, WeatherWidgetService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);

//
//what is done here???
//
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));

final RemoteViews rv = new RemoteViews(context.getPackageName(),
R.layout.widget_layout);
rv.setRemoteAdapter(appWidgetIds[i], R.id.weather_list, intent);


This code is taken from:

http://developer.android.com/resources/samples/WeatherListWidget/src/com/example/android/weatherlistwidget/WeatherWidgetProvider.html


I understand what toUri does for an intent. However in this case

1. the intent is explicitly invoking a service component
2. The service component is free to choose the extra parameters from the intent
3. If so why set the data to itself???

Appeciate if you can throw some light on this

Thanks
Satya

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


Re: [android-developers]

2011-02-23 Thread Satya Komatineni
Saurabh,
I am curious to here what your difficulties are with Android and what
aspects of J2ME that you come to like

Satya

On Wed, Feb 23, 2011 at 8:12 AM, saurabh sinha saurs...@gmail.com wrote:
 I am fed up with android application I prefer j2me is much better than android

 somoebody tell me how to unsubscibe android group

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

-- 
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] Is it possible to hold onto a DialogFragment pointer in its parent activity?

2011-02-21 Thread Satya Komatineni
The reason I am not able to do this is because

1. To hold on to this fragment pointer I need to save/restore the
pointer through the save bundle
2. I am using putFragment() method to do this (via the activity
onsaveinstancestate)
3. putFragment() seem to require that the fragment is added to the
fragment manager
4. however when a fragment dialog is dismissed it is removed from
the fragment manager. So I cannot do a put fragment. Not only that the
fragment manager will not even recreate the fragment because it is
removed by dismiss. I want to keep it there even if it is dismissed
so that the fragment manager can keep its state.

I suppose I can always maintain the state of the dialog outside of it,
but I am trying to see if there is a way to do this without resoring
to separatng the state data.


In more detail
*
If the above post is a bit dense here is psuedo code I am trying to do


MyActivity
{
private MyDialogSegment   ds = null;

private void initMyDialogSegment(Bundle savebundle)
{
 if  (fragmentmanager.getfragment(mytag)) has it
  ds = restoredfragment;
 else
   ds = MyDialogSegment.newInstance();
   fragmentmanager.add(null, ds, mytag);
}

   public showDiloag()
   {
 .
 ds.show(ft, mytag);
   }
   public onDismissCallback()
   {
ds.getSomeState();
   }

   onSaveInstanceState(bundle b)
   {
   fragmentmanager.putfragment(ds,mytag);
   }

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


Re: [android-developers] Is it possible to hold onto a DialogFragment pointer in its parent activity?

2011-02-21 Thread Satya Komatineni
Dianne,
Thanks.

I do wonder though, would it have been possible, architecturally, to
separate showing a fragment from adding a fragment to the fragment
manager.

For example when I show a dialog fragment it does both adding and
showing of that fragment. Sameway when I dismiss a dialog, it stops
showing the fragment and also removes it. So I have no mechanism
to retain that fragment once it is dismissed.

So state is intimately tied to visibility.

But again I am just getting to know them and probably there are
stronger reasons to tie them strongly to the UI

Thanks again for your tireless support on this forum and elsewhere.

Satya

On Mon, Feb 21, 2011 at 2:30 PM, Dianne Hackborn hack...@android.com wrote:
 You can only maintain a fragment pointer if it is actually added to the
 fragment manager.

 On Mon, Feb 21, 2011 at 7:24 AM, Satya Komatineni
 satya.komatin...@gmail.com wrote:

 The reason I am not able to do this is because

 1. To hold on to this fragment pointer I need to save/restore the
 pointer through the save bundle
 2. I am using putFragment() method to do this (via the activity
 onsaveinstancestate)
 3. putFragment() seem to require that the fragment is added to the
 fragment manager
 4. however when a fragment dialog is dismissed it is removed from
 the fragment manager. So I cannot do a put fragment. Not only that the
 fragment manager will not even recreate the fragment because it is
 removed by dismiss. I want to keep it there even if it is dismissed
 so that the fragment manager can keep its state.

 I suppose I can always maintain the state of the dialog outside of it,
 but I am trying to see if there is a way to do this without resoring
 to separatng the state data.


 In more detail
 *
 If the above post is a bit dense here is psuedo code I am trying to do


 MyActivity
 {
    private MyDialogSegment   ds = null;

    private void initMyDialogSegment(Bundle savebundle)
    {
         if  (fragmentmanager.getfragment(mytag)) has it
              ds = restoredfragment;
         else
               ds = MyDialogSegment.newInstance();
               fragmentmanager.add(null, ds, mytag);
    }

   public showDiloag()
   {
         .
         ds.show(ft, mytag);
   }
   public onDismissCallback()
   {
        ds.getSomeState();
   }

   onSaveInstanceState(bundle b)
   {
       fragmentmanager.putfragment(ds,mytag);
   }

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



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

 Note: please don't send private questions to me, as I don't have time to
 provide private support, and so won't reply to such e-mails.  All such
 questions should be posted on public forums, where I and others can see and
 answer them.

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

-- 
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] Direct pointers to fragments

2011-02-18 Thread Satya Komatineni
You say one can hold direct pointers (not just their references such
as id and tag) to fragments of an activity.

won't these pointers go stale across save/restore of either an
activity or fragment?

May be a targetfragment pointer may be retrofitted by the fragment
manager (perhaps!!). How is this maintained across save/restore?

how about the holding activity having an explicit pointer as a local
variable of one of its child fragments? what about this pointer? as
fragments go popping out of stack it is possible that the activity may
hold on to each of these stacked fragments. (Ofcourse there is the
find by tag or id of those in the current stack)

I suspect these local pointers to other fragments may need to be
explicitly managed through save/restore states??

Thanks for helping us demystify a few things...

Satya

On Fri, Feb 18, 2011 at 1:13 AM, Dianne Hackborn hack...@android.com wrote:
 No, actually, one of the big benefits of fragments is that they are *not*
 sub-activities, they don't try to have a pretense of being isolated from
 each other, and are designed to allow you to easily use direct pointers to
 them.

 Don't try to impose object oriented because you feel like this somehow
 magically makes things better.  Unless it serves a purpose, it doesn't.
 Anyway there is a perfectly fine way to do these interactions that most
 people will agree is object oriented and makes the code much simpler and
 lighter weight: define a callback interface that one fragment (or activity)
 implements and another can then call.
 See for example the built-in facility for a fragment to have a pointer to a
 target fragment.  This is the fragment version of activity's
 onActivityResult().  However because fragments don't have a goal of imposing
 a strict (remote-able) high-level interface to itself, sending results
 between fragments is a lot easier: just define an interface of whatever
 functionality you want, which the target fragment can implement, and the
 sending can cast and call on.
 You can also take advantage of the FragmentManager APIs to save a fragment
 pointer in a bundle and later retrieve it, to allow you to maintain direct
 pointers across state save/restore.
 Basically, with fragments you'll want to unlearn a lot of the painful things
 you got used to dealing with in embedded activities. :)
 On Thu, Feb 17, 2011 at 8:10 PM, davemac davemac...@gmail.com wrote:

 I'd love to hear opinions on the best way to communicate between
 fragments.

 If we consider that fragments are like sub-activities (a common
 metaphor), then we might think to use broadcast messages to tell one
 fragment about something that happened in another fragment. That seems
 a bit difficult though not impossible.

 The samples simply lookup one fragment from another then access views
 directly. This forces that fragment to understand what's going on
 around it, which doesn't feel as object-oriented as I'd like. I'd feel
 better if maybe the activity was doing that sort of coordination, so
 the fragment tells the activity, and the activity figures out which
 other fragment, if any, needs to get a message, then invokes a method
 on the fragment so it can perform any updates. Or the activity could
 decide we're in a situation where we need to fire up a separate
 activity. Or maybe move things around on the screen.

 Am I over-complicating things here? I realize that a mobile app should
 be as compact as possible, and if that means just do it and access
 views in other fragments directly, then I could go along with that.
 But I thought I'd ask the group to get some other opinions.

 - dave

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



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

 Note: please don't send private questions to me, as I don't have time to
 provide private support, and so won't reply to such e-mails.  All such
 questions should be posted on public forums, where I and others can see and
 answer them.

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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

Re: [android-developers] Direct pointers to fragments

2011-02-18 Thread Satya Komatineni
Ok. got it.
thanks

On Fri, Feb 18, 2011 at 12:45 PM, Dianne Hackborn hack...@android.com wrote:
 Like I said, there are APIs on FragmentManager to put a Fragment pointer in
 a Bundle and pull it out again, which work across state save/restore.
 Though probably just as often, you can just use a tag name (or view ID) for
 the fragment and later re-retrieve it when being created though
 findFragmentByTag() and findFragmentById().

 On Fri, Feb 18, 2011 at 9:22 AM, Satya Komatineni
 satya.komatin...@gmail.com wrote:

 You say one can hold direct pointers (not just their references such
 as id and tag) to fragments of an activity.

 won't these pointers go stale across save/restore of either an
 activity or fragment?

 May be a targetfragment pointer may be retrofitted by the fragment
 manager (perhaps!!). How is this maintained across save/restore?

 how about the holding activity having an explicit pointer as a local
 variable of one of its child fragments? what about this pointer? as
 fragments go popping out of stack it is possible that the activity may
 hold on to each of these stacked fragments. (Ofcourse there is the
 find by tag or id of those in the current stack)

 I suspect these local pointers to other fragments may need to be
 explicitly managed through save/restore states??

 Thanks for helping us demystify a few things...

 Satya

 On Fri, Feb 18, 2011 at 1:13 AM, Dianne Hackborn hack...@android.com
 wrote:
  No, actually, one of the big benefits of fragments is that they are
  *not*
  sub-activities, they don't try to have a pretense of being isolated from
  each other, and are designed to allow you to easily use direct pointers
  to
  them.
 
  Don't try to impose object oriented because you feel like this somehow
  magically makes things better.  Unless it serves a purpose, it doesn't.
  Anyway there is a perfectly fine way to do these interactions that most
  people will agree is object oriented and makes the code much simpler and
  lighter weight: define a callback interface that one fragment (or
  activity)
  implements and another can then call.
  See for example the built-in facility for a fragment to have a pointer
  to a
  target fragment.  This is the fragment version of activity's
  onActivityResult().  However because fragments don't have a goal of
  imposing
  a strict (remote-able) high-level interface to itself, sending results
  between fragments is a lot easier: just define an interface of whatever
  functionality you want, which the target fragment can implement, and the
  sending can cast and call on.
  You can also take advantage of the FragmentManager APIs to save a
  fragment
  pointer in a bundle and later retrieve it, to allow you to maintain
  direct
  pointers across state save/restore.
  Basically, with fragments you'll want to unlearn a lot of the painful
  things
  you got used to dealing with in embedded activities. :)
  On Thu, Feb 17, 2011 at 8:10 PM, davemac davemac...@gmail.com wrote:
 
  I'd love to hear opinions on the best way to communicate between
  fragments.
 
  If we consider that fragments are like sub-activities (a common
  metaphor), then we might think to use broadcast messages to tell one
  fragment about something that happened in another fragment. That seems
  a bit difficult though not impossible.
 
  The samples simply lookup one fragment from another then access views
  directly. This forces that fragment to understand what's going on
  around it, which doesn't feel as object-oriented as I'd like. I'd feel
  better if maybe the activity was doing that sort of coordination, so
  the fragment tells the activity, and the activity figures out which
  other fragment, if any, needs to get a message, then invokes a method
  on the fragment so it can perform any updates. Or the activity could
  decide we're in a situation where we need to fire up a separate
  activity. Or maybe move things around on the screen.
 
  Am I over-complicating things here? I realize that a mobile app should
  be as compact as possible, and if that means just do it and access
  views in other fragments directly, then I could go along with that.
  But I thought I'd ask the group to get some other opinions.
 
  - dave
 
  --
  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
 
 
 
  --
  Dianne Hackborn
  Android framework engineer
  hack...@android.com
 
  Note: please don't send private questions to me, as I don't have time to
  provide private support, and so won't reply to such e-mails.  All such
  questions should be posted on public forums, where I and others can see
  and
  answer them.
 
  --
  You received this message because you are subscribed

[android-developers] what is the diff between dismissing a dialogfragment or explicitly removing it from the fragment manager?

2011-02-17 Thread Satya Komatineni
ASampleDialogFragment
extends DialogFragment
{
   onButtonDismiss()
   {
 this.dismiss();
   }
   onButtonRemove()
   {
FragmentManager fm = this.getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.remove(this);
ft.commit();
   }
}

if my intention is to dismiss the dialog I would probably call
onDismiss() as shown in the onButtonDismiss() function. As per the
documentation the dismiss will automatically take care of removig
the dialog fragment from the stack etc. This is probably the right
thing in this scenario. Also in this case the order of callbacks are


onDismiss
onStop
onDestroyView


However I see in the honeycomb preview dialog fragment example a
series of dialogs are added to teh backstack and an explicit remove is
called before adding the new fragment dialog adn showing it.

So I thought I would try an explicit remove(fragment) as in the code
above. The code seem to dismiss the dialog fine but the order of
callbacks is different

onStop
onDestroyView
onDismissDialog

Essentially in this sequence if I am relying on the view in
onDismissDialog the view may not be there.

Just curiouse, when would one call dismiss() and when would one call
remove(fragment).

Thanks
Satya

-- 
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] Can a fragment hold on to local variables?

2011-02-17 Thread Satya Komatineni
A fragment can be instantiated using its default constructor by the
base framework.

The initialization arguments are passed as  a bundle that can be
restored and reset.

How about local variables for managing state of that fragment?

Does one need to use the bundle to insert/remove these local variables?

Or does one need to reset local variables based on lifecycle methods
and valid only for the current life of the fragment?

Appreciate your coments and help
Satya

-- 
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] How does one set title for a DialogFragment

2011-02-15 Thread Satya Komatineni
A DialogFragment seem to indicate a style that is

STYLE_NO_TITLE

when the style is

STYLE_NORMAL

The display from the API demos shows a glowing horizontal bar with no title.

How does one go about setting a title?

I dont' see any methods on DialogFragment or Fragment to set titles.

The supplied view from onCreateView may not do this, I suspect.

Any insight is greatly appreciated

Satya

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


Re: [android-developers] Re: Fragment question on the use of the arguments bundle

2011-02-14 Thread Satya Komatineni
I think Dave's code can be slightly changed to have the desired affect
and still maintain constructor semantics

public class MyFragment extends Fragment {
public MyFragment() {}
public MyFragment(int index) {
//MyFragment f = new MyFragment();
Bundle args = new Bundle();
args.add(index, index);
this.setArguments(args);
}

Notice the commented out instantiation and uses the this.setArguments().

Satya


On Mon, Feb 14, 2011 at 9:47 AM, Kostya Vasilyev kmans...@gmail.com wrote:
 The code fragment below creates two instances of MyFragment, which is
 probably not what you intended.

 One is created by the new operator outside the constructor (someone doing
 new MyFragment(myIndexValue)) and another instance inside the constructor
 (f = new MyFragment). The latter one, with the index value, is not
 returned to the caller in any way, it just gets dropped on the floor.

 What you probably want is a factory method, like this:

 public class MyFragment extends Fragment {
 public static MyFragment createMyFragment(int index) {
 MyFragment f = new MyFragment();
 Bundle args = new Bundle();
 args.putInt(index, index);
 f.setArguments(args);
   return f;
 }
 }

 which is remarkably similar to public static DetailsFragment
 newInstance(..) in Dianne's blog post, see 3rd code example from the top.

 Now clients of MyFragment can do MyFragment f =
 MyFragment.createMyFragment(myIndexValue);

 -- Kostya

 14.02.2011 17:20, davemac пишет:

 public class MyFragment extends Fragment {
 public MyFragment() {}
 public MyFragment(int index) {
 MyFragment f = new MyFragment();
 Bundle args = new Bundle();
 args.add(index, index);
 f.setArguments(args);
 }
 [ ... ]
 }
 Now the clients of MyFragment can instantiate one with arguments much
 easier, yet I still get the recoverability because I do the right
 things behind the scenes.


 --
 Kostya Vasilyev -- http://kmansoft.wordpress.com

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

-- 
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] Will this action bar navigation mode be there: NAVIGATION MODE DROPDOWNLIST

2011-02-05 Thread Satya Komatineni
I see this navigation mode in the API however not in the javadoc that
is downloaded with honeycomb preview.

Any thoughts which is more recent?

Thanks
Satya

-- 
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] Re: Will this action bar navigation mode be there: NAVIGATION MODE DROPDOWNLIST

2011-02-05 Thread Satya Komatineni
Looks like the value for both

NAVIGATION_MODE_LIST
NAVIGATION_MODE_DROPDOWN_LIST

appears to be the same.

The only affect of setting one mode or vs the other, (betweent these
two modes), is wether to show the titles or not. I suppose those can
be done through display options setting.

Satya

On Sat, Feb 5, 2011 at 12:58 PM, Satya Komatineni
satya.komatin...@gmail.com wrote:
 I see this navigation mode in the API however not in the javadoc that
 is downloaded with honeycomb preview.

 Any thoughts which is more recent?

 Thanks
 Satya




-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

-- 
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] Re: Will this action bar navigation mode be there: NAVIGATION MODE DROPDOWNLIST

2011-02-05 Thread Satya Komatineni
Here is some sample code, images of various actionbar modes, and a
downloadable sample project.

http://www.satyakomatineni.com/item/3624


On Sat, Feb 5, 2011 at 1:21 PM, Satya Komatineni
satya.komatin...@gmail.com wrote:
 Looks like the value for both

 NAVIGATION_MODE_LIST
 NAVIGATION_MODE_DROPDOWN_LIST

 appears to be the same.

 The only affect of setting one mode or vs the other, (betweent these
 two modes), is wether to show the titles or not. I suppose those can
 be done through display options setting.

 Satya

 On Sat, Feb 5, 2011 at 12:58 PM, Satya Komatineni
 satya.komatin...@gmail.com wrote:
 I see this navigation mode in the API however not in the javadoc that
 is downloaded with honeycomb preview.

 Any thoughts which is more recent?

 Thanks
 Satya




 --
 Satya Komatineni
 http://www.satyakomatineni.com
 http://www.androidbook.com




-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

-- 
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] can multiple activiites share an ActionBar?

2011-02-02 Thread Satya Komatineni
Hello there.

I am looking at the ActionBar classes in 3.0.

Each activity can control its ActionBar.

Activity
{
  .
  ActionBar bar = getActionBar();
  bar.addTab(..1..)
  bar.addTab(..1..)
  .
}

Does every activity in an application setup an ActionBar
independently? Especially if there are common icons or actions that
needs to be activated across multiple activities, is it still the
responsibility of the individual activities to orchestrate?

Thanks
Satya

-- 
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] In Android 2.2.1 startSearch() seem to behave differently...

2010-12-01 Thread Satya Komatineni
The documentation of startSearch indicates that the globalSearch
indicator of false will invoke the glbal search if there is not
local search defined. if this indicator is true it will always
invoke global search irrespective of local search.

I am noticing that on a simple activity in an application calling
onSearchRequested() which in turn calls the startSearch() with a
false flag, is not invoking Global search.

Is this a change in direction? or documentation not updated?

Appreciate any input
Thanks

-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] Re: Can anyone recommend a good OpenGL ES book?

2010-11-03 Thread Satya Komatineni
If it were OpenGL ES 1.x, the opengl redbook would have been a very good one.

However the OpenGL ES 2.x is a different animal requiring a knowledge
of the shading programming language.

I recently bouth OpenGL Super Bible as it promised it covered a lot of
the new opengl apis. I am a bit dissapointed as it hides a lot of
detail behind libraries. This doesnt give a lot of opportunity to
learn.

So my search for a good opengl book is still on. I couldn't find
decent online references either. They all assume a ton of stuff.

However the one book I promised myself to buy and read is

OpenGL Shading Language by Randi Rost.

I don't know if it will turn out to be  a good one. But one will need
atleast one book that is just dedicated to thsi new animal.

I have been planning on documenting what I find on these books here:

http://www.satyakomatineni.com/akc/display?url=DisplayNoteIMPURLreportId=3173ownerUserId=satya

Check in once in a while I will post what I find.

In short

I am dissapointed with
**
Mobile 3D Graphics  Kari Pulli
OpenGL Super Bible
OpenGL programming guide (for ES 2.0)

I would like to consider

OpenGL programming guide (Core OpenGL concepts0
Shading programming language - Randi Rost

I am not sure off
*
OpenGL ES 2.0 Programming Guide

Meanwhile if you find a reasonable book do tell.

Thanks
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

On Tue, Nov 2, 2010 at 11:02 PM, Leigh McRae
leigh.mc...@lonedwarfgames.com wrote:
 The Red Book is pretty good for OpenGL but it's not ES.  Here is a free
 link.

 http://fly.cc.fer.hr/~unreal/theredbook/

 Other than that you're likely best off with getting an iphone book about 3d
 game dev.



 On 11/2/2010 10:47 PM, Matt Quigley wrote:

 A little.  I took a 3D graphics class in college.  I've actually been
 drawing lines, squares, and textures on Android already.  The thing
 is, I'd like to know how to start from scratch, instead of starting
 from a tutorial.  Basically, I'd like to KNOW why I'm writing the code
 I write.  It's just a yucky feeling (to me, at least) to not know why
 a line of code is there.

 On Nov 2, 7:53 pm, Leigh McRaeleigh.mc...@lonedwarfgames.com  wrote:

 Do you have any 3d experience?

 On 11/2/2010 7:28 PM, Matt Quigley wrote:

 I'm looking for a good book to buy to help me with OpenGL ES.  This is
 obviously going to be for Android, but I suppose the benefits will
 spill over to iPhone development too.  Although I'm not specifically
 opposed to a general OpenGL book, I'm not going to be using it on my
 desktop (at least not professionally).
 Wouldn't hurt to throw a few good online references too, although what
 I've found with online tutorials is that they teach a code snippet but
 not the whole picture.  Or, they don't target ES (embedded systems,
 like Android).
 Thanks,
 -Matt

 --
 Leigh McRaewww.lonedwarfgames.com

 --
 Leigh McRae
 www.lonedwarfgames.com

 --
 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 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] what logic does contacts api use to aggregate (possibly) overlapping fields from multiple raw contacts

2010-11-02 Thread Satya Komatineni
when a contact detail screen is presented in the contacts
application, how is each field aggregated from its underlying raw
contacts

case 1: Overlapping fields

when the same field exists in two or more contacts. Say they have two
different last names or emails in different accounts. Does the
contacts app show both fields with an account indicator?

case 2: Non overlapping fileds

one rawcontact has email while the other one has phone number

Short of scouring the source code, I have exhausted searching everywhere else.

Any help is much appreciated

Thanks
Satya

-- 
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] will the android emulator support opengles 2.0 in the future?

2010-10-04 Thread Satya Komatineni
From the posting so far I have seen, the current emulator as of API
level 8 and Platform 2.2 does not support OpenGL ES 2.0. (Only in the
emulator that the support is not there)

(The support is there at API level 8 for the ES 2.0)

wondering if any jone has figured out the following

1. Will the emulator support ES 2.0 in the future (considering there
is compilers, shaders etc needed to support es 2.0)
2. What is a likely timeframe this may be available? (months or
sometime future?)

I suppose considering that iPhone SDK has the emulator suppor for es
2.0, it can be anticipated on the Android emulator as well.

Thanks for the help
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] Re: will the android emulator support opengles 2.0 in the future?

2010-10-04 Thread Satya Komatineni
Robert,
Thank you very much. that is incredibly helpful to know.

Satya


On Mon, Oct 4, 2010 at 5:24 PM, Robert Green rbgrn@gmail.com wrote:
 FWIW - The iPhone simulator does not emulate the actual phone.
 Instead it routes calls to native OSX functions, simulating the
 environment.  The Android emulator does in fact emulator an ARM CPU
 and runs Android OS on it, which is an important distinction between
 the two.  When using GL in the iPhone simulator, you're actually
 running all of your GL on the PowerVR GLES emulation library, which
 uses hardware.  It's great for developing but you still really need a
 device to test since a PC GPU is going to be many times faster than a
 mobile GPU.

 So why can't the Android emulator do the same thing?  Because the PVR
 lib is for x86/OSX and the Android emulator is running on ARM.



 On Oct 4, 4:13 pm, Satya Komatineni satya.komatin...@gmail.com
 wrote:
 From the posting so far I have seen, the current emulator as of API
 level 8 and Platform 2.2 does not support OpenGL ES 2.0. (Only in the
 emulator that the support is not there)

 (The support is there at API level 8 for the ES 2.0)

 wondering if any jone has figured out the following

 1. Will the emulator support ES 2.0 in the future (considering there
 is compilers, shaders etc needed to support es 2.0)
 2. What is a likely timeframe this may be available? (months or
 sometime future?)

 I suppose considering that iPhone SDK has the emulator suppor for es
 2.0, it can be anticipated on the Android emulator as well.

 Thanks for the help
 Satya Komatinenihttp://www.satyakomatineni.comhttp://www.androidbook.com

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


Re: [android-developers] Custom Cursor wrapping a MatrixCursor

2010-08-19 Thread Satya Komatineni
Mark,
It has been a while I looked into this when I researched this stuff
for Live Folders chapter in Pro Android 2 book.
I have some source code from the book here at the following URL. See
if this helps

http://www.satyakomatineni.com/akc/display?url=DisplayNoteIMPURLreportId=3014ownerUserId=satya

Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

On Thu, Aug 19, 2010 at 3:22 AM, Mark Carter mjc1...@googlemail.com wrote:
 I want to implement Cursor so that it wraps another Cursor (probably
 MatrixCursor) and can swap out the wrapped Cursor as necessary.

 I've tried two approaches:

 1. Subclass CursorWrapper. The problem with this is that any calls to
 registerX/unregisterX methods land on the wrapped cursor. Therefore,
 instead, the wrapping cursor needs to maintain these observers and how
 they are notified. This gets messy.

 2. Subclass AbstractCursor and override some methods to actually get
 the data from another cursor (the MatrixCursor). This is also tricky
 because you are trying to juggle two cursors as one. This just feels
 *wrong*.

 Any thoughts?

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


Re: [android-developers] Re: Custom Cursor wrapping a MatrixCursor

2010-08-19 Thread Satya Komatineni
Alright,
let me take a look. It will take a bit of time to get into this.

On Thu, Aug 19, 2010 at 10:43 AM, Mark Carter mjc1...@googlemail.com wrote:
 Thanks Satya. I saw that example and tried it out but its pretty clear
 that the content observers and dataset observers are being set on the
 wrapped MatrixCursor which is discarded as soon as setInternalCursor()
 is called...

 On Aug 19, 3:53 pm, Satya Komatineni satya.komatin...@gmail.com
 wrote:
 Mark,
 It has been a while I looked into this when I researched this stuff
 for Live Folders chapter in Pro Android 2 book.
 I have some source code from the book here at the following URL. See
 if this helps

 http://www.satyakomatineni.com/akc/display?url=DisplayNoteIMPURLrepo...

 Satya Komatinenihttp://www.satyakomatineni.comhttp://www.androidbook.com





 On Thu, Aug 19, 2010 at 3:22 AM, Mark Carter mjc1...@googlemail.com wrote:
  I want to implement Cursor so that it wraps another Cursor (probably
  MatrixCursor) and can swap out the wrapped Cursor as necessary.

  I've tried two approaches:

  1. Subclass CursorWrapper. The problem with this is that any calls to
  registerX/unregisterX methods land on the wrapped cursor. Therefore,
  instead, the wrapping cursor needs to maintain these observers and how
  they are notified. This gets messy.

  2. Subclass AbstractCursor and override some methods to actually get
  the data from another cursor (the MatrixCursor). This is also tricky
  because you are trying to juggle two cursors as one. This just feels
  *wrong*.

  Any thoughts?

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] onCreate, onStop..... super.onCreate, super.onStop... called before code or after?

2010-07-31 Thread Satya Komatineni
Probably there are exceptions to every rule.

In this particular instance I would probably have the base class
complete its work before I do the work of the derived. May be a poor
parallel, but if I am constructing a multi-story house, I would want
to finish the base floors and move on to the upper floors.

Another thought is, a derived class comes later in conception than the
base class. So a derived class can anticipate what a base class does
on the otherhand baseclass designers would not have known what the
derived class would have done.

In case of a constructor, the compiler will tell you that you have to
call the super first.

However if I know that I am not altering the state of the base class,
such as logging a message, I could put that method either before or
after.

Also if you want the behavior of the base class to be a default one
after you have exhausted your options such as attending to menus, then
you want to call the base super last.

In the particular case of onCreate, as it resembles construction, I
go with calling the super first.

Hope this reflection helps

Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

On Sat, Jul 31, 2010 at 10:26 PM, Moto medicalsou...@gmail.com wrote:
 This might be a simple question but I'm seeing the super call at the
 end of the overwritten function and also at the start of the
 function.  What is recommended? any differences on this?

 I feel very beginner with this question... :P

 i.e.

       �...@override
        protected void onCreate)
        {
                super.onCreate();
                // some code
        }

 or

       �...@override
        protected void onCreate()
        {
                // some code
                super.onCreate();
        }

 -Moto

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



-- 
Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

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


Re: [android-developers] What is a WeakReference?

2010-07-22 Thread Satya Komatineni
Recently I had to do some research on the role of weak references
possibly for configuration changes and auto restart of activities. See
if the following material is useful

http://www.satyakomatineni.com/akc/display?url=DisplayNoteIMPURLreportId=3528ownerUserId=satya

The weak references are towards the end of the document

Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com


On Thu, Jul 22, 2010 at 1:48 PM, GodsMoon godsm...@gmail.com wrote:
 Google just posted a new blog post on
 http://android-developers.blogspot.com/2010/07/multithreading-for-performance.html.
 I understand the AsyncTask and I'm even using one in a list with
 images already.

 But I don't understand what a WeakReference is. I gather is is a
 garbage collector directive, but I thought I didn't need to manage
 garbage collection on Android.

 http://developer.android.com/reference/java/lang/ref/WeakReference.html
 isn't as helpful as I was hoping it would be.

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


Re: [android-developers] R cannot be resolved

2010-07-21 Thread Satya Komatineni
It is a basic question, but let me ask you anyway, do you have the ADT
installed in Eclipse?

When you expand the project do you see an R.java in a sub directory
similar to what is at the following url?

http://www.satyakomatineni.com/akc/filestorage/satya/documentfiles/3279/two-R-java.gif

Perhaps, give your directory structure in that project and probably
the contents of the R.java file.

Satya Komatineni
http://www.satyakomatineni.com
http://www.androidbook.com

On Tue, Jul 20, 2010 at 6:31 PM, Marc marc.d.pa...@gmail.com wrote:
 Hi.

 I'm an Android development newb, and I got a problem with Eclipse. I
 tried a few tutorials, but I can't run the tutorial-apps because it
 pops up with this error: R cannot be resolved .
 I've searched a lot of different fora, where people describes the same
 problem, but I just can't fix it.
 A lot of people recommend unchecking Build automatically, Cleaning
 and rechecking Build automatically, people also suggest that it's a
 line that says import R. that causes the problem, but it feels like
 I've tried everything and I still can't make it work...

 I use this SDK : http://developer.android.com/sdk/index.html
 along with 3 different versions of Eclipse, but it's the same error-
 message i get in every version.

 NB.: I don't have a .classpath file, nor do I have a .project file.
 Could that cause the problem ?


 Help is greatly appreciated.

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


Re: [android-developers] why does AlarmManagerService.java call remove first in a set alarm?

2010-07-14 Thread Satya Komatineni
I would have probably seen that if the operation indicated by the
pendingintent is used as a key.

But I am saying an explicit removal of the alarm containing the
operation (pending intent).

See the code (little) below.

Moreover what one is doing is

alarms.put(at 11pm, foo)
alarms.put(at 12 pm, foo)

Conceptually I would have understood if I did

pendingintent.gooff(at 11);
pendingintent.gooff(at 12);

*** AlarmManagerService.java extract

160 public void setRepeating(int type, long triggerAtTime, long interval,
 161 PendingIntent operation) {
 162 if (operation == null) {
 163 Slog.w(TAG, set/setRepeating ignored because there
is no intent);
 164 return;
 165 }
 166 synchronized (mLock) {
 167 Alarm alarm = new Alarm();
 168 alarm.type = type;
 169 alarm.when = triggerAtTime;
 170 alarm.repeatInterval = interval;
 171 alarm.operation = operation;
 172
 173 // Remove this alarm if already scheduled.
 174 removeLocked(operation);
 175
 176 if (localLOGV) Slog.v(TAG, set:  + alarm);
 177
 178 int index = addAlarmLocked(alarm);
 179 if (index == 0) {
 180 setLocked(alarm);
 181 }
 182 }
 183 }


AlarmManagerService doest maintain separate 'alarm' objects with every
set even with the same equivalent intent. It then physically removes
one of the alarm objects that were scheduled earlier.

Is this to avoid a later confusion between two alarms with the same intent??

Anyway thanks for chiming in

Satya


On Wed, Jul 14, 2010 at 1:58 AM, Dianne Hackborn hack...@android.com wrote:
 If they are the same intent, they can not be uniquely distinguished, so the
 more recent one replaces the previous.
 It's like doing:
 HashMapString, Foo alarms;
 Foo foo1 = new Foo();
 Foo foo2 = new Foo();
 alarms.put(mything, foo1);
 alarms.put(mything, foo2);
 The second call replaces the value of the first.

 On Tue, Jul 13, 2010 at 8:04 PM, Satya Komatineni
 satya.komatin...@gmail.com wrote:

 It was a bit baffling (Probably there is a good reason, and it doesnt
 take much to baffle me)

 AlarmManager am;
 ...
 PendingIntent pi;


 am.set(pi, ...) at 11pm
 am.set(pi,...) at 2pm

 Same pending intent with the same intent and  request code, in
 otherwords they resolve to same intent on equals.

 Although I know what happens (being the latest one takes precedence),
 I would have expected my broadcast receiver to be called twice.

 I thought something funny is happening in the PendingIntent.

 However when I looked at the AlarmManagerService.java I have noticed
 that the set.. methods are calling a remove using the
 PendingIntent that is passed in, essentially cancelling the one
 before.

 Why is that??

 It is late, my head hurts, I am hoping someone will throw some light.

 Thanks a bunch
 Satya

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



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

 Note: please don't send private questions to me, as I don't have time to
 provide private support, and so won't reply to such e-mails.  All such
 questions should be posted on public forums, where I and others can see and
 answer them.

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


  1   2   >