第一个demo:Intent,根据指定的类型,枚举出所有符合条件的activity,让用户选择
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("audio/*");
startActivity(Intent.createChooser(intent, "Select music"));
效果图:
第二个demo:为activity创建快捷方式:
1、首先需要在manifest中为activity配置action
<action android:name="android.intent.action.CREATE_SHORTCUT"/>
2、实现代码
Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
shortcutIntent.setClassName(this, this.getClass().getName());
shortcutIntent.putExtra(EXTRA_KEY, "ApiDemos Provided This Shortcut");
// Then, set up the container intent (the response to the caller)
Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_shortcuts_name));
Parcelable iconResource = Intent.ShortcutIconResource.fromContext(
this,R.drawable.launcher);
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
// Now, return the result to the launcher
setResult(RESULT_OK, intent);
代码中设置了快捷方式打开的activity,以及快捷方式的图片、名称,需要特别注意的是使用项目内的drawable资源需要使用Intent.ShortcutIconResource来包裹下。
如果使用bitmap可以直接放入就可以了
我们可以给任何activity添加快捷方式,方便用户快捷的使用某一常用功能
效果如:
- 大小: 61.4 KB
- 大小: 131 KB
- 大小: 452.4 KB
分享到:
相关推荐
<intent-filter></intent-filter> <meta-data/> </activity-alias> <intent-filter></intent-filter> <meta-data/> </service> <intent-filter></intent-filter> <meta-data/> </receiver> <grant-...
android intent和intent action大全
Android Shortcuts Example app for shortcuts in design library v25 Demo Manifest Add meta-data before `````` tag in Manifest.xml Add Shortcut To add or edit a new shotcut, go to /res/xml/shortcuts....
android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="ReviewList" android:label="@string/app_name_reviews"> <intent-filter> ...
《android 2.3应用开发实战》包括 android介绍、开发环境、应用开发平台、活动程序 activity、意图方法 intent、widget、layout窗体布局、menu菜单、sqlite、service服务程序、应用程序国际化、webview、app widget...
android 项目 开发 demo <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.demo" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:...
React Native Android模块使用Android的Intent操作将文本发送到可共享的应用程序或拨打电话或打开第三方应用程序。 当您需要在Android设备中的应用之间共享一些文本,并且如果您有有效的电话号码直接拨打电话(如果...
NULL 博文链接:https://ln-ydc.iteye.com/blog/1905353
android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> android:name="android.appwidget.action.APPWIDGET_CONFIGURE" /> </intent-filter> </activity> android:name...
android 网格组件9宫格,GridView展示数据 3*3排列显示。鼠标点击其中一个网格 会触发事件,并传递参数
android intent
Android入门开发实例--Toast、Notification、Intent应用
Android自学笔记-14-意图(Intent)
把其它app 放在assets/ 下面打包, 通过系统调用安装这个app //申请安装未知应用权限 Uri packageURI = Uri.parse("package:" + mContext.getPackageName()); Intent intent = new Intent(Settings.ACTION_...
React本机接收共享意图 一个React Native插件,使React Native应用程序能够从另一个应用程序接收共享的照片,视频,文本,URL或任何其他文件类型。 此外,还支持iOS Share扩展并... 注意: Ios and Android on Debb
《android 2.3应用开发实战》包括 android介绍、开发环境、应用开发平台、活动程序 activity、意图方法intent、widget、layout窗体布局、menu菜单、sqlite、service服务程序、应用程序国际化、webview、appwidget...
9 Communicating intent: Developing a self-driving language 10 Delivery of the future: Designing self-driving vehicle customer experiences 11 City solutions: getting to know the streets of Miami-Dade ...
android edittext不弹出软键盘三种方法“: 方法一: 在AndroidMainfest.xml中选择哪个activity,设置... <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
Android状态保存、用户偏好设置保存、通过universal_image_loder网络加载图片并做图片缓存处理Demo 1、将universal-image-loder...jar包放入项目的libs文件里,并引入。 2、将MyApplication.java类放入项目,具体...