代码之家  ›  专栏  ›  技术社区  ›  Rodnik

让应用程序出现在google chrome的“共享列表选项”中?

  •  1
  • Rodnik  · 技术社区  · 6 年前

    我正试图让我的应用程序出现在谷歌的股票列表选项上。已经有很多关于在股票列表选项中列出应用程序的帖子,但我找不到答案。据我所知,谷歌将使用不同的意图,只列出具有特定意图的应用程序?

    这就是我想做的。

    我添加的代码是

      <activity android:name=".ui.MyActivity" >
    <intent-filter>
      <action android:name="android.intent.action.SEND" />
      <category android:name="android.intent.category.DEFAULT" />
      <data android:mimeType="image/*" />
    </intent-filter>
    <intent-filter>
      <action android:name="android.intent.action.SEND" />
      <category android:name="android.intent.category.DEFAULT" />
      <data android:mimeType="text/plain" />
    </intent-filter>
    <intent-filter>
      <action android:name="android.intent.action.SEND_MULTIPLE" />
      <category android:name="android.intent.category.DEFAULT" />
      <data android:mimeType="image/*" />
    </intent-filter>
    

    但该应用程序并没有出现在谷歌的股票列表选项中。甚至当我下载一幅图像并试图通过库共享它时也不行。应用程序没有显示。

    Image

    2 回复  |  直到 6 年前
        1
  •  0
  •   Houssem    6 年前

    除了添加从其他应用程序获取内容的功能外,您还需要添加以下内容:

            <intent-filter>
                <action android:name="android.intent.action.GET_CONTENT" />
    
                <category android:name="android.intent.category.DEFAULT" />
    
                <data android:mimeType="*/*" />
            </intent-filter>
    
        2
  •  0
  •   Houssem    6 年前

    我没有测试它,但在MainActivity中,您可以在类声明之前添加它吗

     [IntentFilter(new[] { Intent.ActionSend }, Categories = new[] {
            Android.Content.Intent.CategoryDefault,
            Android.Content.Intent.CategoryBrowsable
        }, DataMimeType = "text/plain")]
    

    在OnCreate方法中添加

    if (!String.IsNullOrEmpty(Intent.GetStringExtra(Intent.ExtraText)))
            {
                string subject = Intent.GetStringExtra(Intent.ExtraSubject) ?? "subject not available";
                Toast.MakeText(this, subject, ToastLength.Long).Show();
            }
    

    出于文本和测试目的,您可以进行调试以验证应用程序是否达到此代码,然后您可以根据需要进行更改