0% found this document useful (0 votes)
14 views1 page

Android

An activity represents a single focused task the user can perform. Activities must extend the Activity class and implement onCreate() and onPause() methods. OnCreate() initializes the activity by setting the content view and finding widgets. OnPause() commits any user changes before leaving the activity. Bundles can pass data like strings between activities by adding extras to an intent.

Uploaded by

Res Saver
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views1 page

Android

An activity represents a single focused task the user can perform. Activities must extend the Activity class and implement onCreate() and onPause() methods. OnCreate() initializes the activity by setting the content view and finding widgets. OnPause() commits any user changes before leaving the activity. Bundles can pass data like strings between activities by adding extras to an intent.

Uploaded by

Res Saver
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

accepted

An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI with setContentView(View).

There are two methods almost all subclasses of Activity will implement: onCreate(Bundle) is where you initialize your activity. Most importantly, here you will usually call setContentView(int) with a layout resource defining your UI, and using findViewById(int) to retrieve the widgets in that UI that you need to interact with programmatically. onPause() is where you deal with the user leaving your activity. Most importantly, any changes made by the user should at this point be committed (usually to the ContentProvider holding the data).

Bundle generally use for passing data between various Activities. It depends on you what type of values you want to pass but bundle can hold all types of values and pass to the new activity. You can use it like ... Intent intent = new Intent(getApplicationContext(),SecondActivity.class); intent.putExtra("myKey",AnyValue); startActivity(intent); Now you can get the passed values by... Bundle extras = intent.getExtras(); String tmp = extras.getString("myKey");

You might also like