最佳实践-将应用程序添加到Android共享菜单

最佳实践-将应用程序添加到Android共享菜单,android,android-intent,Android,Android Intent,我的应用程序通过TCP连接发送文件(所有mime类型),因此我希望我的应用程序出现在Android共享菜单中 我在AndroidManifest.xml <intent-filter ><!--intent filter for single file sharing--> <action android:name="android.intent.action.SEND" /> <category android:name="androi

我的应用程序通过TCP连接发送文件(所有mime类型),因此我希望我的应用程序出现在Android共享菜单中

我在
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>
我使用此方法生成要共享的文件的绝对路径

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;
}
上述方法正确地检索图像/视频和其他文件的绝对路径。是否有我遗漏的内容,或者有更好的方法

除了
Share
菜单外,我的手机上还有
Send Via
菜单。


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

我试图解决这个问题,我很确定三星的gallery会使用一些自定义操作通过该菜单进行共享。考虑到所有列出的应用程序都是预装的,很明显,三星同意所有列出的应用程序开发人员使用它的定制意图操作


我也试着联系三星,但他们还没有回复。

我在这里概述了如何进入菜单:

基本上就是有你的mimetype/:



如果你这样做,但它没有显示,这意味着他们正在使用一个意向菜单,这是一个自定义共享列表,因此你不能强行进入。

我认为你是在从应用程序外部共享图像。请在intentfiler中定义minetype。在我这边工作得很好

<activity
            android:name=".SharePhotoFromOutSide"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" >
            <intent-filter>
                <action android:name="android.intent.action.SEND" />

                <category android:name="android.intent.category.DEFAULT" />

                <data android:mimeType="photo/*" />
            </intent-filter>
        </activity>


AFAIK,这里只有一个“共享”菜单。该列表可能是定制的,因为我希望Facebook、G+、Twitter会出现在该列表中,否则,如果您安装了它们的话。我也这么认为,因为列表中的那些都是随ROM附带的默认应用程序。这一定是三星添加的:)感谢您的澄清。您尝试过这个吗?intent.setType(“/”);我认为你的过滤器和我的一样,除了mimeType。我的显示所有文件类型的共享菜单。我最初的问题中的菜单是一个定制的三星菜单,我不认为仅仅通过修改清单就可以进入其中。mimeType
photo/*
是否存在?如果我只是尝试共享图片-/定义所有类型的文件,我会使用
image/*
,但是你可以使用photo/*从应用程序外部共享照片。它在矿井边工作得很好。固定的,是旧的领域
        <intent-filter>
            <action android:name="android.intent.action.GET_CONTENT" />

            <category android:name="android.intent.category.DEFAULT" />

            <data android:mimeType="*/*" />
        </intent-filter>
<activity
            android:name=".SharePhotoFromOutSide"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" >
            <intent-filter>
                <action android:name="android.intent.action.SEND" />

                <category android:name="android.intent.category.DEFAULT" />

                <data android:mimeType="photo/*" />
            </intent-filter>
        </activity>