0

I would like to know if there is a way to fully stop one activity when another activity is called. For instance, I have two activities within an application but it seems like that when one activity is called another activity seems to be running (such as Background services). I thought that when one activity within an application is called another activity is stopped under the circumstance that there are two activities. Following is manifest file for the application (I deleted lines for Background services here..) Thanks in advance! :)

<?xml version="1.0" encoding="utf-8"?>
 <uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="19" />

 <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme">



      <activity
        android:name=".MainActivity"
        android:label="@string/app_name" 
        android:screenOrientation="portrait"
        >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name="com.me.hello"
        android:label="@string/app_name"
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

        </intent-filter>
    </activity>
        </application>

denden130
  • 231
  • 4
  • 15
  • 1
    read it , you will get the answer: http://stackoverflow.com/questions/8515936/android-activity-life-cycle-what-are-all-these-methods-for – Krupal Shah Sep 21 '14 at 21:07
  • @krupalshah hello krupalshah, thanks for commenting. I read it and found the difference between shutdown and stop. Should have read it carefully. Thanks much ! – denden130 Sep 21 '14 at 21:33

1 Answers1

0

You can call finish() on the first Activity.

Intent intent = new Intent(FirstActivity.class, SecondActivity.class);
startActivity(intent);
finsish();
TmKVU
  • 2,910
  • 2
  • 16
  • 30
  • thanks! I found that finish() is the right way to fully shutdown the first activity. I will implement it and see if it is working. It was helpful. :) – denden130 Sep 21 '14 at 21:34