相关疑难解决方法(0)

如何在Android上实现我自己的URI方案

假设我想定义一个URI,例如:

myapp://path/to/what/i/want?d=This%20is%20a%20test
Run Code Online (Sandbox Code Playgroud)

必须由我自己的应用程序或服务处理.请注意,该方案"myapp",而不是"http",或"ftp".这正是我的意图:为Android OS全局定义自己的URI架构.这可能吗?

这有点类似于某些程序已经在做的事情,例如Windows系统,例如Skype(skype://)或任何torrent下载程序(torrent://).

browser android uri intentfilter android-intent

159
推荐指数
5
解决办法
17万
查看次数

Android在Intent中响应URL

我希望在用户访问某个网址时启动我的意图:例如,Android市场通过http://market.android.com/网址进行此操作.youtube也是如此.我也希望我也这样做.

url android launch intentfilter android-intent

151
推荐指数
2
解决办法
11万
查看次数

Android:了解Intent-Filters

我想创建一个意向过滤器,从而使某些环节会触发我的应用程序的开始(见本计算器线程,例如:如何注册一些URL命名空间(MYAPP://app.start/)来访问你的程序通过在Android OS中的浏览器中调用URL?)

尝试时,我想,我不太明白Intents和Intent-Filters(在Manifest.xml中定义)实际上是如何工作的.以下是有什么区别的:

<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />
Run Code Online (Sandbox Code Playgroud)

或以下:

<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.MAIN" />
Run Code Online (Sandbox Code Playgroud)

实际上,类别和动作Intent-Filters之间的区别是什么.我阅读了这个页面http://developer.android.com/reference/android/content/Intent.html但我仍然缺少一个基本的了解.

android intentfilter android-intent

33
推荐指数
1
解决办法
2万
查看次数

Intent Filter在单击自定义URI时启动My Activity

我正在尝试允许注册URI以使用我的应用程序打开.就像PatternRepository黑莓和iPhone上的CFBundleURLName/一样CFBundleURLSchemes.如何在Android上获得相同的结果?

系统将发送带有以下链接的电子邮件: myapp://myapp.mycompany.com/index/customerId/12345.这个想法是用户应该能够点击链接以打开应用程序中的客户活动.

我已尝试过其他SO帖子的大量建议,但我无法让操作系统识别模式并打开我的应用程序.

在Gmail应用中,它看起来像这样:myapp:// myapp.mycompany.com/index/customerId/12345.它识别并强调myapp.mycompany.com/index/customerId/12345链接的一部分,并在浏览器中打开它.该myapp://部分未链接.

标准邮件应用程序将整个链接视为纯文本.

我在这里错过了什么?

PS:我已经看过 如何在Android上实现我自己的URI方案 以及如何通过在Android OS中的浏览器中调用URL来注册一些URL命名空间(myapp://app.start/)来访问您的程序?

清单:

<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:versionCode="2"
    android:versionName="0.0.8" 
    package="com.mycompany.myapp.client.android">

    <uses-sdk 
        android:minSdkVersion="7" 
        android:targetSdkVersion="7"/>

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>

    <application 
        android:label="@string/app_name" 
        android:name="myappApplication" 
        android:icon="@drawable/ic_icon_myapp" 
        android:debuggable="true">

        <activity 
            android:label="My App" 
            android:name=".gui.activity.LoginActivity" 
            label="@string/app_name">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>

        <activity android:name=".gui.activity.CustomerDetailActivity" > 
            <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="myapp"/> 
            </intent-filter> 
        </activity>

        <activity android:name=".gui.activity.CustomerDetailActivity"/> …
Run Code Online (Sandbox Code Playgroud)

android uri android-manifest android-intent

23
推荐指数
2
解决办法
4万
查看次数

关于从URL启动Android应用程序

我试图弄清楚如何从URL启动应用程序,以及我应该如何编写该URL.

我的AndroidManifest中有以下代码:

<activity android:name=".MyActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN"></action>
        <action android:name="android.intent.action.VIEW"></action>
        <category android:name="android.intent.category.LAUNCHER"></category>
        <category android:name="android.intent.category.DEFAULT"></category>
        <category android:name="android.intent.category.BROWSABLE"></category>
        <data android:host="my.app" android:scheme="http"></data>
    </intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)

我使用了本回答中解释的URL ,但没有任何反应.

如果我的意图写得很好,请告诉我,以及我应该如何编写调用该应用程序的URL,并注意我需要调用我的"主要"活动.

android intentfilter android-intent android-activity

11
推荐指数
1
解决办法
9906
查看次数

使用意图URI启动我的应用程序

我知道StackOverflow已经多次询问过这个问题,但我还没有找到解决方案.我的应用会发送一封电子邮件,其中包含一个链接,点击后应启动该应用.

根据@hackbod的说法,最好的方法是使用Intent URI(参见本节).这是我设置意图的代码并将其放入电子邮件正文中:

Intent customIntent = new Intent(CUSTOM_ACTION);
customIntent.setPackage(MY_PACKAGE);
customIntent.addCategory(MY_CAT_BROWSABLE);
customIntent.addCategory(MY_CAT_DEFAULT);

String customUri = customIntent.toUri(Intent.URI_INTENT_SCHEME);

String emailBody = getString(R.string.intent_link, customUri);

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/html");
intent.putExtra(Intent.EXTRA_SUBJECT, "Recommending vid");
intent.putExtra(Intent.EXTRA_TEXT   , Html.fromHtml(emailBody));
try {
    startActivity(Intent.createChooser(intent, "Choose email client:"));
} catch (android.content.ActivityNotFoundException ex) {
    Toast.makeText(this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
Run Code Online (Sandbox Code Playgroud)

这是我从LogCat得到的:

08-25 17:01:23.333: VERBOSE/Test URI(16987): intent:#Intent;action=com.test.project.action.VIEW_VID_FROM_LINK;category=android.intent.category.DEFAULT;category=android.intent.category.BROWSABLE;package=com.test.project;end
08-25 17:01:23.338: VERBOSE/Test email text(16987): Hi,<br><br>Testing intents from an email.<br><br> A standard website: <a href=http://www.google.com>Go to Google</a>.<br><br> This link should …
Run Code Online (Sandbox Code Playgroud)

email android uri android-intent

7
推荐指数
1
解决办法
2万
查看次数

URL方案在Android浏览器中不起作用

点击链接时我需要打开我的应用程序.为此,我读到我必须使用URL方案.该链接必须具有myapp://参数形式.

我阅读了关于这个主题的每篇文章,但是当我发送一封带有"myapp:// addUser /?id = 22"的电子邮件并且我从chrome(在我的手机上)打开时,它无法点击.

我的清单:

 <activity
            android:name="com.example.SplashActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <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="myapp" android:host="com.example"/>
            </intent-filter>

        </activity>
Run Code Online (Sandbox Code Playgroud)

我的课:

公共类SplashActivity扩展FragmentActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_splash);
    Intent intent = getIntent();

    if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        Uri uri = intent.getData();
        String id = uri.getQueryParameter("id"); 
    }

}
Run Code Online (Sandbox Code Playgroud)

要测试代码的邮件内容:

myapp://addUser/?id=22
Run Code Online (Sandbox Code Playgroud)

参考链接:

在Android浏览器中建立一个链接启动我的应用程序?

如何通过在Android OS中的浏览器中调用URL来注册一些URL命名空间(myapp://app.start/)来访问您的程序?

https://legacy.madewithmarmalade.com/devnet/forum/custom-url-scheme-primarily-android-3

UPDATE

我认为问题是邮件正文,但我不知道如何测试它.

android url-scheme

6
推荐指数
1
解决办法
5646
查看次数

Android M - App Linking无法在Chrome中运行

所以我想在一些新的应用程序中实现App Links,我已经通过开发笔记,设置服务器,使用正确的json标头添加文件并构建了一个测试应用程序.Android M中引入的应用程序深度链接似乎可以正常工作,如果我给自己发送附带链接的电子邮件,但是当我在chrome的示例页面上执行此操作时,它只是重新加载页面.我只是在我的网络服务器上访问根页面.(https://www.EXAMPLE.com).我最初在平板电脑上有一些Chrome问题但是我添加了根证书,现在它变成了绿色

我正在使用Nexus 7 2013,刚刚擦除并运行Android M和Chrome,已更新.

我在我的服务器上提供HTML文件(就像我有一个后退页面一样).

不知道这是我如何使用网页/退回,或者我配置错误.它在Gmail中运行良好,没有任务选择器,但在chrome中不行.

我尝试混合几个例子html看起来像这样,没有一个工作.

<a href="EXAMPLE://">Click HERE for schema</a>

<a href="https://www.EXAMPLE.com/">Click HERE for url with slash</a>

<a href="https://www.EXAMPLE.com">Click HERE for url, no slash</a>

<a href="#" onclick="window.location('https://www.EXAMPLE.com/')">Trying with onclick javascript</a>
Run Code Online (Sandbox Code Playgroud)

我的android清单:

<activity
        android:name=".deepActivity"
        android:label="@string/title_activity_deep" >
        <intent-filter android:autoVerify="true">

            <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" android:host="www.EXAMPLE.com" />
            <data android:scheme="https" android:host="www.MYDOMAIN.com" />

            <!-- note that the leading "/" is required for pathPrefix-->
            <!-- Accepts URIs that begin with "example://gizmos”-->

        </intent-filter>
Run Code Online (Sandbox Code Playgroud)

https://developer.android.com/training/app-links/index.html …

android google-chrome deep-linking android-6.0-marshmallow

5
推荐指数
1
解决办法
1760
查看次数