[英]onNewIntent not being fired
我正在使用意圖過濾器為我的應用程序捕獲自定義方案:
<activity
android:name=".activities.MyActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/title_my_activity"
android:launchMode="singleTop"
android:noHistory="true"
android:screenOrientation="portrait">
<!-- myapp://app.open -->
<intent-filter android:label="@string/my_intent">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myapp" />
<data android:host="app" />
<data android:host="app.open" />
</intent-filter>
</activity>
在我的活動中,我覆蓋:
@Override
protected void onNewIntent(Intent intent) {
Log.d("DEBUG", "New intent!");
super.onNewIntent(intent);
}
但這從未被稱為...我在哪里錯了? noHistory標志是否必要? 如果刪除它,那么我將在堆棧中擁有兩個相同活動的副本。
下面的代碼對我來說很好
<activity android:name=".MainActivity"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myapp" />
<data android:host="app" />
<data android:host="app.open" />
</intent-filter>
</activity>
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent(this,MainActivity.class);
startActivity(intent);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Log.d("DEBUG", "New intent!");
}}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.