最佳实践 - 将您的应用程序到Android共享菜单 [英] Best Practice - Adding your App to the Android Share Menu

查看:126
本文介绍了最佳实践 - 将您的应用程序到Android共享菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序发送的文件(所有MIME类型)通过TCP连接,所以我想我的应用程序出现在Android的分享菜单。

My App sends files(all mime Types) over a TCP connection and hence I wanted my app to appear in the Android Share menu.

我增加了以下意图过滤器到我的活动在的Andr​​oidManifest.xml

I added the following intent filters to my Activity in AndroidManifest.xml

<intent-filter ><!--intent filter for single file sharing-->
  <action android:name="android.intent.action.SEND" />
  <category android:name="android.intent.category.DEFAULT" />
  <data android:mimeType="*/*" />
</intent-filter>
<intent-filter ><!--intent filter for sharing multiple files-->
  <action android:name="android.intent.action.SEND_MULTIPLE" />
  <category android:name="android.intent.category.DEFAULT" />
  <data android:mimeType="*/*" />
</intent-filter>

现在我已将此添加活动这是要在点击分享行动启动

Now I added this to the Activity which is to be launched on clicking the Share Action

Intent intent = getIntent();
if (Intent.ACTION_SEND.equals(intent.getAction()))
{
 Uri uri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
 if (uri != null) {
    fileset = new HashSet();
    fileset.add(getPathfromUri(uri));
     }
 }
else if (Intent.ACTION_SEND_MULTIPLE.equals(intent.getAction()))
{
 ArrayList<Uri> uris= intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
 if (uris != null) {
        fileset = new HashSet();
        for(Uri uri : uris)                         
            {
            fileset.add(getPathfromUri(uri));
            }
        }
}

我用这种方法生成的文件的要被共享的绝对路径。

I use this method to generate the absolute paths of the Files that are to be shared.

public String getPathfromUri(Uri uri) {
 if(uri.toString().startsWith("file://")) 
       return uri.getPath();
 String[] projection = { MediaStore.Images.Media.DATA };
 Cursor cursor = managedQuery(uri, projection, null, null, null);
 startManagingCursor(cursor);
 int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
 cursor.moveToFirst();
 String path= cursor.getString(column_index);
 //cursor.close();
 return path;
}

以上方法得当检索图像/视频和其他files.Is有什么事,我已经错过了或者是有这样做的更好方法的绝对路径?

The above method properly retrieves the absolute path of Images/Videos and other files.Is there something that I have missed out or is there a better way of doing this?

除了共享菜单里,有一个发送通过在我的手机菜单。 屏幕截图

In Addition to the Share menu, there is a Send Via menu on my Phone.

有没有办法让我的应用程序进入这个名单?

Is there a way to get my App into this list?

推荐答案

我试图解决这个问题,我pretty的肯定,三星的库使用,通过该菜单分享一些自定义操作。考虑到所有列出的应用程序是$ pinstalled p $的人很明显,三星与所有列出的应用程序开发人员同意使用它的自定义的意图行动。

I tried to deal with this issue and I pretty sure that samsung's gallery uses some custom action for sharing through that menu. Taking into account that all the listed application are preinstalled ones it's obvious that Samsung agreed with all of the listed application developers to use it's custom intent action.

我也试图联系三星和他们还没有回答呢。

I have also tried to contact to Samsung and they haven't replied yet.

这篇关于最佳实践 - 将您的应用程序到Android共享菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆