linux和android学习,android学习笔记
在红皮书第七章(p127)Using Intents and the Phone Dialer中
有个程序是用intent打开Dialer这个application其中有几行代码是这样写的
Intent DialIntent = new Intent(Intent.DIAL_ACTION,Uri.parse("tel:5551212"));DialIntent.setLaunchFlags(Intent.NEW_TASK_LAUNCH );
其中第一行中的Intent.DIAL_ACTION在eclipse中出现错误(Intent.DIAL_ACTION can not be resolved),
需要将其改为Intent.ACTION_DIAL.
第二行代码中的Intent.NEW_TASK_LAUNCH也有错误(Intent.NEW_TASK_LAUNCH can not be resolved)
需要将其改为 DialIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
关于Uri.parse(String uristring)方法
public static Uri parse(String uriString)
Creates a Uri which parses the given encoded URI string.
Parameters
uriString an RFC 3296-compliant, encoded URI
Returns
* Uri for this given uri string
Throws
NullPointerException if uriString is null
这个方法是将uristring转化为Uri形式,并返回Uri形式的引用。如果Uristring为null将产生异常。
在android文档中,没有setLaunchFlags(int flags)这个方法,但却有setFlags(int flags)方法。
通过查android文档我们可以看到setfFlags(int flags)方法的定义如下:
public Intent setFlags(int flags)
Set special flags controlling how this intent is handled. Most values here depend on the type of component being executed by the Intent,
specifically the FLAG_ACTIVITY_* flags are all for use with Context.startActivity() and the FLAG_RECEIVER_* flags are all for use
with Context.sendBroadcast().
See the Application Model documentation for important information on how some of these options impact the behavior of your application.
Parameters
flags The desired flags.
Returns
* Returns the same Intent object, for chaining multiple calls into a single statement.
See Also
* getFlags()* addFlags(int)* FLAG_GRANT_READ_URI_PERMISSION* FLAG_GRANT_WRITE_URI_PERMISSION* FLAG_DEBUG_LOG_RESOLUTION* FLAG_FROM_BACKGROUND* FLAG_ACTIVITY_RESET_TASK_IF_NEEDED* FLAG_ACTIVITY_BROUGHT_TO_FRONT* FLAG_ACTIVITY_CLEAR_TOP* FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS* FLAG_ACTIVITY_FORWARD_RESULT* FLAG_ACTIVITY_MULTIPLE_TASK* FLAG_ACTIVITY_NEW_TASK* FLAG_ACTIVITY_NO_HISTORY* FLAG_ACTIVITY_SINGLE_TOP* FLAG_RECEIVER_REGISTERED_ONLY
可以看出在以上的flags常量中没有NEW_TASK_LAUNCH.
public static final int FLAG_ACTIVITY_NEW_TASK
If set, this activity will become the start of a new task on this history stack.
A task (from the activity that started it to the next task activity) defines an
atomic group of activities that the user can move to. Tasks can be moved to the
foreground and background; all of the activities inside of a particular task
always remain in the same order. See the Application Model documentation for
more details on tasks.
This flag is generally used by activities that want to present a "launcher" style
behavior: they give the user a list of separate things that can be done, which
otherwise run completely independently of the activity launching them.
When using this flag, if a task is already running for the activity you are now
starting, then a new activity will not be started; instead, the current task will
simply be brought to the front of the screen with the state it was last in. See
FLAG_ACTIVITY_MULTIPLE_TASK for a flag to disable this behavior.
This flag can not be used when the caller is requesting a result from the activity being launched.
Constant Value: 268435456 (0x10000000)
最终代码:
package com.android.AndroidPhoneDalier;
import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.net.Uri;
public class AndroidPhoneDalier extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent DialIntent = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:88161644"));
DialIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(DialIntent);
}
}
各种FlAG定义
public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT
This flag is not normally set by application code, but set for
you by the system as described in the launchMode documentation for the singleTask mode.
Constant Value: 4194304 (0x00400000)
public static final int FLAG_ACTIVITY_CLEAR_TOP
If set, and the activity being launched is already running in
the current task, then instead of launching a new instance of
that activity, all of the other activities on top of it will
be closed and this Intent will be delivered to the (now on top)
old activity as a new Intent.
For example, consider a task consisting of the activities: A, B, C, D. If D calls
startActivity() with an Intent that resolves to the component of activity B,
then C and D will be finished and B receive the given Intent, resulting in the stack now being: A, B.
The currently running instance of task B in the above example will either
receiving the new intent you are starting here in its onNewIntent() method,
or be itself finished and restarting with the new intent. If it has declared
its launch mode to be "multiple" (the default) it will be finished and
re-created; for all other launch modes it will receive the Intent in the current instance.
This launch mode can also be used to good effect in conjunction
with FLAG_ACTIVITY_NEW_TASK: if used to start the root activity of a task,
it will bring any currently running instance of that task to the foreground,
and then clear it to its root state. This is especially useful, for example,
when launching an activity from the notification manager.
See the Application Model documentation for more details on tasks.
Constant Value: 67108864 (0x04000000)
public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
If set, the new activity is not kept in the list of recently
launched activities.
Constant Value: 8388608 (0x00800000)
public static final int FLAG_ACTIVITY_FORWARD_RESULT
If set and this intent is being used to launch a new activity
from an existing one, then the reply target of the existing
activity will be transfered to the new activity. This way the
new activity can call setResult(int) and have that result sent
back to the reply target of the original activity.
Constant Value: 33554432 (0x02000000)
public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
If set, this activity is being launched from history (longpress home key).
Constant Value: 1048576 (0x00100000)
public static final int FLAG_ACTIVITY_MULTIPLE_TASK
Do not use this flag unless you are implementing your own top-level
application launcher. Used in conjunction with FLAG_ACTIVITY_NEW_TASK
to disable the behavior of bringing an existing task to the foreground.
When set, a new task is always started to host the Activity for the Intent,
regardless of whether there is already an existing task running the same thing.
Because the default system does not include graphical task management,
you should not use this flag unless you provide some way for a user to
return back to the tasks you have launched.
This flag is ignored if FLAG_ACTIVITY_NEW_TASK is not set.
See the Application Model documentation for more details on tasks.
Constant Value: 134217728 (0x08000000)
public static final int FLAG_ACTIVITY_NEW_TASK
If set, this activity will become the start of a new
task on this history stack. A task (from the activity that
started it to the next task activity) defines an atomic group
of activities that the user can move to. Tasks can be moved to
the foreground and background; all of the activities inside of a
particular task always remain in the same order. See the Application
Model documentation for more details on tasks.
This flag is generally used by activities that want to present
a "launcher" style behavior: they give the user a list of separate
things that can be done, which otherwise run completely independently
of the activity launching them.
When using this flag, if a task is already running for the activity you
are now starting, then a new activity will not be started; instead, the
current task will simply be brought to the front of the screen with the
state it was last in. See FLAG_ACTIVITY_MULTIPLE_TASK for a flag to disable this behavior.
This flag can not be used when the caller is requesting a result from the activity being launched.
Constant Value: 268435456 (0x10000000)
public static final int FLAG_ACTIVITY_NO_HISTORY
If set, the new activity is not kept in the history stack.
Constant Value: 1073741824 (0x40000000)
public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP
If set and this intent is being used to launch a new activity
from an existing one, the current activity will not be counted
as the top activity for deciding whether the new intent should be
delivered to the top instead of starting a new one. The previous
activity will be used as the top, with the assumption being that
the current activity will finish itself immediately.
Constant Value: 16777216 (0x01000000)
public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
If set, and this activity is either being started in a new task or
bringing to the top an existing task, then it will be launched as
the front door of the task. This will result in the application of
any affinities needed to have that task in the proper state
(either moving activities to or from it), or simply resetting that
task to its initial state if needed.
Constant Value: 2097152 (0x00200000)
public static final int FLAG_ACTIVITY_SINGLE_TOP
If set, the activity will not be launched if it is
already running at the top of the history stack.
Constant Value: 536870912 (0x20000000)
public static final int FLAG_DEBUG_LOG_RESOLUTION
A flag you can enable for debugging: when set, log messages
will be printed during the resolution of this intent to show
you what has been found to create the final resolved list.
Constant Value: 8 (0x00000008)
public static final int FLAG_FROM_BACKGROUND
Can be set by the caller to indicate that this Intent is
coming from a background operation, not from direct user interaction.
Constant Value: 4 (0x00000004)
public static final int FLAG_GRANT_READ_URI_PERMISSION
If set, the recipient of this Intent will be granted permission
to perform read operations on the Uri in the Intent's data.
Constant Value: 1 (0x00000001)
public static final int FLAG_GRANT_WRITE_URI_PERMISSION
If set, the recipient of this Intent will be granted permission
to perform write operations on the Uri in the Intent's data.
Constant Value: 2 (0x00000002)
public static final int FLAG_RECEIVER_REGISTERED_ONLY
If set, when sending a broadcast only registered receivers will be
called -- no BroadcastReceiver components will be launched.
Constant Value: 1073741824 (0x40000000)
linux和android学习,android学习笔记相关推荐
- Android底层开发学习笔记 第一天
今天,开始学习Android底层的开发.(注:我是新手小白,纯粹学习笔记,大神们可以直接略过了) 第一部分 编译运行我的第一个Android system. 准备工作: 下载源码:包括u-boot源码 ...
- Android 基础视频学习笔记 1 (完结)
综述: 1 1G-4G的介绍:(了解) 1G 大哥大 2G 小灵通 gsm 发短信 wap.baidu.c ...
- Android Studio Notes/学习笔记
学习视频来源:https://www.bilibili.com/video/BV1jW411375J?from=search&seid=16068849106535436916 文章目录 小知 ...
- 嵌入式Linux+Android学习路线图+学习进度
嵌入式Linux+Android学习路线图 转载:http://www.100ask.net/a/howtostudy/ 重拾Linux驱动,就按照百问网的步骤一步一步做,看自己最后能坚持到哪一步!! ...
- Android编译及编译脚本、Android构建基础学习笔记
Android编译及编译脚本.Android构建基础学习笔记 Android编译及编译脚本 概述 Android.mk转换成Android.bp 例子(简单Android.mk文件转Android.b ...
- Android逆向 学习Android安全和逆向开发的路线总结,啃下这些Framework技术笔记
此篇整理了最完整的–Android逆向学习线路知识体系.希望给迷糊的入门者指出一个明确的方向. 真心建议:先正向开发几年再搞逆向吧--正向都不会破解的是啥?不看代码只会脱壳?只会xposed ?远远不 ...
- Android 应用开发学习笔记(2 of 2,from hitwh)
Android 应用开发 注意!由于文章图片是通过typora一键上传图片实现,该功能还存在bug,容易导致图片顺序混乱,文章(1 of 2)开头提供了原版文章的 pdf 资源下载,推荐下载 pdf ...
- Android开发技术学习笔记
目标:全面学习知识点,能理解原理,多实战练习并做笔记与总结学习心得 Android开发技术学习笔记记录如下: Android开发Google的官网https://developer.android.g ...
- Android应用开发学习笔记之事件处理
作者:刘昊昱 博客:http://blog.csdn.net/liuhaoyutz Android提供的事件处理机制分为两类:一是基于监听的事件处理:二是基于回调的事件处理.对于基于监听的事件处理,主 ...
- android NFC 开发学习笔记(1)
由于工作需求,最近在研究android nfc开发,借鉴了很对大神的文章在此记录自己的学习过程: 大家学习android开发建议首选android开发文档,该文档在你下载的sdk中,路径:/sdk/d ...
最新文章
- 使用java9的uuid生成方式,让uuid生成速度提升一个档次...
- Qt之QObjectCleanupHandler使用介绍
- 防止UI界面被输入法遮挡(画面随输入法自适应)
- leetcode - 813. 最大平均值和的分组
- Android中Parcelable和Serializable接口用法
- Mac OS X 更新JAMF域控配置
- python接口自动化4-绕过验证码登录(cookie) (转载)
- php 活动报名,活动报名小程序 - 微信小程版的活动在线报名,支持付费活动发布! – 基于ThinkPHP和Bootstrap的极速后台开发框架...
- Proteus十字路口交通灯
- ghost版32位win10系统,win10系统下载地址
- sqlldr 参数介绍
- 2021年中国道路交通事故情况分析(附机动车保有量、交通事故发生数量、死亡人数、受伤人数、直接经济损失)[图]
- linux skype 4.3,在Arch Linux上安装Skype 4.3(最新版本)
- php美颜相机,手机照片美化软件哪个好|美颜相机官方版-官方版
- Easy Less生成.ttss后缀文件的配置
- 图神经网络(CNN)一
- 梦三花重金修改服务器,3月6日一梦江湖游戏更新公告
- pwlink用作USB转TTL,进入HC-05的AT模式
- 4 个 Linux 技巧,你值得拥有
- 数据结构(一):数据结构的概述