- 浏览: 2560436 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Android UI(5)Getting Started - Sharing Content
Sharing Content
Why reinvent functionality that isn't core to your application when it already exists in another application?
1. Sending Content to Other Apps
Send Text Content
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Here is an example.");
sendIntent.setType("text/plain");
startActivity(sendIntent);
Find an application to send the text. Sometimes if there are multiple applications can send text message, we can customize the chooser title
startActivity(Intent.createChooser(sendIntent, "Choose an Application"));
Send Binary Content
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, uriToImage);
shareIntent.setType("image/jpeg");
startActivity(shareIntent);
Send Multiple Pieces of Content
ArrayList<Uri> imageUris = new ArrayList<Uri>();
imageUris.add(imageUri1);
imageUris.add(imageUri2);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
shareIntent.setType("image/*");
2. Receiving Content from Other Apps
Update Your Manifest
<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>
This should be the intent filter for my activity.
Handle the Incoming Content in my Activity
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<Uri> imageUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
if (imageUris != null) {
// Update UI to reflect multiple images being shared
}
}
3. Adding an Easy Share Action
…snip...
References:
http://developer.android.com/training/sharing/index.html
Sharing Content
Why reinvent functionality that isn't core to your application when it already exists in another application?
1. Sending Content to Other Apps
Send Text Content
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Here is an example.");
sendIntent.setType("text/plain");
startActivity(sendIntent);
Find an application to send the text. Sometimes if there are multiple applications can send text message, we can customize the chooser title
startActivity(Intent.createChooser(sendIntent, "Choose an Application"));
Send Binary Content
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, uriToImage);
shareIntent.setType("image/jpeg");
startActivity(shareIntent);
Send Multiple Pieces of Content
ArrayList<Uri> imageUris = new ArrayList<Uri>();
imageUris.add(imageUri1);
imageUris.add(imageUri2);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris);
shareIntent.setType("image/*");
2. Receiving Content from Other Apps
Update Your Manifest
<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>
This should be the intent filter for my activity.
Handle the Incoming Content in my Activity
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<Uri> imageUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
if (imageUris != null) {
// Update UI to reflect multiple images being shared
}
}
3. Adding an Easy Share Action
…snip...
References:
http://developer.android.com/training/sharing/index.html
发表评论
-
ionic UI(4)ionic2 framework - basic and components and native
2016-03-24 02:33 1265ionic UI(4)ionic2 framework - b ... -
ionic UI(3)TypeScript - handbook
2016-03-22 23:21 642ionic UI(3)TypeScript - handboo ... -
ionic UI(2)ionic2 framework - TypeScript - tutorial
2016-03-22 06:52 1664ionic UI(2)ionic2 framework - T ... -
Parse and Heroku Service(3)Parse Server and Parse Dashboard
2016-03-22 06:30 974Parse and Heroku Service(3)Pars ... -
Parse and Heroku Service(2)Mail Templates and Push Notification
2016-03-22 02:45 588Parse and Heroku Service(2)Mail ... -
ionic UI(1)Introduction
2016-03-19 03:18 726ionic UI(1)Introduction 1 Inst ... -
Parse and Heroku Service(1)Heroku Installation and Play
2016-03-19 00:13 828Parse and Heroic Service(1)Hero ... -
Hybrid(5)Customize Meteor Directly Google Login
2015-09-01 02:33 915Hybrid(5)Customize Meteor Direc ... -
Hybrid(4)Favorite Places - Google Login
2015-09-01 02:02 1348Hybrid(4)Favorite Places - Goog ... -
Hybrid(3)More Meteor Example - Social
2015-08-11 05:04 762Hybrid(3)More Meteor Example - ... -
Hybrid(2)meteor Running Android and iOS
2015-07-28 23:59 1058Hybrid(2)meteor Running Android ... -
Create the Google Play Account
2015-07-18 06:42 1107Create the Google Play Account ... -
Secure REST API and Mobile(1)Document Read and Understand OAUTH2
2015-07-14 00:36 769Secure REST API and Mobile(1)Do ... -
Screen Size and Web Design
2015-07-11 01:11 733Screen Size and Web Design iPh ... -
Hybrid(1)ionic Cordova meteor
2015-06-25 05:49 475Hybrid(1)ionic Cordova meteor ... -
Android Fire Project(1)Recall Env and Knowledge
2015-02-11 12:28 696Android Fire Project(1)Recall ... -
Android Content Framework(1)Concept
2014-06-14 13:54 1090Android Content Framework(1)Con ... -
Feel Android Studio(1)Install and Update Android Studio
2014-04-11 03:12 2046Feel Android Studio(1)Install a ... -
IOS7 App Development Essentials(2)iBeacon
2014-03-05 05:55 897IOS7 App Development Essentials ... -
IOS7 App Development Essentials(1) Persistent Store
2014-03-05 05:54 1340IOS7 App Development Essentials ...
相关推荐
Android-android-ui-animation-components-and-libraries.zip,android ui库、组件和动画作者@ramotion-https://github.com/ramotion/swift-ui-animation-components-libraries,安卓系统是谷歌在2008年设计和制造的。...
•Android---UI篇---Tab Layout(选项卡布局) • •Andorid---UI篇---TableLayout(表格布局) • •Android---UI篇---RelativeLayout(相对布局) • •Android---UI篇---GridView(网格布局) • •Android---UI篇-...
《Android UI 测试框架详解——以android-ui-test-runner-master为例》 在移动应用开发中,UI测试是确保产品质量的关键环节。Android平台提供了多种测试工具,其中`android-ui-test-runner`是一个用于自动化测试...
Android-awesome-android-ui.zip,一份精选的android ui/ux库列表,安卓系统是谷歌在2008年设计和制造的。操作系统主要写在爪哇,C和C 的核心组件。它是在linux内核之上构建的,具有安全性优势。
android-support-core-ui-26.0.0-alpha1.jar
Android源码查看ui-闹钟-导航-pdf等.rar
Android UI设计内容简介: 创造一个统一外观,感觉完整的用户界面会增加你的产品附加价值。 精炼的图形风格也使用户觉得用户界面更加专业。 帮助你如何在应用界面的不同部分创造图标来匹配 Android 2.x框架下的普遍...
"ui-fabric-android"是一个专为Office和Office 365设计的前端框架,它针对Android平台进行了优化,旨在提供一致、高效的用户界面组件和设计系统。这个开源项目旨在帮助开发者构建与Office品牌相符的高质量应用程序,...
在Android开发中,支持库(Support Library)是Google提供的一系列API,用于向后兼容旧版本的Android系统,同时也引入了一些新的特性和组件。这里提到的`android-support-v4.jar`、`android-support-v13.jar`和`...
很多朋友对RollNavigationBar+SlidePageView如何设计业务界面感到疑惑,今天我专门写...了解详情可以看我的博客《android-整体UI设计-(滑动导航栏+滚动页面)》http://blog.csdn.net/swadair/article/details/7551609
强大的网络请求库,主要特征如下: 处理异步Http请求,并通过匿名内部类...Http请求均位于非UI线程,不会阻塞UI操作 通过线程池处理并发请求 处理文件上传、下载 响应结果自动打包JSON格式 自动处理连接断开时请求重连
新版Android开发教程+笔记七--基础UI编程1 新版Android开发教程+笔记八--基础UI编程2 新版Android开发教程+笔记九--基础UI编程3 新版Android开发教程+笔记十--基础UI编程4 新版Android开发教程+笔记十一--可视化UI...
开源项目推荐:Android UI Patterns 实现各种UI效果,含动画
Android-react-native-ui-lib.zip,用于react native的ui组件库,安卓系统是谷歌在2008年设计和制造的。操作系统主要写在爪哇,C和C 的核心组件。它是在linux内核之上构建的,具有安全性优势。
Android奇艺高清UI界面源代码-仅用于Android项目学习
Android--开发--奇艺高清UI界面源代码
20.[开源][安卓][翻页效果的UI组件]android-flip-master Aphid FlipView是一个能够实现Flipboard翻页效果的UI组件。
新版Android开发教程+笔记七--基础UI编程1.pdf 新版Android开发教程+笔记八--基础UI编程2.pdf 新版Android开发教程+笔记九--基础UI编程3.pdf 新版Android开发教程+笔记十--基础UI编程4.pdf 新版Android开发教程+笔记...
Android系统定制-SystemUI-下拉状态栏快捷设置新增选项(自动亮度&静音)_Patch 文章链接:https://blog.csdn.net/qq_33750826/article/details/122829104
在Android开发中,`android-support-v7-appcompat.jar` 和 `android-support-v4.jar` 是两个非常重要的库文件,它们提供了对旧版本Android系统的重要支持和功能扩展。 首先,`android-support-v7-appcompat.jar` 是...