Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mmm-rain
AndroidUtilCode
提交
06e577c4
A
AndroidUtilCode
项目概览
mmm-rain
/
AndroidUtilCode
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
AndroidUtilCode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
06e577c4
编写于
5月 15, 2018
作者:
B
Blankj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
see 05/15 log
上级
7a7b08d1
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
348 addition
and
7 deletion
+348
-7
README-CN.md
README-CN.md
+1
-1
README.md
README.md
+1
-1
app/build.gradle
app/build.gradle
+1
-1
build.gradle
build.gradle
+2
-2
update_log.md
update_log.md
+1
-0
utilcode/README-CN.md
utilcode/README-CN.md
+2
-1
utilcode/README.md
utilcode/README.md
+2
-1
utilcode/src/main/java/com/blankj/utilcode/util/ActivityUtils.java
...src/main/java/com/blankj/utilcode/util/ActivityUtils.java
+338
-0
未找到文件。
README-CN.md
浏览文件 @
06e577c4
...
...
@@ -41,7 +41,7 @@
[
logo
]:
https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
[
aucsvg
]:
https://img.shields.io/badge/AndroidUtilCode-v1.15.
0
-brightgreen.svg
[
aucsvg
]:
https://img.shields.io/badge/AndroidUtilCode-v1.15.
1
-brightgreen.svg
[
auc
]:
https://github.com/Blankj/AndroidUtilCode
[
apisvg
]:
https://img.shields.io/badge/API-14+-brightgreen.svg
...
...
README.md
浏览文件 @
06e577c4
...
...
@@ -41,7 +41,7 @@ If this project helps you a lot and you want to support the project's developmen
[
logo
]:
https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
[
aucsvg
]:
https://img.shields.io/badge/AndroidUtilCode-v1.15.
0
-brightgreen.svg
[
aucsvg
]:
https://img.shields.io/badge/AndroidUtilCode-v1.15.
1
-brightgreen.svg
[
auc
]:
https://github.com/Blankj/AndroidUtilCode
[
apisvg
]:
https://img.shields.io/badge/API-14+-brightgreen.svg
...
...
app/build.gradle
浏览文件 @
06e577c4
...
...
@@ -56,7 +56,7 @@ dependencies {
// LeakCanary
debugImplementation
"com.squareup.leakcanary:leakcanary-android:$leakcanary_version"
releaseImplementation
"com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary_version"
// implementation 'com.blankj:utilcode:1.15.
0
'
// implementation 'com.blankj:utilcode:1.15.
1
'
}
build.gradle
浏览文件 @
06e577c4
...
...
@@ -44,8 +44,8 @@ ext {
min_sdk_version
=
14
target_sdk_version
=
27
version_code
=
1
_015_00
0
version_name
=
'1.15.
0
'
// E.g 1.9.72 => 1,009,072
version_code
=
1
_015_00
1
version_name
=
'1.15.
1
'
// E.g 1.9.72 => 1,009,072
// App dependencies
support_version
=
'27.1.0'
...
...
update_log.md
浏览文件 @
06e577c4
*
18/05/15 新增 MetaDataUtils 和 ActivityUtils#startActivityForResult,发布 1.15.1 版本
*
18/05/08 新增 ResourceUtils,发布 1.15.0 版本
*
18/05/07 修复 ZipUtils 漏洞,发布 1.14.4 版本
*
18/05/03 修复 ToastUtils 默认字体大小问题,发布 1.14.3 版本
...
...
utilcode/README-CN.md
浏览文件 @
06e577c4
...
...
@@ -2,7 +2,7 @@
Gradle:
```
groovy
implementation
'com.blankj:utilcode:1.15.
0
'
implementation
'com.blankj:utilcode:1.15.
1
'
```
...
...
@@ -25,6 +25,7 @@ U needn't do anything, because I add `consumerProguardFiles 'proguard-rules.pro'
```
isActivityExists : 判断 Activity 是否存在
startActivity : 启动 Activity
startActivityForResult : 启动 Activity 为返回结果
startActivities : 启动多个 Activity
startHomeActivity : 回到桌面
getActivityList : 获取 Activity 栈链表
...
...
utilcode/README.md
浏览文件 @
06e577c4
...
...
@@ -2,7 +2,7 @@
Gradle:
```
groovy
implementation
'com.blankj:utilcode:1.15.
0
'
implementation
'com.blankj:utilcode:1.15.
1
'
```
...
...
@@ -25,6 +25,7 @@ U needn't do anything, because I add `consumerProguardFiles 'proguard-rules.pro'
```
isActivityExists
startActivity
startActivityForResult
startActivities
startHomeActivity
getActivityList
...
...
utilcode/src/main/java/com/blankj/utilcode/util/ActivityUtils.java
浏览文件 @
06e577c4
...
...
@@ -597,6 +597,321 @@ public final class ActivityUtils {
}
}
/**
* Start the activity.
*
* @param activity The activity.
* @param clz The activity class.
* @param requestCode if >= 0, this code will be returned in
* onActivityResult() when the activity exits.
*/
public
static
void
startActivityForResult
(
@NonNull
final
Activity
activity
,
@NonNull
final
Class
<?
extends
Activity
>
clz
,
final
int
requestCode
)
{
startActivityForResult
(
activity
,
null
,
activity
.
getPackageName
(),
clz
.
getName
(),
requestCode
,
null
);
}
/**
* Start the activity.
*
* @param activity The activity.
* @param clz The activity class.
* @param requestCode if >= 0, this code will be returned in
* onActivityResult() when the activity exits.
* @param options Additional options for how the Activity should be started.
*/
public
static
void
startActivityForResult
(
@NonNull
final
Activity
activity
,
@NonNull
final
Class
<?
extends
Activity
>
clz
,
final
int
requestCode
,
final
Bundle
options
)
{
startActivityForResult
(
activity
,
null
,
activity
.
getPackageName
(),
clz
.
getName
(),
requestCode
,
options
);
}
/**
* Start the activity.
*
* @param activity The activity.
* @param clz The activity class.
* @param requestCode if >= 0, this code will be returned in
* onActivityResult() when the activity exits.
* @param sharedElements The names of the shared elements to transfer to the called
* Activity and their associated Views.
*/
public
static
void
startActivityForResult
(
@NonNull
final
Activity
activity
,
@NonNull
final
Class
<?
extends
Activity
>
clz
,
final
int
requestCode
,
final
View
...
sharedElements
)
{
startActivityForResult
(
activity
,
null
,
activity
.
getPackageName
(),
clz
.
getName
(),
requestCode
,
getOptionsBundle
(
activity
,
sharedElements
));
}
/**
* Start the activity.
*
* @param activity The activity.
* @param clz The activity class.
* @param requestCode if >= 0, this code will be returned in
* onActivityResult() when the activity exits.
* @param enterAnim A resource ID of the animation resource to use for the
* incoming activity.
* @param exitAnim A resource ID of the animation resource to use for the
* outgoing activity.
*/
public
static
void
startActivityForResult
(
@NonNull
final
Activity
activity
,
@NonNull
final
Class
<?
extends
Activity
>
clz
,
final
int
requestCode
,
@AnimRes
final
int
enterAnim
,
@AnimRes
final
int
exitAnim
)
{
startActivityForResult
(
activity
,
null
,
activity
.
getPackageName
(),
clz
.
getName
(),
requestCode
,
getOptionsBundle
(
activity
,
enterAnim
,
exitAnim
));
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
JELLY_BEAN
)
{
activity
.
overridePendingTransition
(
enterAnim
,
exitAnim
);
}
}
/**
* Start the activity.
*
* @param extras The Bundle of extras to add to this intent.
* @param activity The activity.
* @param clz The activity class.
* @param requestCode if >= 0, this code will be returned in
* onActivityResult() when the activity exits.
*/
public
static
void
startActivityForResult
(
@NonNull
final
Bundle
extras
,
@NonNull
final
Activity
activity
,
@NonNull
final
Class
<?
extends
Activity
>
clz
,
final
int
requestCode
)
{
startActivityForResult
(
activity
,
extras
,
activity
.
getPackageName
(),
clz
.
getName
(),
requestCode
,
null
);
}
/**
* Start the activity.
*
* @param extras The Bundle of extras to add to this intent.
* @param activity The activity.
* @param clz The activity class.
* @param requestCode if >= 0, this code will be returned in
* onActivityResult() when the activity exits.
* @param options Additional options for how the Activity should be started.
*/
public
static
void
startActivityForResult
(
@NonNull
final
Bundle
extras
,
@NonNull
final
Activity
activity
,
@NonNull
final
Class
<?
extends
Activity
>
clz
,
final
int
requestCode
,
@NonNull
final
Bundle
options
)
{
startActivityForResult
(
activity
,
extras
,
activity
.
getPackageName
(),
clz
.
getName
(),
requestCode
,
options
);
}
/**
* Start the activity.
*
* @param extras The Bundle of extras to add to this intent.
* @param activity The activity.
* @param clz The activity class.
* @param requestCode if >= 0, this code will be returned in
* onActivityResult() when the activity exits.
* @param sharedElements The names of the shared elements to transfer to the called
* Activity and their associated Views.
*/
public
static
void
startActivityForResult
(
@NonNull
final
Bundle
extras
,
@NonNull
final
Activity
activity
,
@NonNull
final
Class
<?
extends
Activity
>
clz
,
final
int
requestCode
,
final
View
...
sharedElements
)
{
startActivityForResult
(
activity
,
extras
,
activity
.
getPackageName
(),
clz
.
getName
(),
requestCode
,
getOptionsBundle
(
activity
,
sharedElements
));
}
/**
* Start the activity.
*
* @param extras The Bundle of extras to add to this intent.
* @param activity The activity.
* @param clz The activity class.
* @param requestCode if >= 0, this code will be returned in
* onActivityResult() when the activity exits.
* @param enterAnim A resource ID of the animation resource to use for the
* incoming activity.
* @param exitAnim A resource ID of the animation resource to use for the
* outgoing activity.
*/
public
static
void
startActivityForResult
(
@NonNull
final
Bundle
extras
,
@NonNull
final
Activity
activity
,
@NonNull
final
Class
<?
extends
Activity
>
clz
,
final
int
requestCode
,
@AnimRes
final
int
enterAnim
,
@AnimRes
final
int
exitAnim
)
{
startActivityForResult
(
activity
,
extras
,
activity
.
getPackageName
(),
clz
.
getName
(),
requestCode
,
getOptionsBundle
(
activity
,
enterAnim
,
exitAnim
));
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
JELLY_BEAN
)
{
activity
.
overridePendingTransition
(
enterAnim
,
exitAnim
);
}
}
/**
* Start the activity for result.
*
* @param activity The activity.
* @param extras The Bundle of extras to add to this intent.
* @param pkg The name of the package.
* @param cls The name of the class.
* @param requestCode if >= 0, this code will be returned in
* onActivityResult() when the activity exits.
*/
public
static
void
startActivityForResult
(
@NonNull
final
Bundle
extras
,
@NonNull
final
Activity
activity
,
@NonNull
final
String
pkg
,
@NonNull
final
String
cls
,
final
int
requestCode
)
{
startActivityForResult
(
activity
,
extras
,
pkg
,
cls
,
requestCode
,
null
);
}
/**
* Start the activity for result.
*
* @param extras The Bundle of extras to add to this intent.
* @param activity The activity.
* @param pkg The name of the package.
* @param cls The name of the class.
* @param requestCode if >= 0, this code will be returned in
* onActivityResult() when the activity exits.
* @param options Additional options for how the Activity should be started.
*/
public
static
void
startActivityForResult
(
@NonNull
final
Bundle
extras
,
@NonNull
final
Activity
activity
,
@NonNull
final
String
pkg
,
@NonNull
final
String
cls
,
final
int
requestCode
,
final
Bundle
options
)
{
startActivityForResult
(
activity
,
extras
,
pkg
,
cls
,
requestCode
,
options
);
}
/**
* Start the activity for result.
*
* @param extras The Bundle of extras to add to this intent.
* @param activity The activity.
* @param pkg The name of the package.
* @param cls The name of the class.
* @param requestCode if >= 0, this code will be returned in
* onActivityResult() when the activity exits.
* @param sharedElements The names of the shared elements to transfer to the called
* Activity and their associated Views.
*/
public
static
void
startActivityForResult
(
@NonNull
final
Bundle
extras
,
@NonNull
final
Activity
activity
,
@NonNull
final
String
pkg
,
@NonNull
final
String
cls
,
final
int
requestCode
,
final
View
...
sharedElements
)
{
startActivityForResult
(
activity
,
extras
,
pkg
,
cls
,
requestCode
,
getOptionsBundle
(
activity
,
sharedElements
));
}
/**
* Start the activity for result.
*
* @param extras The Bundle of extras to add to this intent.
* @param pkg The name of the package.
* @param cls The name of the class.
* @param requestCode if >= 0, this code will be returned in
* onActivityResult() when the activity exits.
* @param enterAnim A resource ID of the animation resource to use for the
* incoming activity.
* @param exitAnim A resource ID of the animation resource to use for the
* outgoing activity.
*/
public
static
void
startActivityForResult
(
@NonNull
final
Bundle
extras
,
@NonNull
final
Activity
activity
,
@NonNull
final
String
pkg
,
@NonNull
final
String
cls
,
final
int
requestCode
,
@AnimRes
final
int
enterAnim
,
@AnimRes
final
int
exitAnim
)
{
startActivityForResult
(
activity
,
extras
,
pkg
,
cls
,
requestCode
,
getOptionsBundle
(
activity
,
enterAnim
,
exitAnim
));
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
JELLY_BEAN
)
{
activity
.
overridePendingTransition
(
enterAnim
,
exitAnim
);
}
}
/**
* Start the activity for result.
*
* @param activity The activity.
* @param intent The description of the activity to start.
* @param requestCode if >= 0, this code will be returned in
* onActivityResult() when the activity exits.
*/
public
static
void
startActivityForResult
(
@NonNull
final
Activity
activity
,
@NonNull
final
Intent
intent
,
final
int
requestCode
)
{
startActivityForResult
(
intent
,
activity
,
requestCode
,
null
);
}
/**
* Start the activity for result.
*
* @param activity The activity.
* @param intent The description of the activity to start.
* @param requestCode if >= 0, this code will be returned in
* onActivityResult() when the activity exits.
* @param options Additional options for how the Activity should be started.
*/
public
static
void
startActivityForResult
(
@NonNull
final
Activity
activity
,
@NonNull
final
Intent
intent
,
final
int
requestCode
,
final
Bundle
options
)
{
startActivityForResult
(
intent
,
activity
,
requestCode
,
options
);
}
/**
* Start the activity for result.
*
* @param activity The activity.
* @param intent The description of the activity to start.
* @param requestCode if >= 0, this code will be returned in
* onActivityResult() when the activity exits.
* @param sharedElements The names of the shared elements to transfer to the called
* Activity and their associated Views.
*/
public
static
void
startActivityForResult
(
@NonNull
final
Activity
activity
,
@NonNull
final
Intent
intent
,
final
int
requestCode
,
final
View
...
sharedElements
)
{
startActivityForResult
(
intent
,
activity
,
requestCode
,
getOptionsBundle
(
activity
,
sharedElements
));
}
/**
* Start the activity for result.
*
* @param activity The activity.
* @param intent The description of the activity to start.
* @param requestCode if >= 0, this code will be returned in
* onActivityResult() when the activity exits.
* @param enterAnim A resource ID of the animation resource to use for the
* incoming activity.
* @param exitAnim A resource ID of the animation resource to use for the
* outgoing activity.
*/
public
static
void
startActivityForResult
(
@NonNull
final
Activity
activity
,
@NonNull
final
Intent
intent
,
final
int
requestCode
,
@AnimRes
final
int
enterAnim
,
@AnimRes
final
int
exitAnim
)
{
startActivityForResult
(
intent
,
activity
,
requestCode
,
getOptionsBundle
(
activity
,
enterAnim
,
exitAnim
));
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
JELLY_BEAN
)
{
activity
.
overridePendingTransition
(
enterAnim
,
exitAnim
);
}
}
/**
* Start activities.
*
...
...
@@ -1203,6 +1518,29 @@ public final class ActivityUtils {
}
}
private
static
void
startActivityForResult
(
final
Activity
activity
,
final
Bundle
extras
,
final
String
pkg
,
final
String
cls
,
final
int
requestCode
,
final
Bundle
options
)
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
);
if
(
extras
!=
null
)
intent
.
putExtras
(
extras
);
intent
.
setComponent
(
new
ComponentName
(
pkg
,
cls
));
startActivityForResult
(
intent
,
activity
,
requestCode
,
options
);
}
private
static
void
startActivityForResult
(
final
Intent
intent
,
final
Activity
activity
,
final
int
requestCode
,
final
Bundle
options
)
{
if
(
options
!=
null
&&
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN
)
{
activity
.
startActivityForResult
(
intent
,
requestCode
,
options
);
}
else
{
activity
.
startActivityForResult
(
intent
,
requestCode
);
}
}
private
static
void
startActivities
(
final
Intent
[]
intents
,
final
Context
context
,
final
Bundle
options
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录