Activity.StartActivityIfNeeded 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| StartActivityIfNeeded(Intent, Int32) |
就像打電話 |
| StartActivityIfNeeded(Intent, Int32, Bundle) |
一種特殊變體,只有在需要新的活動實例來處理特定意圖時才會啟動活動。 |
StartActivityIfNeeded(Intent, Int32)
就像打電話 #startActivityIfNeeded(Intent, int, Bundle) 時沒有選項一樣。
[Android.Runtime.Register("startActivityIfNeeded", "(Landroid/content/Intent;I)Z", "GetStartActivityIfNeeded_Landroid_content_Intent_IHandler")]
public virtual bool StartActivityIfNeeded(Android.Content.Intent intent, int requestCode);
[<Android.Runtime.Register("startActivityIfNeeded", "(Landroid/content/Intent;I)Z", "GetStartActivityIfNeeded_Landroid_content_Intent_IHandler")>]
abstract member StartActivityIfNeeded : Android.Content.Intent * int -> bool
override this.StartActivityIfNeeded : Android.Content.Intent * int -> bool
參數
- intent
- Intent
開始的意圖。
- requestCode
- Int32
若 >= 0,當活動結束時,該代碼會在 onActivityResult() 中回傳;若為 < 0,則活動結束時不會返回結果,如 #startActivityForResult所述。
傳回
若啟動新活動,則回傳 true;否則錯誤將被回傳,你必須自行處理意圖。
- 屬性
備註
就像呼叫 startActivityIfNeeded(Intent, int, Bundle) 一樣,沒有選項。
另請參閱:
Android 參考資料。android.app.Activity.startActivityIfNeeded
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。
適用於
StartActivityIfNeeded(Intent, Int32, Bundle)
一種特殊變體,只有在需要新的活動實例來處理特定意圖時才會啟動活動。
[Android.Runtime.Register("startActivityIfNeeded", "(Landroid/content/Intent;ILandroid/os/Bundle;)Z", "GetStartActivityIfNeeded_Landroid_content_Intent_ILandroid_os_Bundle_Handler")]
public virtual bool StartActivityIfNeeded(Android.Content.Intent intent, int requestCode, Android.OS.Bundle? options);
[<Android.Runtime.Register("startActivityIfNeeded", "(Landroid/content/Intent;ILandroid/os/Bundle;)Z", "GetStartActivityIfNeeded_Landroid_content_Intent_ILandroid_os_Bundle_Handler")>]
abstract member StartActivityIfNeeded : Android.Content.Intent * int * Android.OS.Bundle -> bool
override this.StartActivityIfNeeded : Android.Content.Intent * int * Android.OS.Bundle -> bool
參數
- intent
- Intent
開始的意圖。
- requestCode
- Int32
若 >= 0,當活動結束時,該代碼會在 onActivityResult() 中回傳;若為 < 0,則活動結束時不會返回結果,如 #startActivityForResult所述。
- options
- Bundle
活動開始方式的額外選項。
更多細節請參見 android.content.Context#startActivity(Intent, Bundle) Context.startActivity(Intent, Bundle)}。
傳回
若啟動新活動,則回傳 true;否則錯誤將被回傳,你必須自行處理意圖。
- 屬性
備註
一種特殊變體,只有在需要新的活動實例來處理特定意圖時才會啟動活動。 換句話說,這就像 startActivityForResult(Intent,int) 一樣,只是:如果你使用 Intent.FLAG_ACTIVITY_SINGLE_TOP 標誌、singleTask 或 singleTop launchMode,且處理意圖的活動與你目前正在執行的活動相同,則不需要新實例。 在這種情況下,這個函式會回傳,而不是像一般呼叫 onNewIntent(Intent) 那樣,你也可以自己處理這個 Intent。 此函式只能從頂層活動呼叫;若是從子活動呼叫,則會拋出執行時例外。
另請參閱:
Android 參考資料。android.app.Activity.startActivityIfNeeded
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。