[英]How to create two entry points to application using deeplink?
I want to create an application which will have two entry points. 我想创建一个具有两个入口点的应用程序。 The first will be a regular entry when the user clicks the app icon.
当用户单击应用程序图标时,第一个条目将是常规条目。 The second one will be through a deeplink which will be sent through push notifications.
第二个将通过深层链接,该深层链接将通过推送通知发送。
I used this tutorial to build the deeplink. 我使用本教程构建了深层链接。
I tried to use the deeplink to open the second entry point using adb, however I keep getting 我尝试使用Deeplink使用adb打开第二个入口点,但是我不断
Activity not started, unable to resolve Intent.
活动尚未开始,无法解决意图。
Here is my manifest file: 这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.edwardkeselman.siemens">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".Login">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ReportActivity" />
<activity android:name=".DetailsActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "example://gizmos” -->
<data android:scheme="example"
android:host="gizmos" />
</intent-filter>
</activity>
</application>
</manifest>
Here is my DetailsActivity: 这是我的DetailsActivity:
public class DetailsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_details);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Intent intent = getIntent();
String action = intent.getAction();
Uri data = intent.getData();
}
}
This is the adb command that I use to try to open the DetailsActivity: 这是我用来尝试打开DetailsActivity的adb命令:
adb shell am start -W -a android.intent.action.BROWSE -d "example://gizmoz" com.example.myname
Help will be much appreciated. 帮助将不胜感激。
manifest.xml manifest.xml
<activity android:name=".DeepLinking">
<intent-filter android:label="@string/filter_deeplinking">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
<data
android:host="domain.in"
android:scheme="http" />
<!-- note that the leading "/" is required for pathPrefix -->
<!-- Accepts URIs that begin with "example://gizmos” -->
<data android:scheme="example"
android:host="gizmos" />
</intent-filter>
</activity>
DeepLinking.java DeepLinking.java
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import java.net.URLDecoder;
public class DeepLinking extends AppCompatActivity { 公共类DeepLinking扩展了AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_deep_linking);
Intent intent = getIntent();
String action = intent.getAction();
Uri uri_data = intent.getData();
String data=uri_data.toString();
Log.d("DATA : ",""+uri_data.toString());
if(data.equals("domain.in") || data.equals("http://domain.in") )
{
Intent i = new Intent(getApplicationContext(), Splash.class);
startActivity(i);
finish();
}
else if (!data.equals(null))
{
Intent i = new Intent(getApplicationContext(), DetailActivity.class);
startActivity(i);
finish();
}
else
{
Intent i = new Intent(getApplicationContext(), Splash.class);
startActivity(i);
finish();
}
}
} }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.