在遇到类似于这个问题的问题时,我开始想知道为什么我们setIntent在重写时明确地必须调用onNewIntent,以及为什么这个代码不会被执行super.onNewIntent.
@Override
public void onNewIntent(Intent intent)
{
super.onNewIntent(intent);
// Why isn't this performed by the framework in the line above?
setIntent(intent);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的应用上实现Facebook的深层链接功能,并遇到以下情况:
我有一个名为MainActivity的活动,声明如下:
<activity
android:name="com.mypackage.android.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
此活动+我的包名也在我的应用程序的Facebook开发者网站设置中声明.
一旦链接被点击Facebook的应用程序,我应该通过我的活动的onCreate方法处理此事件.以下代码处理事件:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Uri target = getIntent().getData();
if (target != null){
// got here via Facebook deep link
// once I'm done parsing the URI and deciding
// which part of my app I should point the client to
// I fire an intent for a new activity and
// call finish() the current activity (MainActivity)
}else{
// activity was created in …Run Code Online (Sandbox Code Playgroud) 我有四个活动-A,B,C,D
我以-> ABCDB的方式称呼这四个活动。(指定方式)
我有三种情况。
第一:-我android:launchMode="singleTask"仅在B活动中定义。我通过Intent上述指定方式调用所有活动。
现在首先呼叫ABCD, BackStack Task 1 : A-B-C-D,
现在,我再次呼叫B,然后 BackStack Task 1 : A-B。这里的C和D活动被销毁。
第二:-我正在定义android:launchMode="singleTask"&android:taskAffinity=""在B活动中。我通过Intent上述指定方式调用所有活动。
现在首先呼叫ABCD, BackStack Task 1 : A
Task 2 : B-C-D
Run Code Online (Sandbox Code Playgroud)
现在我再次打电话给B,然后 BackStack Task 1 : A
Task 2 : B ,Here C and D Activities are destroyed.
Run Code Online (Sandbox Code Playgroud)
第三:-我正在定义Intent.FLAG_ACTIVITY_NEW_TASK&android:taskAffinity=""在B活动中。我通过Intent上述指定方式调用所有活动。
现在首先呼叫ABCD, BackStack Task 1 : A
Task 2 : B-C-D
Run Code Online (Sandbox Code Playgroud)
现在我再次打电话给B,然后 BackStack Task …