<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>android system - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/android-system/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/android-system/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Wed, 15 Sep 2021 06:19:36 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.wikitechy.com/interview-questions/wp-content/uploads/2025/10/cropped-wikitechy-icon-32x32.png</url>
	<title>android system - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/android-system/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Android Fragments</title>
		<link>https://www.wikitechy.com/interview-questions/android/android-fragments/</link>
					<comments>https://www.wikitechy.com/interview-questions/android/android-fragments/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Sun, 11 Jul 2021 05:28:24 +0000</pubDate>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[activity lifecycle in android]]></category>
		<category><![CDATA[add fragment to activity]]></category>
		<category><![CDATA[Agreeya Solutions interview questions and answers]]></category>
		<category><![CDATA[Allstate Solutions Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[android api]]></category>
		<category><![CDATA[android app development]]></category>
		<category><![CDATA[android app store]]></category>
		<category><![CDATA[android apps]]></category>
		<category><![CDATA[android apps download]]></category>
		<category><![CDATA[android developer]]></category>
		<category><![CDATA[android development]]></category>
		<category><![CDATA[android development tutorial]]></category>
		<category><![CDATA[android device]]></category>
		<category><![CDATA[android download]]></category>
		<category><![CDATA[android emulator]]></category>
		<category><![CDATA[android fragment]]></category>
		<category><![CDATA[android fragment example]]></category>
		<category><![CDATA[android fragment example source code]]></category>
		<category><![CDATA[android fragment lifecycle]]></category>
		<category><![CDATA[android fragment tutorial]]></category>
		<category><![CDATA[android lifecycle]]></category>
		<category><![CDATA[android multiple fragments in one activity example]]></category>
		<category><![CDATA[android phones]]></category>
		<category><![CDATA[android programming]]></category>
		<category><![CDATA[android sdk]]></category>
		<category><![CDATA[android service]]></category>
		<category><![CDATA[android software]]></category>
		<category><![CDATA[android studio fragment]]></category>
		<category><![CDATA[android studio tutorial]]></category>
		<category><![CDATA[android system]]></category>
		<category><![CDATA[android tutorial]]></category>
		<category><![CDATA[android update]]></category>
		<category><![CDATA[android versions]]></category>
		<category><![CDATA[android video]]></category>
		<category><![CDATA[apps for android]]></category>
		<category><![CDATA[best android phone]]></category>
		<category><![CDATA[Bharti Airtel interview questions and answers]]></category>
		<category><![CDATA[Bosch India Software interview questions and answers]]></category>
		<category><![CDATA[Capgemini interview questions and answers]]></category>
		<category><![CDATA[CASTING NETWORKS INDIA PVT LIMITED interview questions and answers]]></category>
		<category><![CDATA[CGI Group Inc interview questions and answers]]></category>
		<category><![CDATA[Chetu interview questions and answers]]></category>
		<category><![CDATA[Collabera Technologies interview questions and answers]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[developer android]]></category>
		<category><![CDATA[eclipse android]]></category>
		<category><![CDATA[Electronics Arts Inc interview questions and answers]]></category>
		<category><![CDATA[examples of fragments]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[fragment android]]></category>
		<category><![CDATA[fragment android example]]></category>
		<category><![CDATA[fragment example in android studio]]></category>
		<category><![CDATA[fragment examples]]></category>
		<category><![CDATA[fragment lifecycle]]></category>
		<category><![CDATA[fragmentmanager]]></category>
		<category><![CDATA[fragments in android]]></category>
		<category><![CDATA[fragments in android example androidhive]]></category>
		<category><![CDATA[G-Cube Webwide Software Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[google android]]></category>
		<category><![CDATA[how to call fragment from activity in android example]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[Infosys Technologies interview questions and answers]]></category>
		<category><![CDATA[Lava International Ltd interview questions and answers]]></category>
		<category><![CDATA[Maintec Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Mphasis interview questions and answers]]></category>
		<category><![CDATA[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[PeopleStrong interview questions and answers]]></category>
		<category><![CDATA[Photon Interactive Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Prokarma Softech Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[SAP Labs India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Symphony Teleca interview questions and answers]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[what is a fragment]]></category>
		<category><![CDATA[what is android]]></category>
		<category><![CDATA[what is fragment]]></category>
		<category><![CDATA[Wipro interview questions and answers]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=106</guid>

					<description><![CDATA[Answer : A Fragment is a piece of an activity which enable more modular...]]></description>
										<content:encoded><![CDATA[<div class="ImageContent">
<div class="hddn" style="text-align: justify;"><img decoding="async" class="img-responsive center-block" src="https://cdn.wikitechy.com/tutorials/android/fragment-android.png" alt=" Android Fragments " /></div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="what-is-fragments" class="color-pink">What is Fragments?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>A Fragment is a piece of an activity which enable more modular activity design. It will not be wrong if we say, a fragment is a kind of sub-activity. A fragment has its own <a href="https://www.wikitechy.com/tutorials/android/layouts-in-android" target="_blank" rel="noopener">layout</a> and its own behavior with its own life cycle <a href="https://www.wikitechy.com/tutorials/android/android-call" target="_blank" rel="noopener">callbacks.</a></li>
</ul>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>You can add or remove fragments in an <a href="https://www.wikitechy.com/tutorials/android/android-start-activity" target="_blank" rel="noopener">activity</a> while the activity is running.</li>
<li>You can combine multiple fragments in a single activity to build a multi-plane UI.</li>
<li>Android Fragment is the part of activity, it is also known as sub-activity. There can be more than one fragment in an activity. Fragments represent multiple screen inside one activity.</li>
<li>Android fragment lifecycle is affected by activity lifecycle because fragments are included in activity.</li>
<li>Each fragment has its own life cycle methods that is affected by <a href="https://www.wikitechy.com/tutorials/android/android-activity-lifecycle" target="_blank" rel="noopener">activity life cycle</a> because fragments are embedded in activity.</li>
<li>The Fragment Manager class is responsible to make interaction between fragment objects.</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="android-fragment-lifecycle" class="color-purple">Android Fragment Lifecycle</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>The lifecycle of android fragment is like the activity lifecycle. There are 12 lifecycle methods for fragment.</li>
</ul>
</div>
</div>
<table class="table-bordered table-striped table table-responsive">
<tbody>
<tr>
<th class="text-center">No.</th>
<th class="text-center">Method</th>
<th class="text-center">Description</th>
</tr>
<tr>
<td class="text-leftalign">1.</td>
<td class="text-leftalign">onAttach(Activity)</td>
<td class="text-leftalign">it is called only once when it is attached with activity.</td>
</tr>
<tr>
<td class="text-leftalign">2.</td>
<td class="text-leftalign">onCreate(Bundle)</td>
<td class="text-leftalign">It is used to initialize the fragment.</td>
</tr>
<tr>
<td class="text-leftalign">3.</td>
<td class="text-leftalign">onCreateView(LayoutInflater, ViewGroup, Bundle)</td>
<td class="text-leftalign">creates and returns view hierarchy.</td>
</tr>
<tr>
<td class="text-leftalign">4.</td>
<td class="text-leftalign">onActivityCreated(Bundle)</td>
<td class="text-leftalign">It is invoked after the completion of onCreate() method.</td>
</tr>
<tr>
<td class="text-leftalign">5.</td>
<td class="text-leftalign">onViewStateRestored(Bundle)</td>
<td class="text-leftalign">It provides information to the fragment that all the saved state of fragment view hierarchy has been restored.</td>
</tr>
<tr>
<td class="text-leftalign">6.</td>
<td class="text-leftalign">onStart()</td>
<td class="text-leftalign">makes the fragment visible.</td>
</tr>
<tr>
<td class="text-leftalign">7.</td>
<td class="text-leftalign">onResume()</td>
<td class="text-leftalign">makes the fragment interactive.</td>
</tr>
<tr>
<td class="text-leftalign">8.</td>
<td class="text-leftalign">onPause()</td>
<td class="text-leftalign">is called when fragment is no longer interactive.</td>
</tr>
<tr>
<td class="text-leftalign">9.</td>
<td class="text-leftalign">onStop()</td>
<td class="text-leftalign">is called when fragment is no longer visible.</td>
</tr>
<tr>
<td class="text-leftalign">10.</td>
<td class="text-leftalign">onDestroyView()</td>
<td class="text-leftalign">allows the fragment to clean up resources.</td>
</tr>
<tr>
<td class="text-leftalign">11.</td>
<td class="text-leftalign">onDestroy()</td>
<td class="text-leftalign">allows the fragment to do final clean up of fragment state.</td>
</tr>
<tr>
<td class="text-leftalign">12.</td>
<td class="text-leftalign">onDetach()</td>
<td class="text-leftalign">It is called immediately prior to the fragment no longer being associated with its activity.</td>
</tr>
</tbody>
</table>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block" src="https://cdn.wikitechy.com/tutorials/android/android-fragment-life-cycle.png" alt="android fragment life cycle" /></div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="using-a-fragment" class="color-purple">Using a fragment</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>The general steps to use a Fragment:</li>
</ul>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li style="list-style-type: none;">
<ul>
<li>Create a subclass of Fragment.</li>
<li>Create a layout for the Fragment.</li>
<li>Add the Fragment to a host Activity, either statically or dynamically.</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="creating-a-fragment" class="color-purple">Creating a fragment</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>To create a Fragment in an app, extend the Fragment class, then override key lifecycle methods to insert your app logic, similar to the way of Activity class.</li>
<li>Instead of extending the base Fragment class, you can extend one of these other, more specific Fragment subclasses:
<ul>
<li><b>DialogFragment :</b> Displays a floating dialog, such as a date picker or time picker.</li>
<li><b>ListFragment :</b> Displays a list of items that are managed by an adapter (such as a SimpleCursorAdapter).</li>
<li><b>PreferenceFragment :</b> Displays a hierarchy of Preference objects as a list, similar to PreferenceActivity. This is useful when creating a &#8220;settings&#8221; Activity for your app.</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<h2 id="how-to-create-a-fragment-in-android-studio">How to create a Fragment in Android Studio</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>In Project: Android view, expand app &gt; java and select the folder containing the Java code for your app.</li>
<li>Choose File &gt; New &gt; Fragment &gt; Fragment (Blank).</li>
<li>Name the Fragment something like SimpleFragment, or use the supplied name (BlankFragment).</li>
<li>If your Fragment has a UI, check the Create layout XML option if it is not already checked. Other options include:</li>
</ul>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li style="list-style-type: none;">
<ul>
<li><b>Include fragment factory methods :</b> Include sample factory method code to initialize the Fragment arguments in a way that encapsulates and abstracts them. Select this option if the number of arguments would make a constructor too complex.</li>
<li><b>Include interface callbacks :</b> Select this option if you want to include sample code that defines an interface in the Fragment with callback methods that enable the Fragment to communicate with its host Activity.</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Click Finish to create a Fragment.</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="android-fragment-classes" class="color-purple">Android Fragment Classes</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Fragments were added to the Android API in Honeycomb(API 11).
<ul>
<li>android.app.Fragment : The base class for all fragment definitions</li>
<li>android.app.FragmentManager : The class for interacting with fragment objects inside an activity</li>
<li>android.app.FragmentTransaction : The class for performing an atomic set of fragment operations</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>When using a compatibility package library provided by Google, the following classes are used for implementation.
<ul>
<li>android.support.v4.app.FragmentActivity : The base class for all activities using compatibility-based fragment (and loader) features</li>
<li>android.support.v4.app.Fragment</li>
<li>android.support.v4.app.FragmentManager</li>
<li>android.support.v4.app.FragmentTransaction</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="android-fragment-example" class="color-blue">Android Fragment Example</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Let&#8217;s have a look at the simple example of android fragment.</li>
</ul>
</div>
</div>
<div class="subheading" style="text-align: justify;">
<h2 id="activity_main-xml">activity_main.xml</h2>
</div>
<div class="CodeContent" style="text-align: justify;">
<div class="hddn">
<figure class="highlight"><div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-javascript code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-javascript code-embed-code">&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;  <br/>    android:layout_width=&quot;fill_parent&quot;  <br/>    android:layout_height=&quot;fill_parent&quot; &gt;  <br/>  <br/>    &lt;fragment  <br/>        android:id=&quot;@+id/fragment2&quot;  <br/>        android:name=&quot;com.example.fragmentexample.Fragment2&quot;  <br/>        android:layout_width=&quot;0px&quot;  <br/>        android:layout_height=&quot;match_parent&quot;   <br/>        android:layout_weight=&quot;1&quot;  <br/>        /&gt;  <br/>  <br/>    &lt;fragment  <br/>        android:id=&quot;@+id/fragment1&quot;  <br/>        android:name=&quot;com.example.fragmentexample.Fragment1&quot;  <br/>        android:layout_width=&quot;0px&quot;  <br/>        android:layout_height=&quot;match_parent&quot;  <br/>        android:layout_weight=&quot;1&quot;  <br/>         /&gt;  <br/>  <br/>&lt;/LinearLayout&gt;  </code></pre> </div></figure>
</div>
</div>
<div class="subheading" style="text-align: justify;">
<h2 id="file-fragment1-xml">File: fragment1.xml</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-javascript code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-javascript code-embed-code">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;  <br/>&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;  <br/>    android:layout_width=&quot;match_parent&quot;  <br/>    android:layout_height=&quot;match_parent&quot;  <br/>    android:orientation=&quot;vertical&quot;  <br/>    android:background=&quot;#00ff00&quot;  <br/>     &gt;  <br/>  <br/>    &lt;TextView  <br/>        android:id=&quot;@+id/textView1&quot;  <br/>        android:layout_width=&quot;wrap_content&quot;  <br/>        android:layout_height=&quot;wrap_content&quot;  <br/>        android:text=&quot;fragment frist&quot;  <br/>        android:textAppearance=&quot;?android:attr/textAppearanceLarge&quot; /&gt;  <br/>  <br/>&lt;/LinearLayout&gt;</code></pre> </div>
</div>
<div class="subheading" style="text-align: justify;">
<h2 id="file-fragment2-xml">File: fragment2.xml</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-javascript code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-javascript code-embed-code">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;  <br/>&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;  <br/>    android:layout_width=&quot;match_parent&quot;  <br/>    android:layout_height=&quot;match_parent&quot;  <br/>    android:orientation=&quot;vertical&quot;  <br/>    android:background=&quot;#0000ff&quot;  <br/>     &gt;  <br/>  <br/>    &lt;TextView  <br/>        android:id=&quot;@+id/textView1&quot;  <br/>        android:layout_width=&quot;wrap_content&quot;  <br/>        android:layout_height=&quot;wrap_content&quot;  <br/>        android:text=&quot;Second Fragment&quot;  <br/>        android:textAppearance=&quot;?android:attr/textAppearanceLarge&quot; /&gt;  <br/>  <br/>&lt;/LinearLayout&gt;</code></pre> </div>
</div>
<div class="subheading" style="text-align: justify;">
<h2 id="mainactivity-class">MainActivity class</h2>
</div>
<div class="subheading" style="text-align: justify;">
<h2 id="file-mainactivity-java">File: MainActivity.java</h2>
</div>
<div class="CodeContent" style="text-align: justify;">
<div class="hddn">
<figure class="highlight"><div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-javascript code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-javascript code-embed-code">package com.example.fragmentexample;  <br/>  <br/>import android.os.Bundle;  <br/>import android.app.Activity;  <br/>import android.view.Menu;  <br/>public class MainActivity extends Activity {  <br/>  <br/>    @Override  <br/>    protected void onCreate(Bundle savedInstanceState) {  <br/>        super.onCreate(savedInstanceState);  <br/>        setContentView(R.layout.activity_main);  <br/>    }  <br/>}</code></pre> </div></figure>
</div>
</div>
<div class="subheading" style="text-align: justify;">
<h2 id="file-fragment1-java">File: Fragment1.java</h2>
</div>
<div class="CodeContent" style="text-align: justify;">
<div class="hddn">
<figure class="highlight"><div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-javascript code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-javascript code-embed-code">ackage com.example.fragmentexample;  <br/>  <br/>import android.app.Fragment;  <br/>import android.os.Bundle;  <br/>import android.view.LayoutInflater;  <br/>import android.view.View;  <br/>import android.view.ViewGroup;  <br/>  <br/>public class Fragment1 extends Fragment {  <br/>    @Override  <br/>    public View onCreateView(LayoutInflater inflater, ViewGroup container,  <br/>            Bundle savedInstanceState) {  <br/>        // TODO Auto-generated method stub  <br/>        return inflater.inflate(R.layout.fragment1,container, false);  <br/>    }  <br/>  <br/>} </code></pre> </div></figure>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/tutorials/android/android-activity-cycle.png" alt="android activity and fragment life cycle" /></div>
</div>
<div class="subheading">
<h2 id="file-fragment2-java" style="text-align: justify;">File: Fragment2.java</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-javascript code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-javascript code-embed-code">package com.example.fragmentexample;  <br/>  <br/>import android.app.Fragment;  <br/>import android.os.Bundle;  <br/>import android.view.LayoutInflater;  <br/>import android.view.View;  <br/>import android.view.ViewGroup;  <br/>  <br/>public class Fragment2 extends Fragment {  <br/>      <br/>    public View onCreateView(LayoutInflater inflater, ViewGroup container,  <br/>            Bundle savedInstanceState) {  <br/>        // TODO Auto-generated method stub  <br/>        return inflater.inflate(R.layout.fragment2,container, false);  <br/>    }  <br/>  <br/>} </code></pre> </div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="output" class="color-green">Output</h2>
</div>
</div>
<div class="ImageContent">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/tutorials/android/android-fragment.png" alt=" Android Fragments " /></div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/android/android-fragments/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Android Activity Lifecycle &#124; android lifecycle</title>
		<link>https://www.wikitechy.com/interview-questions/android/android-activity-lifecycle/</link>
					<comments>https://www.wikitechy.com/interview-questions/android/android-activity-lifecycle/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Sun, 11 Jul 2021 04:58:44 +0000</pubDate>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[activities examples]]></category>
		<category><![CDATA[activity android]]></category>
		<category><![CDATA[activity life cycle in android]]></category>
		<category><![CDATA[activity lifecycle]]></category>
		<category><![CDATA[activity lifecycle android]]></category>
		<category><![CDATA[activity lifecycle in android]]></category>
		<category><![CDATA[Agreeya Solutions interview questions and answers]]></category>
		<category><![CDATA[Allstate Solutions Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[android account manager]]></category>
		<category><![CDATA[android activity]]></category>
		<category><![CDATA[android activity example]]></category>
		<category><![CDATA[android activity lifecycle]]></category>
		<category><![CDATA[android activity lifecycle diagra]]></category>
		<category><![CDATA[android activity lifecycle onsaveinstancestate]]></category>
		<category><![CDATA[android adb driver]]></category>
		<category><![CDATA[android adb interface driver]]></category>
		<category><![CDATA[android add widget]]></category>
		<category><![CDATA[android advanced tutorial]]></category>
		<category><![CDATA[android alertdialog example]]></category>
		<category><![CDATA[android api]]></category>
		<category><![CDATA[android app development]]></category>
		<category><![CDATA[android app store]]></category>
		<category><![CDATA[android application lifecycle]]></category>
		<category><![CDATA[android apps]]></category>
		<category><![CDATA[android apps download]]></category>
		<category><![CDATA[android authority]]></category>
		<category><![CDATA[android button style]]></category>
		<category><![CDATA[android developer]]></category>
		<category><![CDATA[android development]]></category>
		<category><![CDATA[android development tutorial]]></category>
		<category><![CDATA[android device]]></category>
		<category><![CDATA[android download]]></category>
		<category><![CDATA[android emulator]]></category>
		<category><![CDATA[android intent example]]></category>
		<category><![CDATA[android lifecycle]]></category>
		<category><![CDATA[android ndk]]></category>
		<category><![CDATA[android programming]]></category>
		<category><![CDATA[android sdk]]></category>
		<category><![CDATA[android sdk download]]></category>
		<category><![CDATA[android service]]></category>
		<category><![CDATA[android service lifecycle]]></category>
		<category><![CDATA[android software]]></category>
		<category><![CDATA[android studio tutorial]]></category>
		<category><![CDATA[android system]]></category>
		<category><![CDATA[android tutorial]]></category>
		<category><![CDATA[android update android]]></category>
		<category><![CDATA[android versions]]></category>
		<category><![CDATA[android video]]></category>
		<category><![CDATA[apps for android]]></category>
		<category><![CDATA[Bharti Airtel interview questions and answers]]></category>
		<category><![CDATA[Bosch India Software interview questions and answers]]></category>
		<category><![CDATA[Capgemini interview questions and answers]]></category>
		<category><![CDATA[CASTING NETWORKS INDIA PVT LIMITED interview questions and answers]]></category>
		<category><![CDATA[CGI Group Inc interview questions and answers]]></category>
		<category><![CDATA[Chetu interview questions and answers]]></category>
		<category><![CDATA[Collabera Technologies interview questions and answers]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[developer android]]></category>
		<category><![CDATA[eclipse android]]></category>
		<category><![CDATA[Electronics Arts Inc interview questions and answers]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[fragment lifecycle]]></category>
		<category><![CDATA[fragment lifecycle in android]]></category>
		<category><![CDATA[G-Cube Webwide Software Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[google android]]></category>
		<category><![CDATA[google io]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[Infosys Technologies interview questions and answers]]></category>
		<category><![CDATA[intent in android]]></category>
		<category><![CDATA[kodi app]]></category>
		<category><![CDATA[Lava International Ltd interview questions and answers]]></category>
		<category><![CDATA[life cycle of activity in android]]></category>
		<category><![CDATA[Maintec Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Mphasis interview questions and answers]]></category>
		<category><![CDATA[mservice lifecycle in android]]></category>
		<category><![CDATA[oncreate in android]]></category>
		<category><![CDATA[onresume android]]></category>
		<category><![CDATA[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[PeopleStrong interview questions and answers]]></category>
		<category><![CDATA[Photon Interactive Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[poweramp]]></category>
		<category><![CDATA[Prokarma Softech Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[SAP Labs India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[service lifecycle android]]></category>
		<category><![CDATA[Symphony Teleca interview questions and answers]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[what is activity in android]]></category>
		<category><![CDATA[what is android]]></category>
		<category><![CDATA[what is manifest.xml in android?android phones best android phone]]></category>
		<category><![CDATA[Wipro interview questions and answers]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=104</guid>

					<description><![CDATA[Answer : An activity represents a single screen with a user interface...]]></description>
										<content:encoded><![CDATA[<div class="ImageContent">
<div class="hddn" style="text-align: justify;"><img decoding="async" class="img-responsive center-block" src="https://cdn.wikitechy.com/tutorials/android/android-activity-lifecycle.gif" alt="Android activity lifecycle" /></div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="what-is-android-activity" class="color-red">What is Android Activity</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li style="list-style-type: none;">
<ul>
<li>An activity represents a single screen with a user interface just like window or frame of Java .Android activity is the subclass of <a href="https://www.wikitechy.com/tutorials/android/android-context-menu" target="_blank" rel="noopener">Context</a> Theme Wrapper class.
<ul>
<li>Activities are a fundamental building block of Android applications and they can exist in a number of different states.</li>
</ul>
</li>
</ul>
</li>
</ul>
<div class="ImageContent">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/tutorials/android/life-cycle-of-activity-in-android.png" alt=" life cycle of activity in android" /></div>
</div>
<ul>
<li style="list-style-type: none;">
<ul>
<li>The activity lifecycle begins with instantiation and ends with destruction, and includes many states in between.</li>
<li>When an activity changes state, the appropriate lifecycle event method is called, notifying the activity of the impending state change and allowing it to execute code in order to adapt to that change.</li>
<li>Android Activity Lifecycle is controlled by 7 methods of android.app.Activity class.</li>
<li>An activity is the single screen in android. It is like window or frame of Java.</li>
<li>By the help of activity, you can place all your UI components or widgets in a single screen.</li>
<li>The 7 lifecycle method of Activity describes how activity will behave at different states.</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="android-activity-lifecycle-methods" class="color-green">Android Activity Lifecycle methods</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Let&#8217;s see the 7 lifecycle methods of android activity.</li>
</ul>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<table class="table-bordered table-striped table table-responsive" style="height: 426px;" width="508">
<tbody>
<tr>
<th class="text-center">Method</th>
<th class="text-center">Description</th>
</tr>
<tr>
<td class="text-leftalign">onCreate</td>
<td class="text-leftalign">called when activity is first created.</td>
</tr>
<tr>
<td class="text-leftalign">onStart</td>
<td class="text-leftalign">called when activity is becoming visible to the user.</td>
</tr>
<tr>
<td class="text-leftalign">onResume</td>
<td class="text-leftalign">called when activity will start interacting with the user.</td>
</tr>
<tr>
<td class="text-leftalign">onPause</td>
<td class="text-leftalign">called when activity is not visible to the user.</td>
</tr>
<tr>
<td class="text-leftalign">onStop</td>
<td class="text-leftalign">called when activity is no longer visible to the user.</td>
</tr>
<tr>
<td class="text-leftalign">onRestart</td>
<td class="text-leftalign">called after your activity is stopped, prior to start.</td>
</tr>
<tr>
<td class="text-leftalign">onDestroy</td>
<td class="text-leftalign">called before the activity is destroyed.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/tutorials/android/oncreate-in-android.png" alt=" oncreate in android" /></div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>It provides the details about the invocation of life cycle methods of activity. In this example, we are displaying the content on the logcat.
<ul>
<li>File: MainActivity.java</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="CodeContent" style="text-align: justify;">
<div class="hddn">
<figure class="highlight"><div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-javascript code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-javascript code-embed-code">package com.example.activitylifecycle;  <br/>import android.os.Bundle;  <br/>import android.app.Activity;  <br/>import android.util.Log;  <br/>import android.view.Menu;  <br/>public class MainActivity extends Activity {  <br/>    @Override  <br/>    protected void onCreate(Bundle savedInstanceState) {  <br/>        super.onCreate(savedInstanceState);  <br/>        setContentView(R.layout.activity_main);  <br/>        Log.d(&quot;lifecycle&quot;,&quot;onCreate invoked&quot;);  <br/>    }  <br/>    @Override  <br/>    protected void onStart() {  <br/>        super.onStart();  <br/>         Log.d(&quot;lifecycle&quot;,&quot;onStart invoked&quot;);  <br/>    }  <br/>    @Override  <br/>    protected void onResume() {  <br/>        super.onResume();  <br/>         Log.d(&quot;lifecycle&quot;,&quot;onResume invoked&quot;);  <br/>    }  <br/>    @Override  <br/>    protected void onPause() {  <br/>        super.onPause();  <br/>         Log.d(&quot;lifecycle&quot;,&quot;onPause invoked&quot;);  <br/>    }  <br/>    @Override  <br/>    protected void onStop() {  <br/>        super.onStop();  <br/>         Log.d(&quot;lifecycle&quot;,&quot;onStop invoked&quot;);  <br/>    }  <br/>       @Override  <br/>    protected void onRestart() {  <br/>        super.onRestart();  <br/>         Log.d(&quot;lifecycle&quot;,&quot;onRestart invoked&quot;);  <br/>    }     <br/>    @Override  <br/>    protected void onDestroy() {  <br/>        super.onDestroy();  <br/>         Log.d(&quot;lifecycle&quot;,&quot;onDestroy invoked&quot;);  <br/>    }  <br/>} </code></pre> </div></figure>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>You will not see any output on the emulator or device. You need to open logcat.</li>
</ul>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/tutorials/android/android-adb-driver.png" alt=" android adb driver" /></div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Now see on the logcat: on Create, on Start and on Resume methods are invoked.</li>
</ul>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/tutorials/android/android-add-widget.png" alt=" android add widget" /></div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Now click on the HOME Button. You will see on Pause method is invoked.</li>
</ul>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/tutorials/android/android-intent-example.png" alt=" android intent example" /></div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>After a while, you will see on Stop method is invoked.</li>
</ul>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/tutorials/android/activity-android.png" alt=" activity android" /></div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Now see on the emulator. It is on the home. Now click on the center button to launch the app again.</li>
</ul>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/tutorials/android/activity-in-android.png" alt=" activity in android" /></div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Now click on the lifecycle activity icon.</li>
</ul>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/tutorials/android/android-broadcastreceiver.png" alt=" android broadcastreceiver" /></div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Now see on the logcat: on Restart, on Start and on Resume methods are invoked.</li>
</ul>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/tutorials/android/androidmanifest-xml.png" alt=" androidmanifest xml" /></div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>If you see the emulator, application is started again.</li>
</ul>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/tutorials/android/alogcat.png" alt=" alogcat" /></div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Now click on the back button. Now you will see onPause methods is invoked.</li>
</ul>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/tutorials/android/android-activity-life-cycle.png" alt=" android activity life cycle" /></div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>After a while, you will see onStop and onDestroy methods are invoked.</li>
</ul>
</div>
</div>
<div class="ImageContent">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/tutorials/android/life-cycle-of-android.png" alt=" life cycle of android" /></div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/android/android-activity-lifecycle/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
