¡@

Home 

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

android Programming Glossary: activity

Saving Activity state in Android

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

public class HelloAndroid extends Activity Called when the activity is first created. @Override public void onCreate Bundle savedInstanceState..

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

class MailSenderActivity extends Activity Called when the activity is first created. @Override public void onCreate Bundle savedInstanceState.. that you cannot do network operation from the any UI activity in android. So follow this answer if you have any network issue..

Quitting an application - is that frowned upon?

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

the system handles this automatically. That's what the activity lifecycle especially onPause onStop onDestroy is for. No matter.. device is a pleasant fiction and should not be done by an activity in any case. Use a scheduled task via AlarmManager to update.. the BACK button does not kill the app . It finishes the activity that was on screen when the user pressed the BACK button. It..

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

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.. 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.. an image off the SD card the application returns from the activity back to the listview activity to the result handler to relaunch..

Android: How to declare global variables?

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

which requires login. I created the main and the login activity. In the main activity onCreate method I added the following.. I created the main and the login activity. In the main activity onCreate method I added the following condition public void..

Android - basic gesture detection

http://stackoverflow.com/questions/937313/android-basic-gesture-detection

onClickListener for each ImageView I add to be the main activity which implements View.OnClickListener . It seems infinitely.. a fling. I presume this is because it may span views If my activity implements OnGestureListener I don't know how to set that as.. View.OnClickListener OnGestureListener ... If my activity implements OnTouchListener then I have no onFling method to..

How to get screen dimensions

http://stackoverflow.com/questions/1016896/how-to-get-screen-dimensions

know how to get screenWidth and screenHeight in the main Activity android android layout layout screen android screen share.. int width size.x int height size.y If you're not in an Activity you can get the default Display via WINDOW_SERVICE WindowManager..

Saving Activity state in Android

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

Activity state in Android I've been playing around with the Android.. example package com.android.hello import android.app.Activity import android.os.Bundle import android.widget.TextView public.. android.widget.TextView public class HelloAndroid extends Activity Called when the activity is first created. @Override public..

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

authentication Steps to create a sample Project MailSenderActivity.java YOUR PACKAGE import android.app.Activity import android.os.Bundle.. MailSenderActivity.java YOUR PACKAGE import android.app.Activity import android.os.Bundle import android.util.Log import android.view.View.. import android.widget.Button public class MailSenderActivity extends Activity Called when the activity is first created...

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

the onCreate method mProgressDialog new ProgressDialog YourActivity.this mProgressDialog.setMessage A message mProgressDialog.setIndeterminate.. fired final DownloadTask downloadTask new DownloadTask YourActivity.this downloadTask.execute the url to the file you want to download.. where you are showing the dialog... public class MainActivity extends Activity private ProgressDialog mProgressDialog @Override..

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

the user's location so that by the time I need it in Activity X it will be available. Don't particularly care about accuracy..

Activity restart on rotation Android

http://stackoverflow.com/questions/456211/activity-restart-on-rotation-android

restart on rotation Android In my Android application when.. only called when the entire application is created so the Activity restarts on orientation or keyboard visibility changes won't.. keyboard visibility changes and handle them within your Activity. Start by adding the android configChanges node to your Activity's..

Android: How to declare global variables?

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

... loadSettings if strSessionString null login ... The onActivityResult method which is executed when the login form terminates.. form terminates looks like this @Override public void onActivityResult int requestCode int resultCode Intent data super.onActivityResult.. int requestCode int resultCode Intent data super.onActivityResult requestCode resultCode data switch requestCode case SHOW_SUBACTICITY_LOGIN..

R cannot be resolved - Android error

http://stackoverflow.com/questions/885009/r-cannot-be-resolved-android-error

this code package eu.mauriziopz.gps import android.app.Activity import android.os.Bundle public class ggps extends Activity.. import android.os.Bundle public class ggps extends Activity Called when the activity is first created. @Override public..

Android - basic gesture detection

http://stackoverflow.com/questions/937313/android-basic-gesture-detection

or the Image views that I add. public class SelectFilterActivity extends Activity implements View.OnClickListener OnGestureListener.. that I add. public class SelectFilterActivity extends Activity implements View.OnClickListener OnGestureListener ... If my.. if the fling was noteworthy . public class SelectFilterActivity extends Activity implements View.OnClickListener OnTouchListener..

AsyncTask Android example

http://stackoverflow.com/questions/9671546/asynctask-android-example

please help me out. package com.test import android.app.Activity import android.os.AsyncTask import android.os.Bundle import.. android.view.View.OnClickListener public class AsyncTaskActivity extends Activity Button btn Called when the activity is first.. public class AsyncTaskActivity extends Activity Button btn Called when the activity is first created. @Override..

How do I link a checkbox for every contact in populated listview?

http://stackoverflow.com/questions/10544821/how-do-i-link-a-checkbox-for-every-contact-in-populated-listview

I will try to help you... HERE IS MY ONCREATE FUNTION OF ACTIVITY. super.onCreate savedInstanceState setContentView R.layout.main..

Fix the Animation of a Circular ViewPager

http://stackoverflow.com/questions/11622544/fix-the-animation-of-a-circular-viewpager

negative points for a solution that in fact does work. ACTIVITY pager ViewPager findViewById R.id.viewpager String articles..

How to set icon to title bar for each Activity in TabLayout

http://stackoverflow.com/questions/4533830/how-to-set-icon-to-title-bar-for-each-activity-in-tablayout

void onResume super.onResume SET FEATURE FROM INSIDE ACTIVITY TabLayoutDemo.TabLayoutDemoInstance.getWindow . setFeatureInt..

android encryption

http://stackoverflow.com/questions/4816771/android-encryption

get this error on encrypt method 01 27 14 50 51.698 ERROR ACTIVITY 782 java.security.InvalidKeyException Key length not 128 192..

How to set Alarm in Android?

http://stackoverflow.com/questions/6520403/how-to-set-alarm-in-android

Notification note new Notification R.drawable.face NEW ACTIVITY System.currentTimeMillis Intent notificationIntent new Intent..

Return data from AsyncTask class

http://stackoverflow.com/questions/7618614/return-data-from-asynctask-class

result THIS IS WHERE I NEED TO RETURN MY DATA TO THE MAIN ACTIVITY. I am guessing public void getJSON String myUrlString String..

Finish the calling activity when AsyncTask completes

http://stackoverflow.com/questions/8623823/finish-the-calling-activity-when-asynctask-completes

extends Activity implements TaskCallback .....BUNCH OF ACTIVITY CODE..... public void onCreate Bundle savedInstanceState MyTask..

Android Stop Background Music

http://stackoverflow.com/questions/9148615/android-stop-background-music

YOU PRESSED BACK FROM YOUR 'HOME MAIN' ACTIVITY Toast.LENGTH_SHORT .show Context context getApplicationContext.. am ActivityManager context.getSystemService Context.ACTIVITY_SERVICE List RunningTaskInfo taskInfo am.getRunningTasks 1 if.. get 2 Toasts YOU PRESSED BACK FROM YOUR 'HOME MAIN' ACTIVITY and the 2nd Toast is YOU SWITCHED ACTIVITIES WITHIN YOUR APP..

Saving Activity state in Android

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

import android.os.Bundle import android.widget.TextView public class HelloAndroid extends Activity Called when the activity is first created. @Override public void onCreate Bundle savedInstanceState super.onCreate savedInstanceState mTextView new..

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

import android.view.View import android.widget.Button public class MailSenderActivity extends Activity Called when the activity is first created. @Override public void onCreate Bundle savedInstanceState super.onCreate savedInstanceState setContentView.. account for the mail. Cheers Hope this helps And don't forget that you cannot do network operation from the any UI activity in android. So follow this answer if you have any network issue Jar files https code.google.com p javamail android share..

Quitting an application - is that frowned upon?

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

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 for. No matter what you do do not put a quit or exit application button... should be there 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.. kill the app at all see link in my question above . Pressing the BACK button does not kill the app . 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..

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

object I have a list view with a couple of 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.. 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 the image preview load an image off the SD card.. If I click on my button to launch the image preview load an image off the SD card the application returns from the activity back to the listview activity to the result handler to relaunch my new activity which is nothing more than an image widget...

Android: How to declare global variables?

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

How to declare global variables I am creating an application which requires login. I created the main and the login activity. In the main activity onCreate method I added the following condition public void onCreate Bundle savedInstanceState super.onCreate.. variables I am creating an application which requires login. I created the main and the login activity. In the main activity onCreate method I added the following condition public void onCreate Bundle savedInstanceState super.onCreate savedInstanceState..

Android - basic gesture detection

http://stackoverflow.com/questions/937313/android-basic-gesture-detection

adapted. For the simple click situation I need only set the onClickListener for each ImageView I add to be the main activity which implements View.OnClickListener . It seems infinitely more complicated to implement something that recognizes a fling... more complicated to implement something that recognizes a fling. I presume this is because it may span views If my activity implements OnGestureListener I don't know how to set that as the gesture listener for the Grid or the Image views that I.. I add. public class SelectFilterActivity extends Activity implements View.OnClickListener OnGestureListener ... If my activity implements OnTouchListener then I have no onFling method to override it has two events as parameters allowing me to determine..

How to get screen dimensions

http://stackoverflow.com/questions/1016896/how-to-get-screen-dimensions

int px screenWidth m int py screenWidth n Does anyone know how to get screenWidth and screenHeight in the main Activity android android layout layout screen android screen share improve this question If you want the the display dimensions.. .getDefaultDisplay Point size new Point display.getSize size int width size.x int height size.y If you're not in an Activity you can get the default Display via WINDOW_SERVICE WindowManager wm WindowManager ctx.getSystemService Context.WINDOW_SERVICE..

Saving Activity state in Android

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

Activity state in Android I've been playing around with the Android SDK and I am a little unclear on saving an application's state... state. So given this minor re tooling of the 'Hello Android' example package com.android.hello import android.app.Activity import android.os.Bundle import android.widget.TextView public class HelloAndroid extends Activity Called when the activity.. import android.app.Activity import android.os.Bundle import android.widget.TextView public class HelloAndroid extends Activity Called when the activity is first created. @Override public void onCreate Bundle savedInstanceState super.onCreate savedInstanceState..

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

Send e mail in Android using the JavaMail API using Gmail authentication Steps to create a sample Project MailSenderActivity.java YOUR PACKAGE import android.app.Activity import android.os.Bundle import android.util.Log import android.view.View.. using Gmail authentication Steps to create a sample Project MailSenderActivity.java YOUR PACKAGE import android.app.Activity import android.os.Bundle import android.util.Log import android.view.View import android.widget.Button public class MailSenderActivity.. android.os.Bundle import android.util.Log import android.view.View import android.widget.Button public class MailSenderActivity extends Activity Called when the activity is first created. @Override public void onCreate Bundle savedInstanceState super.onCreate..

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

ProgressDialog mProgressDialog instantiate it within the onCreate method mProgressDialog new ProgressDialog YourActivity.this mProgressDialog.setMessage A message mProgressDialog.setIndeterminate true mProgressDialog.setProgressStyle ProgressDialog.STYLE_HORIZONTAL.. true execute this when the downloader must be fired final DownloadTask downloadTask new DownloadTask YourActivity.this downloadTask.execute the url to the file you want to download mProgressDialog.setOnCancelListener new DialogInterface.OnCancelListener.. above. This is how the whole code would look like... The activity where you are showing the dialog... public class MainActivity extends Activity private ProgressDialog mProgressDialog @Override public void onCreate Bundle savedInstanceState super.onCreate..

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

I'd like to do Show the user a list of nearby locations. Preload the user's location so that by the time I need it in Activity X it will be available. Don't particularly care about accuracy or frequency of update. Just grabbing one location is sufficient..

Activity restart on rotation Android

http://stackoverflow.com/questions/456211/activity-restart-on-rotation-android

restart on rotation Android In my Android application when I rotate the device slide out the keyboard then my activity.. code here. The onCreate in the application class is only called when the entire application is created so the Activity restarts on orientation or keyboard visibility changes won't trigger it. It's good practice to expose the instance of this.. for events that would cause a restart like orientation and keyboard visibility changes and handle them within your Activity. Start by adding the android configChanges node to your Activity's manifest node android configChanges keyboardHidden orientation..

Android: How to declare global variables?

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

savedInstanceState setContentView R.layout.main ... loadSettings if strSessionString null login ... The onActivityResult method which is executed when the login form terminates looks like this @Override public void onActivityResult int.. The onActivityResult method which is executed when the login form terminates looks like this @Override public void onActivityResult int requestCode int resultCode Intent data super.onActivityResult requestCode resultCode data switch requestCode case.. terminates looks like this @Override public void onActivityResult int requestCode int resultCode Intent data super.onActivityResult requestCode resultCode data switch requestCode case SHOW_SUBACTICITY_LOGIN if resultCode Activity.RESULT_OK strSessionString..

R cannot be resolved - Android error

http://stackoverflow.com/questions/885009/r-cannot-be-resolved-android-error

a simple application to test drive it. The wizard created this code package eu.mauriziopz.gps import android.app.Activity import android.os.Bundle public class ggps extends Activity Called when the activity is first created. @Override public.. this code package eu.mauriziopz.gps import android.app.Activity import android.os.Bundle public class ggps extends Activity Called when the activity is first created. @Override public void onCreate Bundle savedInstanceState super.onCreate savedInstanceState..

Android - basic gesture detection

http://stackoverflow.com/questions/937313/android-basic-gesture-detection

know how to set that as the gesture listener for the Grid or the Image views that I add. public class SelectFilterActivity extends Activity implements View.OnClickListener OnGestureListener ... If my activity implements OnTouchListener then I.. set that as the gesture listener for the Grid or the Image views that I add. public class SelectFilterActivity extends Activity implements View.OnClickListener OnGestureListener ... If my activity implements OnTouchListener then I have no onFling method.. it has two events as parameters allowing me to determine if the fling was noteworthy . public class SelectFilterActivity extends Activity implements View.OnClickListener OnTouchListener ... If I make a custom View like GestureImageView that..

AsyncTask Android example

http://stackoverflow.com/questions/9671546/asynctask-android-example

to work. I am new to android programming if possible can you please help me out. package com.test import android.app.Activity import android.os.AsyncTask import android.os.Bundle import android.provider.Settings.System import android.view.View import.. android.widget.Button import android.widget.TextView import android.view.View.OnClickListener public class AsyncTaskActivity extends Activity Button btn Called when the activity is first created. @Override public void onCreate Bundle savedInstanceState.. import android.widget.TextView import android.view.View.OnClickListener public class AsyncTaskActivity extends Activity Button btn Called when the activity is first created. @Override public void onCreate Bundle savedInstanceState super.onCreate..

How do I link a checkbox for every contact in populated listview?

http://stackoverflow.com/questions/10544821/how-do-i-link-a-checkbox-for-every-contact-in-populated-listview

try to understand code if any problem you are having then ask I will try to help you... HERE IS MY ONCREATE FUNTION OF ACTIVITY. super.onCreate savedInstanceState setContentView R.layout.main ArrayList String elements new ArrayList String for int i..

Fix the Animation of a Circular ViewPager

http://stackoverflow.com/questions/11622544/fix-the-animation-of-a-circular-viewpager

but you can change it as you need it. I hope i do not get more negative points for a solution that in fact does work. ACTIVITY pager ViewPager findViewById R.id.viewpager String articles ARTICLE 1 ARTICLE 2 ARTICLE 3 ARTICLE 4 pager.setAdapter new..

How to set icon to title bar for each Activity in TabLayout

http://stackoverflow.com/questions/4533830/how-to-set-icon-to-title-bar-for-each-activity-in-tablayout

extends Activity LOST MORE CODE ABOVE @Override protected void onResume super.onResume SET FEATURE FROM INSIDE ACTIVITY TabLayoutDemo.TabLayoutDemoInstance.getWindow . setFeatureInt Window.FEATURE_CUSTOM_TITLE R.layout.my_title Copy on resume..

android encryption

http://stackoverflow.com/questions/4816771/android-encryption

Base64.decode encryptedData return After running this I get this error on encrypt method 01 27 14 50 51.698 ERROR ACTIVITY 782 java.security.InvalidKeyException Key length not 128 192 256 bits. I have seen some other cases here on stackoverflow..

How to set Alarm in Android?

http://stackoverflow.com/questions/6520403/how-to-set-alarm-in-android

context. getSystemService Context.NOTIFICATION_SERVICE Notification note new Notification R.drawable.face NEW ACTIVITY System.currentTimeMillis Intent notificationIntent new Intent context Alset.class PendingIntent contentIntent PendingIntent.getActivity..

Return data from AsyncTask class

http://stackoverflow.com/questions/7618614/return-data-from-asynctask-class

return response protected void onPostExecute String result THIS IS WHERE I NEED TO RETURN MY DATA TO THE MAIN ACTIVITY. I am guessing public void getJSON String myUrlString String contentType DownloadWebPageTask task new DownloadWebPageTask..

Finish the calling activity when AsyncTask completes

http://stackoverflow.com/questions/8623823/finish-the-calling-activity-when-asynctask-completes

done Then you implement this into your Activity public Hello extends Activity implements TaskCallback .....BUNCH OF ACTIVITY CODE..... public void onCreate Bundle savedInstanceState MyTask mt new MyTask this mt.execute public void done finish And..

Android Stop Background Music

http://stackoverflow.com/questions/9148615/android-stop-background-music

was pressed from this activity player.stop Toast.makeText xYourClassNamex.this YOU PRESSED BACK FROM YOUR 'HOME MAIN' ACTIVITY Toast.LENGTH_SHORT .show Context context getApplicationContext ActivityManager am ActivityManager context.getSystemService.. .show Context context getApplicationContext ActivityManager am ActivityManager context.getSystemService Context.ACTIVITY_SERVICE List RunningTaskInfo taskInfo am.getRunningTasks 1 if taskInfo.isEmpty ComponentName topActivity taskInfo.get 0.. when you press BACK from your 'Home Main' activity you obviously get 2 Toasts YOU PRESSED BACK FROM YOUR 'HOME MAIN' ACTIVITY and the 2nd Toast is YOU SWITCHED ACTIVITIES WITHIN YOUR APP . I believe I know why this happens but it doesn t matter because..