常用鏈接

          統(tǒng)計(jì)

          最新評論

          onNewIntent 什么時(shí)候調(diào)用

          protected void onNewIntent (Intent intent)

          Since: API Level 1

          This is called for activities that set launchMode to "singleTop" in their package, or if a client used theFLAG_ACTIVITY_SINGLE_TOP flag when calling startActivity(Intent). In either case, when the activity is re-launched while at the top of the activity stack instead of a new instance of the activity being started, onNewIntent() will be called on the existing instance with the Intent that was used to re-launch it.

          An activity will always be paused before receiving a new intent, so you can count on onResume() being called after this method.

          Note that getIntent() still returns the original Intent. You can use setIntent(Intent) to update it to this new Intent.


          在IntentActivity中重寫下列方法:onCreate onStart onRestart  onResume  onPause onStop onDestroy  onNewIntent
          一、其他應(yīng)用發(fā)Intent,執(zhí)行下列方法:
          I/@@@philn(12410): onCreate
          I/@@@philn(12410): onStart
          I/@@@philn(12410): onResume

          發(fā)Intent的方法:
          Uri uri = Uri.parse("philn://blog.163.com");
          Intent it = new Intent(Intent.ACTION_VIEW, uri);    
          startActivity(it);

          二、接收Intent聲明:
           <activity android:name=".IntentActivity" android:launchMode="singleTask"
                            android:label="@string/testname">
                       <intent-filter>
                          <action android:name="android.intent.action.VIEW" />
                          <category android:name="android.intent.category.DEFAULT" />
                          <category android:name="android.intent.category.BROWSABLE" />
                          <data android:scheme="philn"/>
                      </intent-filter>
            </activity>

          三、如果IntentActivity處于任務(wù)棧的頂端,也就是說之前打開過的Activity,現(xiàn)在處于
          I/@@@philn(12410): onPause
          I/@@@philn(12410): onStop 狀態(tài)的話
          其他應(yīng)用再發(fā)送Intent的話,執(zhí)行順序?yàn)椋?br style="line-height: 22px; " /> I/@@@philn(12410): onNewIntent
          I/@@@philn(12410): onRestart
          I/@@@philn(12410): onStart
          I/@@@philn(12410): onResume

          posted on 2011-02-14 11:18 九寶 閱讀(6213) 評論(1)  編輯  收藏 所屬分類: android

          評論

          # re: onNewIntent 什么時(shí)候調(diào)用 2012-02-14 10:12 tingtingyang

          寫的很清晰!支持  回復(fù)  更多評論   

          主站蜘蛛池模板: 苏尼特左旗| 涪陵区| 平泉县| 兴山县| 五大连池市| 六安市| 嘉禾县| 红河县| 天祝| 永康市| 定安县| 镇安县| 四子王旗| 合肥市| 乌拉特前旗| 成武县| 长沙县| 杨浦区| 四子王旗| 甘南县| 阿拉善盟| 敦煌市| 垦利县| 乌海市| 江达县| 汶上县| 娱乐| 海丰县| 大同县| 偏关县| 苍溪县| 鄂托克前旗| 巧家县| 双辽市| 陆丰市| 洛南县| 林周县| 聂荣县| 皮山县| 保定市| 定兴县|