मेरा ऐप एक टीसीपी कनेक्शन पर फाइलें (सभी माइम प्रकार) भेजता है और इसलिए मैं चाहता हूं कि मेरा ऐप एंड्रॉइड शेयर मेनू में दिखाई दे।बेस्ट प्रैक्टिस - एंड्रॉइड शेयर मेनू में अपनी ऐप जोड़ना
मैं 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>
में मेरी गतिविधि के लिए निम्न आशय फ़िल्टर जोड़े अब मैं Activity
जो शेयर कार्रवाई
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));
}
}
}
मैं इस विधि का उपयोग क्लिक करने पर शुरू किया जाना है पर जोड़ा साझा की जाने वाली फ़ाइलों के पूर्ण पथ उत्पन्न करने के लिए।
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 कुछ है कि मैं चूक या वहाँ ऐसा करने का एक बेहतर तरीका है है निरपेक्ष पथ को पुन: प्राप्त?
Share
मेनू में जोड़ने के लिए, मेरे फोन पर Send Via
मेनू है।
क्या इस ऐप में मेरी ऐप प्राप्त करने का कोई तरीका है?
AFAIK, केवल एक "साझा करें" मेनू है। यह सूची कस्टम हो सकती है, क्योंकि मैं फेसबुक, जी +, ट्विटर को उस सूची में दिखाने की उम्मीद करता हूं अन्यथा यदि आपके पास इंस्टॉल हैं। –
मैं भी ऐसा सोचता हूं क्योंकि सूची में मौजूद लोग डिफ़ॉल्ट एप्लिकेशन हैं जो रोम के साथ आते हैं। सैमसंग ने जो कुछ जोड़ा है वह होना चाहिए :) – coderplus
स्पष्टीकरण के लिए धन्यवाद क्या आपने इसे आजमाया? intent.setType ("*/*"); – jzafrilla