[android-developers] How to dismiss nested dialogfragment correctly after rotation?

2013-09-15 Thread Greenhand
I use appcompat library and support library v4 to host some fragments for tabs. In a specific fragment A, I need to do network operation. In order not to block the UI thread, I execute an AsyncTask in fragment A and do the network operation in doInBackGround() of the AsyncTask. To prevent

[android-developers] How to dismiss nested dialogfragment correctly after rotation?

2013-09-15 Thread Greenhand
I use appcompat library to host some fragments for tabs. In a specific fragment A, I need to do network operation. In order not to block the UI thread, I use an AsyncTask and do the network operation in doInBackGround(). To prevent messing around keep AsyncTask to survive rotation in the

Re: [android-developers] Re: How to dismiss nested dialogfragment correctly after rotation?

2013-09-15 Thread Greenhand
15, 2013 1:52:22 PM UTC+3, Greenhand wrote: Thanks for pointing out the mistakes. The whole code is too long to post and maintain readability so I just put some snippet. The MyAsyncTask having a constructor named GetTokenAsyncTask is a typo, the constructor should named MyAsyncTask

[android-developers] appcompat action bar fragment oncreateview called twice

2013-09-05 Thread Greenhand
I followed the way that http://developer.android.com/guide/topics/ui/actionbar.html#Tabs says to use appcompat actionbar to add tabs. However, I found that the added fragments oncreateview() will be called twice. After searching the web, I found there is a workaround solution at

[android-developers] oncreateview() called twice of added fragments of appcompat action bar

2013-09-05 Thread Greenhand
I followed the way that http://developer.android.com/guide/topics/ui/actionbar.html#Tabs says to use appcompat actionbar to add tabs. However, I found that the oncreateview() of added fragments will be called twice. After searching the web, I found there is a workaround solution at

[android-developers] Re: LoaderCallbacks.OnLoadFinished called twice in Fragments

2013-08-28 Thread Greenhand
Same. Although it is an old thread, I encounter the same issue, too. I find the thread http://stackoverflow.com/questions/11001475/listfragment-is-inflated-twice. It says put initLoader in onCreate() according to Fragment lifecycle (

[android-developers] android action bar background

2013-08-23 Thread Greenhand
I read https://developer.android.com/training/basics/actionbar/styling.html and use style name=MyActionBar parent=@style/Widget.Holo.Light.ActionBar.Solid.Inverse *item name=android:background@drawable/actionbar_background /item* /style to set the ActionBar background.

Re: [android-developers] android action bar logo with AppCompat in XML

2013-08-22 Thread Greenhand
launcher icon: 1 action bar logo: 1 The Android 2.2 emulator behaves strangely. Why? Is it a bug? On Thursday, August 22, 2013 12:22:25 AM UTC+8, TreKing wrote: On Wed, Aug 21, 2013 at 11:06 AM, Greenhand coopera...@gmail.comjavascript: wrote: Is there a correct code snippet

Re: [android-developers] android action bar logo with AppCompat in XML

2013-08-22 Thread Greenhand
4.1.2 launcher icon: 1 action bar logo: 1 The Android 2.2 emulator behaves strangely. Why? Is it a bug? On Thursday, August 22, 2013 12:22:25 AM UTC+8, TreKing wrote: On Wed, Aug 21, 2013 at 11:06 AM, Greenhand coopera...@gmail.comjavascript: wrote: Is there a correct code snippet

Re: [android-developers] android action bar logo with AppCompat in XML

2013-08-22 Thread Greenhand
4.1.2 launcher icon: 1 action bar logo: 1 The Android 2.2 emulator behaves strangely. Why? Is it a bug? On Thursday, August 22, 2013 12:22:25 AM UTC+8, TreKing wrote: On Wed, Aug 21, 2013 at 11:06 AM, Greenhand coopera...@gmail.comjavascript: wrote: Is there a correct code snippet

[android-developers] android action bar logo with AppCompat in XML

2013-08-21 Thread Greenhand
I read http://developer.android.com/guide/topics/ui/actionbar.html and it says Using a logo instead of an icon By default, the system uses your application icon in the action bar, as specified by the

[android-developers] custom tab

2013-03-04 Thread Greenhand
I have read about the TabHost ( http://developer.android.com/reference/android/widget/TabHost.html). However, I still do not know how to make a custom style tab like the attachment. Is there a way to do so? -- -- You received this message because you are subscribed to the Google Groups

[android-developers] asynctask vs. FragmentRetainInstance.java in API demo

2013-01-30 Thread Greenhand
For asynctask to deal with activity rotation, I find this solution: https://github.com/commonsguy/cw-android/blob/master/Rotation/RotationAsync/src/com/commonsware/android/rotation/async/RotationAsync.java . However, getlastnonconfigurationinstance() is deprecated in API level 13 (

Re: [android-developers] Re: android imageview stretch to background height and keep ratio

2013-01-26 Thread Greenhand
Although I can keep the ratio, I do not know what my background height is from parameters. Could you give me some code snippetss? lbendlin於 2013年1月26日星期六UTC+8下午7時33分50秒寫道: Now that you have extended the object you can change the calculations for measure to achieve your desired effect while

Re: [android-developers] Re: android imageview stretch to background height and keep ratio

2013-01-25 Thread Greenhand
上午3時57分31秒寫道: The quickest solution would be to create a custom imageview that extends imageview, and then handle the onLayout and onMeasure yourself. On Friday, January 25, 2013 12:59:38 AM UTC-5, Greenhand wrote: Because if I changed the two inner image views to match_parent

Re: [android-developers] Correct way to implement Activity onDestroy()?

2013-01-16 Thread Greenhand
In my scenario, I have a task to run but I do not want it to block my UI thread. Therefore, I adopt AsyncTask. IntentService can run a task at a time on another Thread but I do not know how to cancel it as mentioned earlier. The problem I would like to deal with is that when user press back

Re: [android-developers] Correct way to implement Activity onDestroy()?

2013-01-14 Thread Greenhand
, at which point the Activity will be thrown away: along with its contents. Of course, if you're holding onto Views elsewhere that's bad (i.e., don't hold static refs). kris On Mon, Jan 14, 2013 at 1:42 AM, Greenhand coopera...@gmail.comjavascript: wrote: I read http://android

Re: [android-developers] Correct way to implement Activity onDestroy()?

2013-01-14 Thread Greenhand
the fact that I proposed it myself, at one point) are just Voodoo. G. Blake Meike Marakana Programming Android 2ed is now in stores: http://bit.ly/programmingandroid On Monday, January 14, 2013 1:10:52 AM UTC-8, Greenhand wrote: Thank you. Another related question, in section 5

[android-developers] Correct way to implement Activity onDestroy()?

2013-01-13 Thread Greenhand
I read http://android-developers.blogspot.tw/2009/01/avoiding-memory-leaks.html about avoiding memory leaks. I would like to know whether I should null out all member variables, such as TextView and Button in onDestroy()? Or, unregistering listener, unbinding service and etc.in onDestroy() are

[android-developers] api demo 4.0.3 com.example.android.apis.app.FragmentRetainInstance

2013-01-01 Thread Greenhand
I would like to ask about the com.example.android.apis.app.FragmentRetainInstance.java in android api demo 4.0.3, which demos how to use fragment to handle configuration changes such as rotation. At line 44-47 if (savedInstanceState == null) {

[android-developers] Emulator 4.0.3 calendar create event not shown

2012-12-28 Thread Greenhand
I followed the steps in http://mavenlog.wordpress.com/2012/01/22/how-to-adding-a-calendar-in-the-android-ics-emulator/ to add my Gmail account to the built in Calendar app in Android 4.0.3 emulator. Then, I adpated the code snippet in

[android-developers] Fragment ID

2012-12-15 Thread Greenhand
At http://developer.android.com/guide/components/fragments.html, it mentions If you provide neither of the previous two, the system uses the ID of the container view. in the section of Adding a fragment to an activity. What does the ID of the container view means? -- You received this message

[android-developers] Re: Button#onClickListener thread unsafe?

2012-10-16 Thread Greenhand
I think I am confused. If the entire Android UI is completely thread safe and the events are queued, the event should be processed one by one. I would like to know why an inconsistent state can be seen during the execution even if I do not start a new thread in my code. G. Blake Meike於

[android-developers] Button#onClickListener thread unsafe?

2012-10-14 Thread Greenhand
In my project, I has a layout as follows: LinearLayout xmlns:android=http://schemas.android.com/apk/res/ android android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical Button android:id=@+id/startButton

[android-developers] Re: android bindservice rotation

2012-06-05 Thread Greenhand
at 11:30 AM, Greenhand cooperateonl...@gmail.com wrote: If I use startService(), can theActivitycommunicate with theService and vice versa? startService() uses a variation of the command pattern: you communicate with theservicevia extras on the Intent passed to startService() as the command

[android-developers] Re: android bindservice rotation

2012-06-04 Thread Greenhand
the new one. more clearly, such as some code fragments? I have never used a fragement. Is it different from Activity when it comes to handling bound service on rotation? On 6月3日, 下午10時08分, Mark Murphy mmur...@commonsware.com wrote: On Sun, Jun 3, 2012 at 10:04 AM, Greenhand cooperateonl

[android-developers] Re: android bindservice rotation

2012-06-04 Thread Greenhand
has leaked ServiceConnection that was originally bound here at the line with !!! mark. On 6月4日, 下午5時45分, Kostya Vasilyev kmans...@gmail.com wrote: 04.06.2012 13:06, Greenhand написал: I modify my code and use bindService(new Intent(getApplicationContext(), MessengerService.class

[android-developers] Re: android bindservice rotation

2012-06-04 Thread Greenhand
In onDestroy(), I checked whether the Activity is finishing and bound. If so, I unbindService(). if(isFinishing() serviceBound){ unbindService(serviceConnection); Log.d(MyMediaPlayerActivity,Activity: unbindService()); } On 6月4日, 下午9時04分, Greenhand cooperateonl...@gmail.com wrote: I

[android-developers] Re: android bindservice rotation

2012-06-04 Thread Greenhand
if (!mBound) return; to prevent null pointer exception but user will perceived that the button is not working before the callback is called. Is there a better way to solve it? On 6月4日, 下午9時20分, Mark Murphy mmur...@commonsware.com wrote: On Mon, Jun 4, 2012 at 9:17 AM, Greenhand cooperateonl

[android-developers] Re: android bindservice rotation

2012-06-04 Thread Greenhand
Thank you! On 6月4日, 下午10時05分, Mark Murphy mmur...@commonsware.com wrote: Disable the button until it is usable. On Mon, Jun 4, 2012 at 9:57 AM, Greenhand cooperateonl...@gmail.com wrote: It works! The context is so mysterious in Android. Another question, in the tutorial (http

[android-developers] Re: android bindservice rotation

2012-06-04 Thread Greenhand
If I change the MessengerService into an media player service, a user can control the media player by the ServiceConnection in the Activity and the media player service can update the UI according to the state of media player. The downside is that the playback will be stopped when a user leaves

[android-developers] Re: android bindservice rotation

2012-06-04 Thread Greenhand
If I use startService(), can the Activity communicate with the Service and vice versa? On 6月4日, 下午11時15分, Mark Murphy mmur...@commonsware.com wrote: Don't use bindService(). Use startService(). On Mon, Jun 4, 2012 at 11:11 AM, Greenhand cooperateonl...@gmail.com wrote: If I change

[android-developers] android bindservice rotation

2012-06-03 Thread Greenhand
For the communication between Activity and Service, I followed the http://developer.android.com/guide/topics/fundamentals/bound-services.html#Messenger to implement an Activity that binds a Service. However, the Service will be killed and created when the Activity is rotating. Is there a way to

[android-developers] Re: android configuration change asynctask

2012-05-24 Thread Greenhand
Thank you! On 5月24日, 上午12時59分, Kostya Vasilyev kmans...@gmail.com wrote: Androidsources are available here: http://source.android.com/ For quickly jumping from docs to source, I often use this: https://chrome.google.com/webstore/detail/hgcbffeicehlpmgmnhnkjbjoldk... AndroidSDK Reference

[android-developers] Re: android configuration change asynctask

2012-05-23 Thread Greenhand
Handler() from an activty's callback such as onCreate will be connected to  the same message loop as well. -- K On 05/22/2012 07:00 PM, Greenhand wrote: But if we use an Activity reference directly (i.e. call a method in the Activity), will it also send a message to the message loop? I

[android-developers] Re: android configuration change asynctask

2012-05-22 Thread Greenhand
treking...@gmail.com wrote: On Mon, May 21, 2012 at 8:48 AM, Greenhand cooperateonl...@gmail.comwrote: I would like to know further about no messages will be processed between onRetainNonConfigurationInstance() to the following onCreate() under the hood, replied by Dianne Hackborn. You might

[android-developers] Re: android configuration change asynctask

2012-05-22 Thread Greenhand
But if we use an Activity reference directly (i.e. call a method in the Activity), will it also send a message to the message loop? I am afraid that the method called by Activity reference and the configuration change may happen concurrently. Does the message loop mentioned here is the same as

[android-developers] android configuration change asynctask

2012-05-21 Thread Greenhand
I read the thread AsyncTask and screen rotation in this group. I would like to know further about no messages will be processed between onRetainNonConfigurationInstance() to the following onCreate() under the hood, replied by Dianne Hackborn. If reading some Android source code is needed,

[android-developers] android developer-activity testing tutorial

2012-03-04 Thread Greenhand
I followed the section named Adding a UI test of the tutorial at http://developer.android.com/resources/tutorials/testing/activity_test.html. I was confused about why it wanted to interact with UI by UI-thread and send keys via instrumentation at the same test testSpinnerUI() method. I think

[android-developers] scan Bluetooth devices and log their location

2011-07-05 Thread greenhand
I would like to write an application which can scan Bluetooth devices around it, log their location and do periodically upload to server. To save energy, I hope to turn off location update when there are no Bluetooth devices detected. My current design is use an Activity and an IntentService