2011-01-27 55 views
0

嗨 我已經添加到圖庫共享菜單的應用程序。 選擇和共享一個圖像工作正常,此代碼:android意圖收到onCreate多次

if (Intent.ACTION_SEND.equals(action)) { 
在我的onCreate

執行。

問題是當我按回(銷燬)並再次打開應用程序 在onCreate中收到相同的意圖。

我用的是:

android:launchMode="singleTop"> 

protected void onNewIntent(Intent intent) 

的onNewIntent不點火。 我懷疑我必須以某種方式清除意圖。 並試圖找到並回答,但我即將卡住

回答

0

找到了解決辦法,所以我回答我的問題對任何人的喜悅

添加到了體現:

 <activity android:name=".ServicesDemo" 
       android:label="@string/app_name" 
       android:configChanges="keyboardHidden|orientation"> 

添加了此到我的ServicesDemo:

public void onConfigurationChanged(Configuration newConfig) 
{ 
    Toast.makeText(this, "onConfigurationChanged",Toast.LENGTH_LONG).show(); 
    super.onConfigurationChanged(newConfig); 
} 

手機的方向變化將觸發此方法,而不是onCreate

1

看問題是在你的launchmode.it應該是標準的,所以每次它會啓動新的活動實例。


因爲你用的是單腳本,所以如果你再次回到你當前的活動,它不會重新啓動。


看到這個鏈接,裁判launchmode是如何工作的:http://developer.android.com/guide/topics/manifest/activity-element.html#lmode

+0

是的,這是奇怪的是,再次與singeltop射擊。將刪除singeltop並從那裏工作。我懷疑我會做更多的錯誤。感謝您的回覆 – Erik 2011-01-27 13:02:01