Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to close all activities on android eclipse
    primarykey
    data
    text
    <p>Assume i have four classes.Each class is having a button to do screen switching from one page to another page,well its working fine.But now im trying to close all the activities by clicking the button from the last page.I have tried that too, but its just closing only the last page.How to achieve this concept?</p> <p>Please find my code for reference</p> <p><strong>Xit_demoActivity.java</strong></p> <pre><code>public class Xit_demoActivity extends Activity { /** Called when the activity is first created. */ Button btn1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); btn1 = (Button)findViewById(R.id.button_1); btn1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent myIntent = new Intent(v.getContext(), Class1.class); startActivity(myIntent); } }); </code></pre> <p><strong>Class1.java</strong></p> <pre><code>public class Class1 extends Activity { Button btn1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main1); btn1 = (Button)findViewById(R.id.button_2); btn1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent myIntent = new Intent(v.getContext(), Class2.class); startActivity(myIntent); } }); </code></pre> <p><strong>Class2.java</strong></p> <pre><code>public class Class2 extends Activity { Button btn1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main2); btn1 = (Button)findViewById(R.id.button_3); btn1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent myIntent = new Intent(v.getContext(), Class3.class); startActivity(myIntent); } }); </code></pre> <p><strong>Class3.java</strong></p> <pre><code>public class Class3 extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main3); Button next = (Button) findViewById(R.id.button_4); next.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(); setResult(RESULT_OK, intent); finish(); } }); </code></pre> <p><strong>Manifest.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.and.roidu.xit" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" /&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" &gt; &lt;activity android:name=".Xit_demoActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt;&lt;activity android:name=".Class1"&gt;&lt;/activity&gt; &lt;activity android:name=".Class1" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN1" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt;&lt;activity android:name=".Class2"&gt;&lt;/activity&gt; &lt;activity android:name=".Class2" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN2" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt;&lt;activity android:name=".Class3"&gt;&lt;/activity&gt; &lt;activity android:name=".Class3" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN3" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>Thanks for your time!..</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload