¡@

Home 

2014/10/16 ¤W¤È 08:27:06

android Programming Glossary: use

Saving Activity state in Android

http://stackoverflow.com/questions/151777/saving-activity-state-in-android

sure it's probably something simple like overriding onPause or something like that but I've been poking away in the docs.. savedInstanceState.getString MyString You'd usually use this technique to store instance values for your application..

Sending Email in Android using JavaMail API without using the default/built-in app

http://stackoverflow.com/questions/2020088/sending-email-in-android-using-javamail-api-without-using-the-default-built-in-a

to create a mail sending application in Android. If I use Intent emailIntent new Intent android.content.Intent.ACTION_SEND.. method stub try GMailSender sender new GMailSender username@gmail.com password sender.sendMail This is Subject This.. password sender.sendMail This is Subject This is Body user@gmail.com user@yahoo.com catch Exception e Log.e SendMail..

Quitting an application - is that frowned upon?

http://stackoverflow.com/questions/2033914/quitting-an-application-is-that-frowned-upon

learn Android I just read the following Question Does the user have a choice to kill the application unless we put a menu.. option in to kill it If no such option exists how does the user terminate the application Answer Romain Guy The user doesn't.. the user terminate the application Answer Romain Guy The user doesn't the system handles this automatically. That's what..

What is the simplest and most robust way to get the user's current location in Android?

http://stackoverflow.com/questions/3145089/what-is-the-simplest-and-most-robust-way-to-get-the-users-current-location-in-a

is the simplest and most robust way to get the user's current location in Android The LocationManager API in android.. API in android seems like it's a bit of a pain to use for an application that only needs an occasional and rough approximation.. only needs an occasional and rough approximation of the user's location. The app I'm working on isn't really a location..

Strange out of memory issue while loading an image to a Bitmap object

http://stackoverflow.com/questions/477572/strange-out-of-memory-issue-while-loading-an-image-to-a-bitmap-object

a new activity. I have had to build my own tabs because of an issue with the camera layout. The activity that gets launched.. row as I am unable to select a row with touch screen because of focus issue. I can use roller ball. I know I can do an out.. a row with touch screen because of focus issue. I can use roller ball. I know I can do an out of band resize and save..

How do I do a lazy load of images in ListView

http://stackoverflow.com/questions/541966/how-do-i-do-a-lazy-load-of-images-in-listview

currently displaying. Please note that the Log object in use here is my custom wrapper around the final Log class inside.. the Apache License Version 2.0 the License you may not use this file except in compliance with the License. You may obtain..

Android: How to declare global variables?

http://stackoverflow.com/questions/708012/android-how-to-declare-global-variables

global in order to avoid login form appearing after the user already successfully authenticates Thanks android singleton.. disagreement I have with those who encourage the use of Singletons rather than subclassing Application. Read it at.. android icon ... android label ... application NOTE 2 user608578 asks below how this works with managing native object..

How to use an existing database with an Android application [duplicate]

http://stackoverflow.com/questions/9109438/how-to-use-an-existing-database-with-an-android-application

to use an existing database with an Android application duplicate .. I have already created an SQLite database. I want to use this database file with my Android project. I want to bundle.. how can the application gain access to this database and use it as its database java android eclipse sqlite share improve..

Quitting an application - is that frowned upon?

http://stackoverflow.com/questions/2033914/quitting-an-application-is-that-frowned-upon

fiction and should not be done by an activity in any case. Use a scheduled task via AlarmManager to update your data for maximum.. pressed the BACK button. It should only terminate when the Users wants to terminate it never ever any other way. If you cant.. via finish can close up your currently running activity. Users generally don't need anything else for properly written applications..

How to get the Android device's primary e-mail address

http://stackoverflow.com/questions/2112965/how-to-get-the-android-devices-primary-e-mail-address

personal information bad things can happen. Method A. Use AccountManager API level 5 You can use AccountManager.getAccounts.. at the Contact Manager sample code in the SDK. Method B. Use ContactsContract.Profile API level 14 As of Android 4.0 Ice..

What are the best practices for SQLite on Android?

http://stackoverflow.com/questions/2493331/what-are-the-best-practices-for-sqlite-on-android

in your LogCat and that will be it. So multiple threads Use one helper. Period. If you KNOW only one thread will be writing..

Focusable EditText inside ListView

http://stackoverflow.com/questions/2679948/focusable-edittext-inside-listview

long id if position 1 listView.setItemsCanFocus true Use afterDescendants because I don't want the ListView to steal.. if listView.isFocused listView.setItemsCanFocus false Use beforeDescendants so that the EditText doesn't re take focus..

Declaring a custom android UI element using XML

http://stackoverflow.com/questions/2695646/declaring-a-custom-android-ui-element-using-xml

.obtainStyledAttributes attrs R.styleable.MyCustomView Use a Log.i test a.getString R.styleable.MyCustomView_android_text.. to view all these constants in the one place is useful. 3. Use it in a layout files such as layout main.xml Include the namespace..

OutOfMemoryError: bitmap size exceeds VM budget :- Android [duplicate]

http://stackoverflow.com/questions/2928002/outofmemoryerror-bitmap-size-exceeds-vm-budget-android

bitmap outofmemoryerror share improve this question Use decodeStream is outPadding opts with BitmapFactory.Options opts..

Launch custom android application from android browser

http://stackoverflow.com/questions/2958701/launch-custom-android-application-from-android-browser

android browser android share improve this question Use an intent filter with a data element. For example to handle..

Download a file with Android, and showing the progress in a ProgressDialog

http://stackoverflow.com/questions/3028306/download-a-file-with-android-and-showing-the-progress-in-a-progressdialog

to you to decide which method is better for your app. 1. Use AsyncTask and show the download progress in a dialog This method.. progress if progress 100 mProgressDialog.dismiss 2.1 Use Groundy library Groundy is a library a friend and I wrote time.. like that in your app it could be really useful. 3. Use DownloadManager class GingerBread and newer only This method..

notifyDataSetChanged example

http://stackoverflow.com/questions/3669325/notifydatasetchanged-example

you changed the List in the Activity. Your choices are Use the functions of the ArrayAdapter to modify the underlying List.. etc. Re create the ArrayAdapter with the new List data. Uses a lot of resources and garbage collection. Create your own.. allows changing of the underlying List data structure. Use the notifyDataSetChanged every time the list is update. To call..

FFMPEG on Android

http://stackoverflow.com/questions/4725773/ffmpeg-on-android

libavcodec libavformat libavutil libc libz Use the ffmpeg wrapping dynamic library from your java sources...

When to call activity context OR application context?

http://stackoverflow.com/questions/7298731/when-to-call-activity-context-or-application-context

Context you have at your disposal. Scenarios include Use getApplicationContext if you need something tied to a Context.. to create it it is safest to use getApplicationContext . Use getApplicationContext when you bind to a Service from an Activity..

How to open PDF in Android

http://stackoverflow.com/questions/10480974/how-to-open-pdf-in-android

webview give internet permission in manifest file. USE the following method to open a PDF file with already installed..

How to get current foreground activity context in android?

http://stackoverflow.com/questions/11411395/how-to-get-current-foreground-activity-context-in-android

activity. android share improve this question DO NOT USE PREVIOUS waqas716 answer. You will have memory leak problem..

android using flood fill algorithm getting out of memory exception

http://stackoverflow.com/questions/12669740/android-using-flood-fill-algorithm-getting-out-of-memory-exception

void onPostExecute Void result pd.dismiss invalidate USE FLOODFILL NOW. public class FloodFill public void floodFill..

Force Screen On

http://stackoverflow.com/questions/2131948/force-screen-on

android share improve this question PLEASE DO NOT USE A WAKE LOCK This requires that you give your app an additional..

How to read excel file using JXL 2.6.12 jar

http://stackoverflow.com/questions/3387478/how-to-read-excel-file-using-jxl-2-6-12-jar

Android: parse XML from string problems

http://stackoverflow.com/questions/5752268/android-parse-xml-from-string-problems

how to set that up. What I do not understand is how to USE it. Xml.parse ... ... returns nothing because it is a void method...

Android, how to access Activity UI from my class?

http://stackoverflow.com/questions/6030982/android-how-to-access-activity-ui-from-my-class

... file Points.java private class Points ... HOW TO USE myView HERE ... How do I use the UI objects in my class..

Android - multi-line linear layout

http://stackoverflow.com/questions/6996837/android-multi-line-linear-layout

params.setMargins 5 0 5 0 YOU CAN USE THIS LL.addView TV params LL.addView views i params LL.measure..

How to use AsyncTask for Jsoup Parser?

http://stackoverflow.com/questions/7083680/how-to-use-asynctask-for-jsoup-parser

AsyncTask Void Void Void HERE DECLARE THE VARIABLES YOU USE FOR PARSING private Element overview null private Element featureList..

Can't upgrade Android SDK Tools

http://stackoverflow.com/questions/8559682/cant-upgrade-android-sdk-tools

tools directory and call this new directory tools2. DO NOT USE 'SDK Setup.exe'. Instead open up a cmd.exe window as administrator..

Android project using httpclient --> http.client (apache), post/get method

http://stackoverflow.com/questions/874227/android-project-using-httpclient-http-client-apache-post-get-method

convenience wrapper methods for get post etc. Anywhere you USE this class from an Activity you should create an internal inner..

Download and Extract Zip File in Android

http://stackoverflow.com/questions/9324103/download-and-extract-zip-file-in-android

INCREMENT THE COUNTER VARIABLE OVER HERE..LATER YOU CAN USE VALUE OF COUNTER VARIABLE TO CROSS VERIFY WHETHER ALL ZIPPED..

Saving Activity state in Android

http://stackoverflow.com/questions/151777/saving-activity-state-in-android

first message no matter how I navigate away from the app. I'm sure it's probably something simple like overriding onPause or something like that but I've been poking away in the docs for 30 minutes or so and haven't found anything obvious so..

Sending Email in Android using JavaMail API without using the default/built-in app

http://stackoverflow.com/questions/2020088/sending-email-in-android-using-javamail-api-without-using-the-default-built-in-a

JavaMail API without using the default built in app I am trying to create a mail sending application in Android. If I use Intent emailIntent new Intent android.content.Intent.ACTION_SEND this will launch the built in Android application I'm trying.. public void onClick View v TODO Auto generated method stub try GMailSender sender new GMailSender username@gmail.com password sender.sendMail This is Subject This is Body user@gmail.com user@yahoo.com catch Exception.. try GMailSender sender new GMailSender username@gmail.com password sender.sendMail This is Subject This is Body user@gmail.com user@yahoo.com catch Exception e Log.e SendMail e.getMessage e GmailSender.java YOUR PACKAGE import javax.activation.DataHandler..

Quitting an application - is that frowned upon?

http://stackoverflow.com/questions/2033914/quitting-an-application-is-that-frowned-upon

application is that frowned upon Moving on in my attempt to learn Android I just read the following Question Does the user have a choice to kill the application unless we put a menu option in to kill it If no such option exists how does the user.. have a choice to kill the application unless we put a menu option in to kill it If no such option exists how does the user terminate the application Answer Romain Guy The user doesn't the system handles this automatically. That's what the activity.. a menu option in to kill it If no such option exists how does the user terminate the application Answer Romain Guy The user doesn't the system handles this automatically. That's what the activity lifecycle especially onPause onStop onDestroy is..

What is the simplest and most robust way to get the user's current location in Android?

http://stackoverflow.com/questions/3145089/what-is-the-simplest-and-most-robust-way-to-get-the-users-current-location-in-a

is the simplest and most robust way to get the user's current location in Android The LocationManager API in android seems like it's a bit of a pain to use for an application.. to get the user's current location in Android The LocationManager API in android seems like it's a bit of a pain to use for an application that only needs an occasional and rough approximation of the user's location. The app I'm working on.. seems like it's a bit of a pain to use for an application that only needs an occasional and rough approximation of the user's location. The app I'm working on isn't really a location app per se but it does need to get the user's location in order..

Strange out of memory issue while loading an image to a Bitmap object

http://stackoverflow.com/questions/477572/strange-out-of-memory-issue-while-loading-an-image-to-a-bitmap-object

image buttons on each row. When you click the list row it launches a new activity. I have had to build my own tabs because of an issue with the camera layout. The activity that gets launched for result is a map. If I click on my button to launch.. changes to the properties of the widgets elements in each row as I am unable to select a row with touch screen because of focus issue. I can use roller ball. I know I can do an out of band resize and save of my image but that is not really.. of the widgets elements in each row as I am unable to select a row with touch screen because of focus issue. I can use roller ball. I know I can do an out of band resize and save of my image but that is not really what I want to do but some..

How do I do a lazy load of images in ListView

http://stackoverflow.com/questions/541966/how-do-i-do-a-lazy-load-of-images-in-listview

Here's what I created to hold the images that my app is currently displaying. Please note that the Log object in use here is my custom wrapper around the final Log class inside Android. package com.wilson.android.library Licensed to the.. copyright ownership. The ASF licenses this file to you under the Apache License Version 2.0 the License you may not use this file except in compliance with the License. You may obtain a copy of the License at http www.apache.org licenses LICENSE..

Android: How to declare global variables?

http://stackoverflow.com/questions/708012/android-how-to-declare-global-variables

strSessionString. Does anyone know how to set the variable global in order to avoid login form appearing after the user already successfully authenticates Thanks android singleton global variables state share improve this question I wrote.. post addressing some criticism and detailing a large philosophical disagreement I have with those who encourage the use of Singletons rather than subclassing Application. Read it at your own risk. ORIGINAL ANSWER The more general problem you.. info. An example application android name my.application.MyApp android icon ... android label ... application NOTE 2 user608578 asks below how this works with managing native object lifecycles. I admit I am not up to speed on using native code..

How to use an existing database with an Android application [duplicate]

http://stackoverflow.com/questions/9109438/how-to-use-an-existing-database-with-an-android-application

to use an existing database with an Android application duplicate This question already has an answer here How to ship an Android.. to ship an Android application with a database 8 answers I have already created an SQLite database. I want to use this database file with my Android project. I want to bundle this database with my application. Instead of creating a new.. with my application. Instead of creating a new database how can the application gain access to this database and use it as its database java android eclipse sqlite share improve this question EDIT You can find source code sample project..

Quitting an application - is that frowned upon?

http://stackoverflow.com/questions/2033914/quitting-an-application-is-that-frowned-upon

means but the data being PUSHed to the device is a pleasant fiction and should not be done by an activity in any case. Use a scheduled task via AlarmManager to update your data for maximum reliability. Our users log in and cant be doing that everytime.. . It finishes the activity that was on screen when the user pressed the BACK button. It should only terminate when the Users wants to terminate it never ever any other way. If you cant write apps that behave like that in Android then I think that.. As everybody else told you users via BACK or your code via finish can close up your currently running activity. Users generally don't need anything else for properly written applications any more than they need a quit option for using Web..

How to get the Android device's primary e-mail address

http://stackoverflow.com/questions/2112965/how-to-get-the-android-devices-primary-e-mail-address

and contact data. If you misuse a user's email address or other personal information bad things can happen. Method A. Use AccountManager API level 5 You can use AccountManager.getAccounts or AccountManager.getAccountsByType to get a list of all.. More on using AccountManager can be found at the Contact Manager sample code in the SDK. Method B. Use ContactsContract.Profile API level 14 As of Android 4.0 Ice Cream Sandwich you can get the user's email addresses by accessing..

What are the best practices for SQLite on Android?

http://stackoverflow.com/questions/2493331/what-are-the-best-practices-for-sqlite-on-android

you won ™t get an exception. You ™ll just get a message in your LogCat and that will be it. So multiple threads Use one helper. Period. If you KNOW only one thread will be writing you MAY be able to use multiple connections and your reads..

Focusable EditText inside ListView

http://stackoverflow.com/questions/2679948/focusable-edittext-inside-listview

void onItemSelected AdapterView listView View view int position long id if position 1 listView.setItemsCanFocus true Use afterDescendants because I don't want the ListView to steal focus listView.setDescendantFocusability ViewGroup.FOCUS_AFTER_DESCENDANTS.. myEditText.requestFocus else if listView.isFocused listView.setItemsCanFocus false Use beforeDescendants so that the EditText doesn't re take focus listView.setDescendantFocusability ViewGroup.FOCUS_BEFORE_DESCENDANTS..

Declaring a custom android UI element using XML

http://stackoverflow.com/questions/2695646/declaring-a-custom-android-ui-element-using-xml

private void init AttributeSet attrs TypedArray a getContext .obtainStyledAttributes attrs R.styleable.MyCustomView Use a Log.i test a.getString R.styleable.MyCustomView_android_text Log.i test a.getColor R.styleable.MyCustomView_android_textColor.. in the future. It is still in the documentation as being to view all these constants in the one place is useful. 3. Use it in a layout files such as layout main.xml Include the namespace declaration xmlns app http schemas.android.com apk res..

OutOfMemoryError: bitmap size exceeds VM budget :- Android [duplicate]

http://stackoverflow.com/questions/2928002/outofmemoryerror-bitmap-size-exceeds-vm-budget-android

bitmap size exceeds VM budget android bitmap outofmemoryerror share improve this question Use decodeStream is outPadding opts with BitmapFactory.Options opts new BitmapFactory.Options opts.inDither false Disable Dithering..

Launch custom android application from android browser

http://stackoverflow.com/questions/2958701/launch-custom-android-application-from-android-browser

me regarding how to launch my android application from the android browser android share improve this question Use an intent filter with a data element. For example to handle all links to twitter.com you'd put this inside your activity..

Download a file with Android, and showing the progress in a ProgressDialog

http://stackoverflow.com/questions/3028306/download-a-file-with-android-and-showing-the-progress-in-a-progressdialog

files. Following I will post most common ways it is up to you to decide which method is better for your app. 1. Use AsyncTask and show the download progress in a dialog This method will allow you to execute some background processes and.. resultData.getInt progress mProgressDialog.setProgress progress if progress 100 mProgressDialog.dismiss 2.1 Use Groundy library Groundy is a library a friend and I wrote time ago. It basically helps you run pieces of code in a background.. and post results to the UI with easily. If you are doing something like that in your app it could be really useful. 3. Use DownloadManager class GingerBread and newer only This method is awesome you do not have to worry about downloading the file..

notifyDataSetChanged example

http://stackoverflow.com/questions/3669325/notifydatasetchanged-example

a reference to the original List . The Adapter does not know you changed the List in the Activity. Your choices are Use the functions of the ArrayAdapter to modify the underlying List add insert remove clear etc. Re create the ArrayAdapter.. to modify the underlying List add insert remove clear etc. Re create the ArrayAdapter with the new List data. Uses a lot of resources and garbage collection. Create your own class derived from BaseAdapter and ListAdapter that allows changing.. your own class derived from BaseAdapter and ListAdapter that allows changing of the underlying List data structure. Use the notifyDataSetChanged every time the list is update. To call it on the UI Thread use the runOnUiThread method of the..

FFMPEG on Android

http://stackoverflow.com/questions/4725773/ffmpeg-on-android

step 1 just add a line similar to this to Android.mk LOCAL_STATIC_LIBRARIES libavcodec libavformat libavutil libc libz Use the ffmpeg wrapping dynamic library from your java sources. There's enough documentation on JNI out there you should be..

When to call activity context OR application context?

http://stackoverflow.com/questions/7298731/when-to-call-activity-context-or-application-context

Context for something that may live longer than any other likely Context you have at your disposal. Scenarios include Use getApplicationContext if you need something tied to a Context that itself will have global scope. I use getApplicationContext.. is static and I need a Context to get at PowerManager to create it it is safest to use getApplicationContext . Use getApplicationContext when you bind to a Service from an Activity if you wish to pass the ServiceConnection i.e. the handle..

How to open PDF in Android

http://stackoverflow.com/questions/10480974/how-to-open-pdf-in-android

gview embedded true url URL_of_PDF fileName.pdf setContentView webview give internet permission in manifest file. USE the following method to open a PDF file with already installed 3rd party application. To open the PDF in application use..

How to get current foreground activity context in android?

http://stackoverflow.com/questions/11411395/how-to-get-current-foreground-activity-context-in-android

my broadcast is executed I want to show alert to foreground activity. android share improve this question DO NOT USE PREVIOUS waqas716 answer. You will have memory leak problem because of the static reference to the activity. For more detail..

android using flood fill algorithm getting out of memory exception

http://stackoverflow.com/questions/12669740/android-using-flood-fill-algorithm-getting-out-of-memory-exception

pt targetColor replacementColor return null @Override protected void onPostExecute Void result pd.dismiss invalidate USE FLOODFILL NOW. public class FloodFill public void floodFill Bitmap image Point node int targetColor int replacementColor..

Force Screen On

http://stackoverflow.com/questions/2131948/force-screen-on

screen to stay active and not shut off while my app is running android share improve this question PLEASE DO NOT USE A WAKE LOCK This requires that you give your app an additional permission and it is very easy to introduce bugs where you..

How to read excel file using JXL 2.6.12 jar

http://stackoverflow.com/questions/3387478/how-to-read-excel-file-using-jxl-2-6-12-jar

Android: parse XML from string problems

http://stackoverflow.com/questions/5752268/android-parse-xml-from-string-problems

been to a lot of sites via Google and StackOverflow that detail how to set that up. What I do not understand is how to USE it. Xml.parse ... ... returns nothing because it is a void method. How do I access my parsed XML data I realize this question..

Android, how to access Activity UI from my class?

http://stackoverflow.com/questions/6030982/android-how-to-access-activity-ui-from-my-class

findViewById R.id.myView ... Points myPoints new Points ... file Points.java private class Points ... HOW TO USE myView HERE ... How do I use the UI objects in my class which does not extend an Activity Should I pass some context..

Android - multi-line linear layout

http://stackoverflow.com/questions/6996837/android-multi-line-linear-layout

new LinearLayout.LayoutParams views i .getMeasuredWidth LayoutParams.WRAP_CONTENT params.setMargins 5 0 5 0 YOU CAN USE THIS LL.addView TV params LL.addView views i params LL.measure 0 0 widthSoFar views i .getMeasuredWidth YOU MAY NEED TO..

How to use AsyncTask for Jsoup Parser?

http://stackoverflow.com/questions/7083680/how-to-use-asynctask-for-jsoup-parser

you need to do that in onPostExecute dit class fetcher extends AsyncTask Void Void Void HERE DECLARE THE VARIABLES YOU USE FOR PARSING private Element overview null private Element featureList null private Elements features null private Element..

Can't upgrade Android SDK Tools

http://stackoverflow.com/questions/8559682/cant-upgrade-android-sdk-tools

Extracted from here INSTRUCTIONS make a copy of the tools directory and call this new directory tools2. DO NOT USE 'SDK Setup.exe'. Instead open up a cmd.exe window as administrator and run the following from this new tools2 directory..

Android project using httpclient --> http.client (apache), post/get method

http://stackoverflow.com/questions/874227/android-project-using-httpclient-http-client-apache-post-get-method

help with this. The helper class creates the client and has convenience wrapper methods for get post etc. Anywhere you USE this class from an Activity you should create an internal inner AsyncTask so that you do not block the UI Thread while making..

Download and Extract Zip File in Android

http://stackoverflow.com/questions/9324103/download-and-extract-zip-file-in-android

IT IN startUnzipping before calling startUnZipping AND INCREMENT THE COUNTER VARIABLE OVER HERE..LATER YOU CAN USE VALUE OF COUNTER VARIABLE TO CROSS VERIFY WHETHER ALL ZIPPED FILES PROPERLY UNZIPPED AND SAVED OR NOT. Handle..