編輯:關於Android編程
當用戶在系統相冊,點擊分享時,能通過我們自己的app,分享該圖片。
1.注冊
主要是在AndroidManifest.xml中,對activity注冊Intent-filter,如:
在Activity中,獲取Intent中的文本和圖片等。
void onCreate (Bundle savedInstanceState) {
...
// Get intent, action and 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 as being started from the home screen
}
...
}
void handleSendText(Intent intent) {
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
if (sharedText != null) {
// Update UI to reflect text being shared
}
}
void handleSendImage(Intent intent) {
Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
if (imageUri != null) {
// Update UI to reflect image being shared
}
}
void handleSendMultipleImages(Intent intent) {
ArrayList imageUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
if (imageUris != null) {
// Update UI to reflect multiple images being shared
}
}
簡單舉例: http://code.tutsplus.com/tutorials/android-sdk-receiving-data-from-the-send-intent--mobile-14878
更多交流,Android開發聯盟QQ群:272209595
Android熱補丁動態修復技術(三)—— 使用Javassist注入字節碼,完成熱補丁框架雛形(可使用)
一、關於CSDN mardown編輯器的坑 Android熱補丁動態修復技術(三)這篇博文其實在4月8日的晚上已經發布了,然後緊接著寫第四篇,但是我將(四)保存到草稿箱
Android模仿知乎的回答詳情頁的動畫效果
廢話不多說,咱們第一篇文章就是模仿“知乎”的回答詳情頁的動畫效果,先上個原版的效果圖,咱們就是要做出這個效果 在實現之前,
Activity生命周期實例講解
Activity中有7個與生命周期有關的函數。其中onCreated()是activity第一次被啟動時執行的,主要是初始化一些變量,onRestart()是
Android IPC之Messenger淺談
之前寫過一篇有關IPC之AIDL淺談的文章。今天再來介紹另一種IPC-Messenger。一、概述。首先看Messenger介紹, Reference to
Android初學者Eclispe環境啟動遇This Android SDK requires Android Developer Toolkit version 23.0.0 or above
當我們進行Android開發,配置安裝環境Eclispe&SDK