正在啟動並執行android程式,按home鍵之後退回到案頭,在次點擊程式表徵圖避免再次重新啟動程式解決辦法

來源:互聯網
上載者:User

標籤:android   style   blog   http   io   ar   strong   div   art   

例如:一個android程式包含兩個Activity,分別為MainActivity和OtherActivity,MainActivity為程式啟動的Activity。如果程式正位於OtherActivity,點擊home鍵,程式退回到案頭,

在次點擊程式表徵圖,程式預設會自動重啟,即重新進入MainActivity,而不是進入點擊home鍵的時刻程式所位於的OtherActivity。

解決方案:

在AndroidManifest.xml中修改,MainActivity的launchMode,去掉android:launchMode="singleTask"啟動模式即可。

AndroidManifest.xml的配置代碼

[html] view plaincopy 
  1. <application  
  2.         android:icon="@drawable/ic_launcher"  
  3.         android:label="@string/app_name"  
  4.         android:theme="@style/AppTheme" >  
  5.         <activity  
  6.             android:name=".MainActivity"  
  7.             android:label="@string/title_activity_main">  
  8.             <intent-filter>  
  9.                 <action android:name="android.intent.action.MAIN" />  
  10.                 <category android:name="android.intent.category.LAUNCHER" />  
  11.             </intent-filter>  
  12.         </activity>  
  13.         <activity  
  14.             android:name=".OtherActivity"  
  15.             android:label="@string/title_activity_other" android:launchMode="singleTask">  
  16.         </activity>  
  17.     </application>  

正在啟動並執行android程式,按home鍵之後退回到案頭,在次點擊程式表徵圖避免再次重新啟動程式解決辦法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.