允许用户将链接从应用发送给其他人,然后在单击时打开应用

时间:2018-06-24 07:37:59

标签: java android android-sharing

我什至不确定这是否可行,但这是我想做的。

为用户提供共享某些内容(例如库存物品)的选项。使用IntentACTION_SEND都很容易。但是,如果其他人安装了相同的应用程序,则链接应将他们带到我的应用程序,并传递发送给他们的数据(以便应用程序可以将其显示给他们)。如果他们没有该应用,则应将其带到应用商店以鼓励他们下载该应用。

这有可能吗?如果可以,怎么办?

2 个答案:

答案 0 :(得分:1)

如此链接中所述:Create Deep Links

您应该在清单中添加它:

courseList: Array<ISemester> = [];

addCourse(){
    this.selectedSemester={Id: "20193", Semester: "Fall ", Year: "2018", course: []};
    this.selectedCourse={CourseNumber:"240",CourseTitle:"Painting",CurriculumID:"00001025"}

    // Add the semester and get the reference to it
    const currentSemester = this.addSemester(this.selectedSemester);

    // Add the selected course to the referenced semester in the courseList
    this._addCourse(this.selectedCourse, currentSemester);
}

/**
 * This method first checks whether the semester is already listed.
 * If not, the semester will be added.
 * The method finally returns the reference to the semester object in the list.
 */
private addSemester(semester: ISemester): ISemester {
    let isInList: boolean = false;
    let currentSemester: ISemester;

    // walk through the semester list
    this.courseList.forEach(element => {
        // if the semester is already listed
        if(element.Id === semester.Id){
            // memorize this and let the return value (currentSemester) 
            // be a reference to the semester element in the list
            isInList = true;
            currentSemester = element;

            // stop iteration
            break;
        }
    });

    // if there was no match, add the semester to the courseList
    if(!isInList) {
       currentSemester = semester;
       this.courseList.push(semester);
    }

    return currentSemester;
}

private _addCourse(course: ICourse, semester: ISemester) {
    // if the course is not yet listed
    if(this.semester.course.filter(element => element.Id === course.Id).length < 0){
        // add it
        this.semester.course.push(course);
    }
}

,然后与另一个人共享一个以“ http://www.example.com/gizmos”(假网址)开头的链接。

答案 1 :(得分:0)

是的,可以通过在URL中添加状态参数,然后从服务器端代码重定向到Play商店来实现。

例如-您的应用程序生成指向某些用户个人资料的网址-

https://www.yourSocialNewtwork.com/profile/sandeshDahake

第1步-使用意图过滤器在您的应用中创建深层链接。这将处理您的应用程序已安装并将参数传递给它-

<data android:scheme="https"
          android:host="www.yourSocialNewtwork.com"
          android:pathPrefix="/profile" />

第2步-如果未安装应用,则可以从服务器端重定向到Play商店

https://developer.android.com/google/play/installreferrer/library#java

https://play.google.com/store/apps/details?id=com.profile.yourHierarchy&referrer = sandeshDahake

我听说有一些开源项目可以处理这种情况,但尚未对其进行探讨。

这里的基本技巧是正确的url结构和深层链接。 https://developer.android.com/training/app-links/deep-linking