android - How can make "share via" intent EXCEPT my app list on it -
i'm working on text base app can share parts other apps in share via , accept shared text apps. when want share data, app appeared in share via screen, how can remove app screen,though want when other app share text , in "share via" screen , app should place there. here codes :
intent sharingintent = new intent(android.content.intent.action_send); sharingintent.settype("text/plain"); string sharebody = "here share content"; sharingintent.putextra(android.content.intent.extra_text, sharebody); startactivity(intent.createchooser(sharingintent, "share via"));
and also:
<activity android:name=".testactivity" android:label="@string/app_name"> <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.send" /> <category android:name="android.intent.category.default" /> <data android:mimetype="text/plain" /> </intent-filter> </activity>
thanks.
i think looking receiving simple data other apps. if yes should use android:mimetype condition different type of data. put below code in manifest activity.
<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>
handle incoming content
void oncreate (bundle savedinstancestate) { ... // intent, action , mime type intent intent = getintent(); string action = intent.getaction(); string type = intent.gettype(); if (intent.action_send.equals(action) && type != null) { if ("text/plain".equals(type)) { handlesendtext(intent); // handle text being sent } else if (type.startswith("image/")) { handlesendimage(intent); // handle single image being sent } } else if (intent.action_send_multiple.equals(action) && type != null) { if (type.startswith("image/")) { handlesendmultipleimages(intent); // handle multiple images being sent } } else { // handle other intents, such being started home screen } ...
}
source : http://developer.android.com/training/sharing/receive.html
Comments
Post a Comment