我想打开同一个应用程序的新实例,就像打开新标签页时(See this)
默认使用的Chrome一样这是我到目前为止所尝试的内容:
PackageManager pm = getContext().getPackageManager();
Intent launcher = pm.getLaunchIntentForPackage("my.package.name");
launcher.setAction(Intent.ACTION_VIEW);
launcher.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
launcher.setData(Uri.parse(result.getExtra()));
getContext().startActivity(launcher);
它确实启动了一项新活动,并且还加载了正确的数据,但它没有打开新的屏幕。
我将如何实现这一目标?
这是我的最终文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="eu.depa.browsing.stack">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:fullBackupContent="true"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:hardwareAccelerated="true">
<activity android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:windowSoftInputMode="stateAlwaysHidden"
android:targetActivity=".MainActivity"
android:icon="@mipmap/ic_launcher">
<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="http" />
<data android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".About"/>
<activity android:name=".Donate"/>
<activity android:name=".Settings"/>
<activity android:name=".GPL"/>
<activity android:name=".History"/>
<!-- ATTENTION: This was auto-generated to add Google Play services to your project for
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information. -->
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
</manifest>