android Programming Glossary: eg
Android, How to manage start activity for result? http://stackoverflow.com/questions/10407159/android-how-to-manage-start-activity-for-result the SecondActivity using startActivityForResult method eg Intent i new Intent this SecondActivity.class startActivityForResult.. If you don't want to return back don't set any. eg In secondActivity if you want to send back data Intent returnIntent..
Android: ProgressDialog.show() crashes with getApplicationContext http://stackoverflow.com/questions/1561803/android-progressdialog-show-crashes-with-getapplicationcontext your ProgressDialog and starts anything else you needed eg. network IO . Something like this @Override public void onCreate..
Android: bug in launchMode=“singleTask”? -> activity stack not preserved http://stackoverflow.com/questions/2417468/android-bug-in-launchmode-singletask-activity-stack-not-preserved act android.intent.action.MAIN cat android.intent.category.LAUNCHER flag FLAG_ACTIVITY_NEW_TASK FLAG_ACTIVITY_RESET_IF_NEEDED.. Standard . The task which contains A will come to the foreground and keep the state the same as before. You can create a.. the same as before. You can create a Standard activity eg. C as the launcher and startActivity A in the onCreate method..
AsyncTask won't stop even when the activity has destroyed http://stackoverflow.com/questions/2531336/asynctask-wont-stop-even-when-the-activity-has-destroyed peculiar behavior which i'm not able to understand. For eg when the android screen's orientation changes then the activity..
How to sign an APK with more than one certificate? http://stackoverflow.com/questions/2881904/how-to-sign-an-apk-with-more-than-one-certificate Google Play does not accept APKs with multiple signatures. eg. You can sign an APK from the command line using jarsigner like..
Android keeps caching my intents Extras, how to declare a pending intent that keeps fresh extras? http://stackoverflow.com/questions/3140072/android-keeps-caching-my-intents-extras-how-to-declare-a-pending-intent-that-ke I have to customize the Intents based on some unique ID eg. setAction still have some problems. I define a PendingIntent.. with this contact ID mNotificationManager.cancel Integer.parseInt objContact.getId then raise a new notification for.. for this contact ID mNotificationManager.notify Integer.parseInt objContact.getId notification This works like this..
Google Analytics in Android app - dealing with multiple activities http://stackoverflow.com/questions/3216692/google-analytics-in-android-app-dealing-with-multiple-activities The docs should probably be updated to reflect this. eg. from inside your Activity Start the tracker in manual dispatch.. mode... tracker.start UA YOUR ACCOUNT HERE this BAD Regarding when to call start stop you can implement a sort of manual.. INSTANCE protected int activityCount 0 protected Integer dispatchIntervalSecs protected String apiKey protected Context..
Common class for AsyncTask in Android? http://stackoverflow.com/questions/3291490/common-class-for-asynctask-in-android for AsyncTask in Android I have a common class say for eg Class A which extends AsyncTask and has all the methods implemented.. ' Can someone let me know what the issue may be Regards Sunil android android asynctask share improve this question..
Android: Bitmap recycle() how does it work? http://stackoverflow.com/questions/3823799/android-bitmap-recycle-how-does-it-work manually garbage collect it before loading another bitmap eg. myBitmap.recycle Also is there a better way to load large images..
pass arraylist from one activity to other http://stackoverflow.com/questions/4780835/pass-arraylist-from-one-activity-to-other this question It depends on the type of arraylist putIntegerArrayListExtra String name ArrayList Integer value putParcelableArrayListExtra.. putIntegerArrayListExtra String name ArrayList Integer value putParcelableArrayListExtra String name ArrayList extends.. by replacing put with get with key string as argument eg myIntent.getStringArrayListExtra arrayPeople share improve..
What optimizations can I expect from Dalvik and the Android toolchain? http://stackoverflow.com/questions/4912695/what-optimizations-can-i-expect-from-dalvik-and-the-android-toolchain as possible with minimal impact to resource contention eg memory footprint CPU hijacked by the compiler thread so that.. and code cache lookup won't be invoked often. To some degree the major source of speedup comes from eliminating the repeated.. a few local optimizations implemented with the Froyo JIT Register allocation 8 registers for v5te target since the JIT produces..
How to make an Android view that flips between views on swipe/fling http://stackoverflow.com/questions/5071743/how-to-make-an-android-view-that-flips-between-views-on-swipe-fling slowly you should see the views dragging as you're swiping eg. the way the Launcher does it. I tried using a ViewFlipper with..
How turn on camera flash light programmatically in Android? http://stackoverflow.com/questions/6068803/how-turn-on-camera-flash-light-programmatically-in-android . The main parameter used here is FLASH_MODE_TORCH . eg. Code Snippet to turn on camera flash light. Camera cam Camera.open.. are also some problems while turning On Off flashlight. eg. for the devices not having FLASH_MODE_TORCH or even if it has..
How do I make an http request using cookies on Android? http://stackoverflow.com/questions/678630/how-do-i-make-an-http-request-using-cookies-on-android request to a remote server while properly handling cookies eg. storing cookies sent by the server and sending those cookies.. HttpPost https portal.sun.com amserver UI Login org self_registered_users goto portal dt gotoOnFail portal dt error true..
Handler vs AsyncTask vs Thread http://stackoverflow.com/questions/6964011/handler-vs-asynctask-vs-thread thread by other ways but there are many disadvantages for eg Main thread isn't thread safe in most of time in other words..
Update data in ListFragment as part of ViewPager http://stackoverflow.com/questions/7379165/update-data-in-listfragment-as-part-of-viewpager showed to update the data sometimes but others I got an IllegalStateException Can not perform this action after onSaveInstanceState... the position in the viewpager. So if the position is known eg 0 I can perform in updateFragments HomeListFragment fragment..
Detect a new Android notification http://stackoverflow.com/questions/9367196/detect-a-new-android-notification able to detect when a new status bar notification appears regardless of if it was caused by my app. To be more specific I.. Actually it is possible I use it in my app. You need to register an AccessibilityService and make sure the user enables.. Do something eg getting packagename final String packagename String.valueOf..
How to change the title of the Tab Dynamically http://stackoverflow.com/questions/2291607/how-to-change-the-title-of-the-tab-dynamically that we provide while adding the tabs to the TabHost. Eg TabHost.addTab tabHost.newTabSpec Tab2 .setIndicator I need..
How to determine if one of my activities is in the foreground http://stackoverflow.com/questions/2314969/how-to-determine-if-one-of-my-activities-is-in-the-foreground intent and will be able to deal with that itself. Eg it could than launch the desired activity show a notification..
Open-sided Android stroke? http://stackoverflow.com/questions/2422120/open-sided-android-stroke an Android shape object with stroke on only certain sides Eg I have stroke android width 3dip android color #000000 android..
Android: Programmatically animate between images in Gallery widget http://stackoverflow.com/questions/2731564/android-programmatically-animate-between-images-in-gallery-widget so a work around I thought of was to fake the key presses. Eg. dispatchKeyEvent new KeyEvent KeyEvent.ACTION_DOWN KeyEvent.KEYCODE_DPAD_LEFT..
How to change background color in android app http://stackoverflow.com/questions/2748830/how-to-change-background-color-in-android-app
How to deal with INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES without uninstallation http://stackoverflow.com/questions/3185444/how-to-deal-with-install-parse-failed-inconsistent-certificates-without-uninstal re build an apk and re install without the uninstallation. Eg. change some config in the AndroidManifest.xml or not sign the..
How to create a completely custom Dialogue/Popup in Android (change overlay colour and dialogue window layout) http://stackoverflow.com/questions/3728990/how-to-create-a-completely-custom-dialogue-popup-in-android-change-overlay-colo constructor that passes both the context AND the theme. Eg. myDialog new Dialog this R.style.CustomDialogTheme CustomDialogTheme.. view to whatever layout you want your dialog to look like. Eg. myDialog.setContentView R.layout.my_custom_overlay If you want..
Android: Disable rotations by 90°, but enable rotations by 180° http://stackoverflow.com/questions/4371631/android-disable-rotations-by-90-but-enable-rotations-by-180 screen orientation is apparently meant for this purpose. Eg you could do setRequestedOrientation ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE..
How to find Intent source in Android? [duplicate] http://stackoverflow.com/questions/4789155/how-to-find-intent-source-in-android Activity C displays extra information based on its source. Eg. If call comes from A then C displays only 2 textviews whereas..
android set multiple alarms simultaneosuly http://stackoverflow.com/questions/5549974/android-set-multiple-alarms-simultaneosuly time for two different operations to be performed. For Eg. A user sets alarm at 2'O clock and sets the duration to 15..
How to check if a value already exists in the database in Android http://stackoverflow.com/questions/7820905/how-to-check-if-a-value-already-exists-in-the-database-in-android present in the database and prevent inserting again Eg. Name of Database Exicom.sqlite Name of table TimeReport Fields..
Formula px to dp, dp to px android http://stackoverflow.com/questions/8309354/formula-px-to-dp-dp-to-px-android value is a rounded value used with the screen 'buckets'. Eg. on my Nexus 10 it returns 2 where the real value would be 298dpi..
How to manage multiple Async Tasks efficiently in Android http://stackoverflow.com/questions/9221343/how-to-manage-multiple-async-tasks-efficiently-in-android calls cant be combined and they are meant to be that way. Eg If you need quote info for GOOGLE then send a request to server..
Android, How to manage start activity for result? http://stackoverflow.com/questions/10407159/android-how-to-manage-start-activity-for-result share improve this question From your FirstActivity call the SecondActivity using startActivityForResult method eg Intent i new Intent this SecondActivity.class startActivityForResult i 1 In your SecondActivity set the data which you want.. set the data which you want to return back to FirstActivity If you don't want to return back don't set any. eg In secondActivity if you want to send back data Intent returnIntent new Intent returnIntent.putExtra result result setResult..
Android: ProgressDialog.show() crashes with getApplicationContext http://stackoverflow.com/questions/1561803/android-progressdialog-show-crashes-with-getapplicationcontext 400 seemed to work for me but you'll need to tinker that opens your ProgressDialog and starts anything else you needed eg. network IO . Something like this @Override public void onCreate Bundle savedInstanceState do all your other stuff here..
Android: bug in launchMode=“singleTask”? -> activity stack not preserved http://stackoverflow.com/questions/2417468/android-bug-in-launchmode-singletask-activity-stack-not-preserved HOME and launch the activity again ActivityManger calls an intent act android.intent.action.MAIN cat android.intent.category.LAUNCHER flag FLAG_ACTIVITY_NEW_TASK FLAG_ACTIVITY_RESET_IF_NEEDED cmp A So the result is A B HOME A. It's different.. result is A B HOME A. It's different when A's launchMode is Standard . The task which contains A will come to the foreground and keep the state the same as before. You can create a Standard activity eg. C as the launcher and startActivity A.. which contains A will come to the foreground and keep the state the same as before. You can create a Standard activity eg. C as the launcher and startActivity A in the onCreate method of C OR Just remove the launchMode singleTask and set FLAG_ACTIVITY_CLEAR_TOP..
AsyncTask won't stop even when the activity has destroyed http://stackoverflow.com/questions/2531336/asynctask-wont-stop-even-when-the-activity-has-destroyed upto 100 images . Everything works fine but there is this peculiar behavior which i'm not able to understand. For eg when the android screen's orientation changes then the activity is destroyed and created again. So I override the onRetainNonConfigurationInstance..
How to sign an APK with more than one certificate? http://stackoverflow.com/questions/2881904/how-to-sign-an-apk-with-more-than-one-certificate to sign an APK more than once just do so. But note that Google Play does not accept APKs with multiple signatures. eg. You can sign an APK from the command line using jarsigner like so jarsigner keystore original keystore my app unsigned.apk..
Android keeps caching my intents Extras, how to declare a pending intent that keeps fresh extras? http://stackoverflow.com/questions/3140072/android-keeps-caching-my-intents-extras-how-to-declare-a-pending-intent-that-ke custom intents for my alarms. Although I got clear answer that I have to customize the Intents based on some unique ID eg. setAction still have some problems. I define a PendingIntent this way Intent intent new Intent this viewContactQuick.class.. ns first try to clear any active notification with this contact ID mNotificationManager.cancel Integer.parseInt objContact.getId then raise a new notification for this contact ID mNotificationManager.notify Integer.parseInt.. Integer.parseInt objContact.getId then raise a new notification for this contact ID mNotificationManager.notify Integer.parseInt objContact.getId notification This works like this application creates a message for a contact an intent is provided..
Google Analytics in Android app - dealing with multiple activities http://stackoverflow.com/questions/3216692/google-analytics-in-android-app-dealing-with-multiple-activities using the Application instead of the activity instance itself. The docs should probably be updated to reflect this. eg. from inside your Activity Start the tracker in manual dispatch mode... tracker.start UA YOUR ACCOUNT HERE getApplication.. getApplication instead of Start the tracker in manual dispatch mode... tracker.start UA YOUR ACCOUNT HERE this BAD Regarding when to call start stop you can implement a sort of manual reference counting incrementing a count for each call to.. protected static GoogleAnalyticsSessionManager INSTANCE protected int activityCount 0 protected Integer dispatchIntervalSecs protected String apiKey protected Context context NOTE you should use your Application context not..
Common class for AsyncTask in Android? http://stackoverflow.com/questions/3291490/common-class-for-asynctask-in-android class for AsyncTask in Android I have a common class say for eg Class A which extends AsyncTask and has all the methods implemented i.e. onPreExecute doinbackground and onPostExecute ... boolean flag isResult flag public String getResult return finalResult ' Can someone let me know what the issue may be Regards Sunil android android asynctask share improve this question A clean way to use AsyncTask to get a result would..
Android: Bitmap recycle() how does it work? http://stackoverflow.com/questions/3823799/android-bitmap-recycle-how-does-it-work first myBitmap does it get Garbage Collected or do i have to manually garbage collect it before loading another bitmap eg. myBitmap.recycle Also is there a better way to load large images and display them one after another recycling on the way..
pass arraylist from one activity to other http://stackoverflow.com/questions/4780835/pass-arraylist-from-one-activity-to-other from one activity to other activity android share improve this question It depends on the type of arraylist putIntegerArrayListExtra String name ArrayList Integer value putParcelableArrayListExtra String name ArrayList extends Parcelable.. share improve this question It depends on the type of arraylist putIntegerArrayListExtra String name ArrayList Integer value putParcelableArrayListExtra String name ArrayList extends Parcelable value putStringArrayListExtra String name ArrayList..
What optimizations can I expect from Dalvik and the Android toolchain? http://stackoverflow.com/questions/4912695/what-optimizations-can-i-expect-from-dalvik-and-the-android-toolchain on this project the goal was to deliver a working JIT as soon as possible with minimal impact to resource contention eg memory footprint CPU hijacked by the compiler thread so that it can run on low end devices as well. Therefore we used a.. through a technique called chaining so that the interpreter and code cache lookup won't be invoked often. To some degree the major source of speedup comes from eliminating the repeated interpreter parsing overhead on frequently executed code.. frequently executed code paths. That said we do have quite a few local optimizations implemented with the Froyo JIT Register allocation 8 registers for v5te target since the JIT produces Thumb code 16 registers for v7 Scheduling eg redundant..
How to make an Android view that flips between views on swipe/fling http://stackoverflow.com/questions/5071743/how-to-make-an-android-view-that-flips-between-views-on-swipe-fling It should not fling across all of the views. If you swipe slowly you should see the views dragging as you're swiping eg. the way the Launcher does it. I tried using a ViewFlipper with a GestureOverlayView as per Romain Guy's blog post here..
How turn on camera flash light programmatically in Android? http://stackoverflow.com/questions/6068803/how-turn-on-camera-flash-light-programmatically-in-android Then make use of Camera and set Camera.Parameters . The main parameter used here is FLASH_MODE_TORCH . eg. Code Snippet to turn on camera flash light. Camera cam Camera.open Parameters p cam.getParameters p.setFlashMode Parameters.FLASH_MODE_TORCH.. only rooted HTC devices support this feature. Issues There are also some problems while turning On Off flashlight. eg. for the devices not having FLASH_MODE_TORCH or even if it has then flashlight doesnot turn ON etc. Typically Samsung creates..
How do I make an http request using cookies on Android? http://stackoverflow.com/questions/678630/how-do-i-make-an-http-request-using-cookies-on-android request using cookies on Android I'd like to make an http request to a remote server while properly handling cookies eg. storing cookies sent by the server and sending those cookies when I make subsequent requests . It'd be nice to preserve.. cookies.get i .toString HttpPost httpost new HttpPost https portal.sun.com amserver UI Login org self_registered_users goto portal dt gotoOnFail portal dt error true List NameValuePair nvps new ArrayList NameValuePair nvps.add..
Handler vs AsyncTask vs Thread http://stackoverflow.com/questions/6964011/handler-vs-asynctask-vs-thread always . And of course you can communicate between two thread by other ways but there are many disadvantages for eg Main thread isn't thread safe in most of time in other words DANGEROUS. That is why you should use Handler and AsyncTask..
Update data in ListFragment as part of ViewPager http://stackoverflow.com/questions/7379165/update-data-in-listfragment-as-part-of-viewpager on the entire FragmentPagerAdapter and this showed to update the data sometimes but others I got an IllegalStateException Can not perform this action after onSaveInstanceState. My second attempt involed trying to call an update.. is the R.id.viewpager in XML layout and INDEX is the position in the viewpager. So if the position is known eg 0 I can perform in updateFragments HomeListFragment fragment HomeListFragment getSupportFragmentManager .findFragmentByTag..
Detect a new Android notification http://stackoverflow.com/questions/9367196/detect-a-new-android-notification In the Android app that I'm working on I'd like to be able to detect when a new status bar notification appears regardless of if it was caused by my app. To be more specific I want to count the number of notifications in a given time frame... so how android notifications share improve this question Actually it is possible I use it in my app. You need to register an AccessibilityService and make sure the user enables the service. Example for a service public class InstantMessenger.. AccessibilityEvent event if event.getEventType AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED Do something eg getting packagename final String packagename String.valueOf event.getPackageName @Override protected void onServiceConnected..
How to change the title of the Tab Dynamically http://stackoverflow.com/questions/2291607/how-to-change-the-title-of-the-tab-dynamically change the title of an another existing Tab. This is the title that we provide while adding the tabs to the TabHost. Eg TabHost.addTab tabHost.newTabSpec Tab2 .setIndicator I need to be Changed dynamically .setContent.... In the above example..
How to determine if one of my activities is in the foreground http://stackoverflow.com/questions/2314969/how-to-determine-if-one-of-my-activities-is-in-the-foreground the broadcast will know that nobody intercepted its broadcast intent and will be able to deal with that itself. Eg it could than launch the desired activity show a notification etc. android broadcastreceiver share improve this question..
Open-sided Android stroke? http://stackoverflow.com/questions/2422120/open-sided-android-stroke sided Android stroke Is it possible to create an Android shape object with stroke on only certain sides Eg I have stroke android width 3dip android color #000000 android dashWidth 10dip android dashGap 6dip Which is similar to..
Android: Programmatically animate between images in Gallery widget http://stackoverflow.com/questions/2731564/android-programmatically-animate-between-images-in-gallery-widget of Gallery it appears that it can handle DPAD key presses so a work around I thought of was to fake the key presses. Eg. dispatchKeyEvent new KeyEvent KeyEvent.ACTION_DOWN KeyEvent.KEYCODE_DPAD_LEFT However I can't get this working for some..
How to change background color in android app http://stackoverflow.com/questions/2748830/how-to-change-background-color-in-android-app
How to deal with INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES without uninstallation http://stackoverflow.com/questions/3185444/how-to-deal-with-install-parse-failed-inconsistent-certificates-without-uninstal new.apk that works fine. But I'm wondering whether I could re build an apk and re install without the uninstallation. Eg. change some config in the AndroidManifest.xml or not sign the APK etc. It would be great appreciated if you could tell..
How to create a completely custom Dialogue/Popup in Android (change overlay colour and dialogue window layout) http://stackoverflow.com/questions/3728990/how-to-create-a-completely-custom-dialogue-popup-in-android-change-overlay-colo Back in your java code when creating the dialog object use the constructor that passes both the context AND the theme. Eg. myDialog new Dialog this R.style.CustomDialogTheme CustomDialogTheme is the name attribute I specified in the styles.xml.. from step 2 4 Simply set your dialog objects content view to whatever layout you want your dialog to look like. Eg. myDialog.setContentView R.layout.my_custom_overlay If you want your dialog to appear at the center of the screen set its..
Android: Disable rotations by 90°, but enable rotations by 180° http://stackoverflow.com/questions/4371631/android-disable-rotations-by-90-but-enable-rotations-by-180 share improve this question The new sensorLandscape screen orientation is apparently meant for this purpose. Eg you could do setRequestedOrientation ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE Unfortunately this is only available..
How to find Intent source in Android? [duplicate] http://stackoverflow.com/questions/4789155/how-to-find-intent-source-in-android activities A and B. Both fire an intent to call activity C. Activity C displays extra information based on its source. Eg. If call comes from A then C displays only 2 textviews whereas in the case of intent fired by B the activity C displays..
android set multiple alarms simultaneosuly http://stackoverflow.com/questions/5549974/android-set-multiple-alarms-simultaneosuly sender2 OLD Question I want to set two alarms at the same time for two different operations to be performed. For Eg. A user sets alarm at 2'O clock and sets the duration to 15 mins. The first alarm should fire at 2'O clock which performs..
How to check if a value already exists in the database in Android http://stackoverflow.com/questions/7820905/how-to-check-if-a-value-already-exists-in-the-database-in-android I parse a JSON response. How can I check if the values are already present in the database and prevent inserting again Eg. Name of Database Exicom.sqlite Name of table TimeReport Fields in Database userID clientName I am using SQLite in android...
Formula px to dp, dp to px android http://stackoverflow.com/questions/8309354/formula-px-to-dp-dp-to-px-android displayMetrics.density . However the docs explain that this value is a rounded value used with the screen 'buckets'. Eg. on my Nexus 10 it returns 2 where the real value would be 298dpi real 160dpi default 1.8625. Depending on your requirements..
How to manage multiple Async Tasks efficiently in Android http://stackoverflow.com/questions/9221343/how-to-manage-multiple-async-tasks-efficiently-in-android server to get the data for six different items. These server calls cant be combined and they are meant to be that way. Eg If you need quote info for GOOGLE then send a request to server requesting for google's quote info. Next if you need yahoo's..
|