onNewIntent 作用

onNewIntent 作用
public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Log.i("MainActivity", "---------------------------onCreate ");   
    }


    
    @Override    
    protected void onNewIntent(Intent intent) {    
        
        Log.i("MainActivity", "---------------------------onNewIntent  intent = "+intent);   
        setIntent(intent);
        super.onNewIntent(intent);   
    }

}
onNewIntent 作用
onNewIntent 作用
    <activity
            android:name="com.example.badupush.MainActivity"
            android:label="@string/app_name" 
            android:launchMode="singleTask">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
onNewIntent 作用

onCreate是用来创建一个activity的,但activity处于任务栈的顶端时,不会再次调用onCreate。

如果你想用这个顶端的activity去处理新的Intent,可以利用onNewIntent()

按home键返回时,再打开app,会调用onNewIntent()

onNewIntent 作用

上一篇:Windows Server 2008 Standard Enterprise Datacenter各个版本区别


下一篇:WIN32进阶必备:跟随鼠标移动的子窗口