編輯:關於Android編程
android:launchMode="singleTask"),但是調用startActivityForResult後馬上調用A裡面的protected
void onActivityResult(int requestCode, int resultCode, Intent data),系統返回resultCode=RESULT_CANCELED。在B中的setResult也沒有任何意義了。
Logcat輸出如下的信息:
Activity is launching as a new task, so cancelling activity result.
看了startActivityForResult的文檔中有下面關鍵一句:
For example, if the activity you
* are launching uses the singleTask launch mode, it will not run in your
* task and thus you will immediately receive a cancel result.
Note that this method should only be used with Intent protocols that are defined to return a result. In other
protocols (such as Intent.ACTION_MAIN or Intent.ACTION_VIEW),
you may not get the result when you expect. For example, if the activity you are launching uses the singleTask launch mode, it will not run in your task and thus you will immediately receive a cancel result.
也就是說B不能是單例或單任務啟動模式,即launchMode不能這樣設置:
android:launchMode="singleInstance"
android:launchMode="singleTask"
去掉B 中的如上設置,運行正常。
因此,對於singInstance或singleTask的Activity只能采用其他的方式來傳遞數據。
這兩個LaunchMode標識只能用在startActivity()的方法中,而不能使用在startActivityForResult方法中。因為從Task的角度看,Android認為不同Task之間的Activity是不能傳遞數據的。所以也不會有有用的result返回。
Android 管理Activity中的fragments
FragmentManager 為了管理Activity中的fragments,需要使用FragmentManager. 為了得到它,需要調用Activity中的getF
Android快樂貪吃蛇游戲實戰項目開發教程-04虛擬方向鍵(三)三角形按鈕效果
一、知識點講解當我們點擊系統自帶的按鈕時,按鈕的外觀會發生變化。上篇博文中我們畫了一個三角形按鈕,但點擊還不能變色,下面我們就來實現點擊變色功能。從知識體系上我們需要了解
Android屏幕適配規則
要適配不同的屏幕,首要需要的是要能夠將不同的屏幕分辨出來,android提供了若干不同的維度來進行限定(qualifier,有的翻譯為限定詞)上圖所示為常用的一些維度,不
chromium for android v34 2dcanvas硬件渲染實現分析
這篇接著上一篇2dcanvas硬件繪制,分析保存繪制結果的texture被合成到on screen framebuffer上的過程。 1.webkit為canvas元素對