本文共 2965 字,大约阅读时间需要 9 分钟。
android mvp示例
In this tutorial you will learn about android deep linking with an example.
在本教程中,您将通过示例了解android深度链接。
In deep linking first we have to understand what does an URI means. Let us consider an example of URI,
首先,在深层链接中,我们必须了解URI的含义。 让我们考虑一个URI的例子,
https://www.example.com/demo?userid=100&client=android
https://www.example.com/demo?userid=100&client=android
Here,
这里,
https is a scheme
https是一个方案
www.example.com is a host
www.example.com是房东
/demo is a path, directing the specific resource
/ demo是用于引导特定资源的路径
?userid=100&client=android is a query string with key-value pairs like the hashmap in java.
?userid = 100&client = android是具有键值对的查询字符串,例如java中的hashmap。
Deeplink is defined as a source of content to content web to your android application and in deeplink whenever user opens an URI and if that URI is deep link with any application then it opens a dialog prompt that open with that app or open with browser only.
深度链接被定义为内容网络到您的android应用程序的内容源,并且在深度链接中,只要用户打开URI,并且该URI是与任何应用程序的深度链接,则它会打开一个对话框提示,该对话框随该应用程序打开或仅通过浏览器打开。
We can create deeplink over network that is connecting website directly to the application or we can create custom deplink also like myApplication://….
我们可以创建将网站直接连接到应用程序的网络深层链接,也可以创建自定义的deplink,例如myApplication://…。
First of all create a new android project to understand deeplink in android app.
首先创建一个新的android项目,以了解android应用中的Deeplink。
Now make intent filter in the activity that you want to open when user click on weblink.
现在,在用户单击Weblink时要打开的活动中进行意图过滤。
What we are doing in this project is when we are clicking on weblink then we are opening the app and showing the weblink in the text view.
在此项目中,我们要做的是单击Weblink,然后打开应用程序并在文本视图中显示该Weblink。
activity_main.xml
activity_main.xml
Now we are designing its java class to represent weblink when user click on it on textview.
现在,我们正在设计其java类,以在用户在textview上单击它时代表Weblink。
MainActivity.java
MainActivity.java
package com.example.deeplinkdemo; import android.content.Intent;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.widget.TextView; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent intent=getIntent(); if(intent!=null&&intent.getData()!=null){ ((TextView)findViewById(R.id.deepLinkText)).setText(intent.getData().toString()); } }}
Build app for about project and install it in your mobile device.
为项目构建应用程序并将其安装在您的移动设备中。
Below we are designing a custom html file when user open that html file and click on the link on that html file then our app will open.
下面,我们在用户打开html文件并单击该html文件上的链接时设计一个自定义html文件,然后我们的应用程序将打开。
myapp://myhost/help
Now you can run and test your application.
现在,您可以运行和测试您的应用程序。
翻译自:
android mvp示例
转载地址:http://wtggb.baihongyu.com/